diff --git a/server/TurnTimerHandler.cpp b/server/TurnTimerHandler.cpp index 2fbda0227..f61b4e4d8 100644 --- a/server/TurnTimerHandler.cpp +++ b/server/TurnTimerHandler.cpp @@ -88,12 +88,21 @@ void TurnTimerHandler::onPlayerMakingTurn(PlayerState & state, int waitTime) } } -void TurnTimerHandler::onBattleStart(PlayerState & state) +void TurnTimerHandler::onBattleStart() { - if(const auto * si = gameHandler.getStartInfo()) + const auto * gs = gameHandler.gameState(); + const auto * si = gameHandler.getStartInfo(); + if(!si || !gs || !gs->curB || !si->turnTimerInfo.isBattleEnabled()) + return; + + auto attacker = gs->curB->getSidePlayer(BattleSide::ATTACKER); + auto defender = gs->curB->getSidePlayer(BattleSide::DEFENDER); + + for(auto i : {attacker, defender}) { - if(si->turnTimerInfo.isBattleEnabled()) + if(i.isValidPlayer()) { + const auto & state = gs->players.at(i); TurnTimeUpdate ttu; ttu.player = state.color; ttu.turnTimer = state.turnTimer; diff --git a/server/TurnTimerHandler.h b/server/TurnTimerHandler.h index acc545acc..602ecfde0 100644 --- a/server/TurnTimerHandler.h +++ b/server/TurnTimerHandler.h @@ -33,7 +33,7 @@ public: void onGameplayStart(PlayerState & state); void onPlayerGetTurn(PlayerState & state); void onPlayerMakingTurn(PlayerState & state, int waitTime); - void onBattleStart(PlayerState & state); + void onBattleStart(); void onBattleNextStack(const CStack & stack); void onBattleLoop(int waitTime); }; diff --git a/server/battles/BattleFlowProcessor.cpp b/server/battles/BattleFlowProcessor.cpp index 72d7b612e..0f0837a47 100644 --- a/server/battles/BattleFlowProcessor.cpp +++ b/server/battles/BattleFlowProcessor.cpp @@ -130,6 +130,8 @@ void BattleFlowProcessor::onBattleStarted() assert(gameHandler->gameState()->curB); tryPlaceMoats(); + + gameHandler->turnTimerHandler.onBattleStart(); if (gameHandler->gameState()->curB->tacticDistance == 0) onTacticsEnded();