take one id per summoned character, not one per play
the spawn log caught it at once: two archers took 11 and 12, and the goblins that followed started again at 12, then the knight landed on 13. the counter moved by one per card while a card can summon several. two objects sharing a global id are one object to the client - getGameObjectIndex finds the first and reuses it - so the duplicates never became objects, never got models, and left the client and the server holding different sets, which no checksum can survive.
This commit is contained in:
parent
1983b2f6ac
commit
252277ec8d
1 changed files with 7 additions and 4 deletions
|
|
@ -325,10 +325,11 @@ impl BattleSession {
|
|||
.position(|id| *id == account)
|
||||
.map(|index| index as i32)
|
||||
}
|
||||
pub fn next_instance(&mut self) -> i32 {
|
||||
let instance = self.next_instance;
|
||||
self.next_instance += 1;
|
||||
instance
|
||||
pub fn next_instance(&self) -> i32 {
|
||||
self.next_instance
|
||||
}
|
||||
pub fn reserve_instances(&mut self, count: usize) {
|
||||
self.next_instance += count.max(1) as i32;
|
||||
}
|
||||
pub fn deck_card(&self, owner: i32, slot: i32) -> Option<LogicDataRef> {
|
||||
let deck = self.mode.battle.decks.get(owner.max(0) as usize)?.as_ref()?;
|
||||
|
|
@ -379,6 +380,7 @@ impl BattleRegistry {
|
|||
session.advance_to_now();
|
||||
if let Some((card, position, instance)) = session.take_bot_play() {
|
||||
let entries = summon(&card, position, crate::bot::BOT_OWNER_INDEX, instance);
|
||||
session.reserve_instances(entries.len());
|
||||
if !entries.is_empty() {
|
||||
tracing::debug!(card = %card, count = entries.len(), "the bot played a card");
|
||||
for entry in entries {
|
||||
|
|
@ -457,6 +459,7 @@ impl BattleRegistry {
|
|||
let cost = card.data().map(|row| row.int("ManaCost")).unwrap_or(0);
|
||||
session.spend_mana(owner, cost);
|
||||
let entries = summon(&card, position, owner, session.next_instance());
|
||||
session.reserve_instances(entries.len());
|
||||
let spawned = entries.len();
|
||||
session.queue(at_tick, entries);
|
||||
spawned
|
||||
|
|
|
|||
Loading…
Reference in a new issue