diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 2ad5a0d63..4e6c03193 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -601,6 +601,13 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build castleInt->townlist->update(town); } +void CPlayerInterface::battleStartBefore(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2) +{ + //Don't wait for dialogs when we are non-active hot-seat player + if(LOCPLINT == this) + waitForAllDialogs(); +} + void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) { EVENT_HANDLER_CALLED_BY_CLIENT; @@ -991,6 +998,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, CComponent * comp void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector & components, int soundID, bool delComps) { + LOG_TRACE_PARAMS(logGlobal, "player=%s, text=%s, is LOCPLINT=%d", playerID % text % (this==LOCPLINT)); waitWhileDialog(); if (settings["session"]["autoSkip"].Bool() && !LOCPLINT->shiftPressed()) diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index d7661f9ca..5449f36db 100644 --- a/client/CPlayerInterface.h +++ b/client/CPlayerInterface.h @@ -203,6 +203,7 @@ public: void battleStacksEffectsSet(const SetStackEffect & sse) override; //called when a specific effect is set to stacks void battleTriggerEffect(const BattleTriggerEffect & bte) override; //various one-shot effect void battleStacksAttacked(const std::vector & bsa) override; + void battleStartBefore(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2) override; //called by engine just before battle starts; side=0 - left, side=1 - right void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override; //called by engine when battle starts; side=0 - left, side=1 - right void battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; //called when stacks are healed / resurrected void battleNewStackAppeared(const CStack * stack) override; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 74b32f07f..e6d069439 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -600,6 +600,17 @@ void ExchangeDialog::applyCl(CClient *cl) INTERFACE_CALL_IF_PRESENT(heroes[0]->tempOwner, heroExchangeStarted, heroes[0]->id, heroes[1]->id, queryID); } +void BattleStart::applyFirstCl( CClient *cl ) +{ + //Cannot use the usual macro because curB is not set yet + CALL_ONLY_THAT_BATTLE_INTERFACE(info->sides[0].color, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject, + info->tile, info->sides[0].hero, info->sides[1].hero); + CALL_ONLY_THAT_BATTLE_INTERFACE(info->sides[1].color, battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject, + info->tile, info->sides[0].hero, info->sides[1].hero); + BATTLE_INTERFACE_CALL_RECEIVERS(battleStartBefore, info->sides[0].armyObject, info->sides[1].armyObject, + info->tile, info->sides[0].hero, info->sides[1].hero); +} + void BattleStart::applyCl( CClient *cl ) { cl->battleStarted(info); diff --git a/lib/IGameEventsReceiver.h b/lib/IGameEventsReceiver.h index c2b5165eb..3f4a4ae18 100644 --- a/lib/IGameEventsReceiver.h +++ b/lib/IGameEventsReceiver.h @@ -60,6 +60,7 @@ public: virtual void battleSpellCast(const BattleSpellCast *sc){}; virtual void battleStacksEffectsSet(const SetStackEffect & sse){};//called when a specific effect is set to stacks virtual void battleTriggerEffect(const BattleTriggerEffect & bte){}; //called for various one-shot effects + virtual void battleStartBefore(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2) {}; //called just before battle start virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right virtual void battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp virtual void battleNewStackAppeared(const CStack * stack){}; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 0e1e09b55..db68eeac9 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1357,6 +1357,8 @@ struct BattleInfo; struct BattleStart : public CPackForClient//3000 { BattleStart(){type = 3000;}; + + void applyFirstCl(CClient *cl); void applyCl(CClient *cl); DLL_LINKAGE void applyGs(CGameState *gs);