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

Use timers for turns only if turn timer is set and for pvp battles -

only if unit timer is set to avoid "bad" edge case where player can
completely run out of time
This commit is contained in:
Ivan Savenko 2023-12-20 16:16:58 +02:00
parent c4b8cc877b
commit 4986b9031d

View File

@ -126,6 +126,10 @@ void TurnTimerHandler::onPlayerMakingTurn(PlayerColor player, int waitTime)
const auto * state = gameHandler.getPlayerState(player);
if(state && state->human && timer.isActive && !timer.isBattle && state->status == EPlayerStatus::INGAME)
{
// turn timers are only used if turn timer is non-zero
if (si->turnTimerInfo.turnTimer == 0)
return;
if(timerCountDown(timer.turnTimer, si->turnTimerInfo.turnTimer, player, waitTime))
return;
@ -276,17 +280,21 @@ void TurnTimerHandler::onBattleLoop(const BattleID & battleID, int waitTime)
auto & timer = timers[player];
if(timer.isActive && timer.isBattle)
{
if (timerCountDown(timer.unitTimer, si->turnTimerInfo.unitTimer, player, waitTime))
// in pvp battles, timers are only used if unit timer is non-zero
if(isPvpBattle(battleID) && si->turnTimerInfo.unitTimer == 0)
return;
if (timerCountDown(timer.battleTimer, si->turnTimerInfo.battleTimer, player, waitTime))
return;
if (timerCountDown(timer.unitTimer, si->turnTimerInfo.unitTimer, player, waitTime))
return;
if (timerCountDown(timer.turnTimer, si->turnTimerInfo.turnTimer, player, waitTime))
return;
if (timerCountDown(timer.battleTimer, si->turnTimerInfo.battleTimer, player, waitTime))
return;
if (timerCountDown(timer.baseTimer, si->turnTimerInfo.baseTimer, player, waitTime))
return;
if (timerCountDown(timer.turnTimer, si->turnTimerInfo.turnTimer, player, waitTime))
return;
if (timerCountDown(timer.baseTimer, si->turnTimerInfo.baseTimer, player, waitTime))
return;
if(isPvpBattle(battleID))
{