1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fix battle timer reset after refactoring

This commit is contained in:
nordsoft 2023-08-22 14:14:50 +04:00
parent dd3e9f102b
commit fb21620c60
3 changed files with 15 additions and 4 deletions

View File

@ -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;

View File

@ -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);
};

View File

@ -130,6 +130,8 @@ void BattleFlowProcessor::onBattleStarted()
assert(gameHandler->gameState()->curB);
tryPlaceMoats();
gameHandler->turnTimerHandler.onBattleStart();
if (gameHandler->gameState()->curB->tacticDistance == 0)
onTacticsEnded();