From eb0af0096e1c54459a1c825687cf3ddba25635f5 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sat, 24 Oct 2015 18:16:57 +0200 Subject: [PATCH] Fixed #2072. --- server/CGameHandler.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 01bf8a9d4..17b0f7ed6 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1510,6 +1510,25 @@ void CGameHandler::newTurn() elem->newTurn(); } + //count days without town for all players, regardless of their turn order + for (auto p = gs->players.begin(); p != gs->players.end(); p++) + { + PlayerState * playerState = &p->second; + if (playerState->status == EPlayerStatus::INGAME) + { + if (playerState->towns.empty()) + { + if (playerState->daysWithoutCastle) + ++(*playerState->daysWithoutCastle); + else playerState->daysWithoutCastle = 0; + } + else + { + playerState->daysWithoutCastle = boost::none; + } + } + } + synchronizeArtifactHandlerLists(); //new day events may have changed them. TODO better of managing that } void CGameHandler::run(bool resume) @@ -1590,18 +1609,6 @@ void CGameHandler::run(bool resume) PlayerState * playerState = &gs->players[playerColor]; //can't copy CBonusSystemNode by value if (playerState->status == EPlayerStatus::INGAME) { - //count days without town - if (playerState->towns.empty()) - { - if (playerState->daysWithoutCastle) - ++(*playerState->daysWithoutCastle); - else playerState->daysWithoutCastle = 0; - } - else - { - playerState->daysWithoutCastle = boost::none; //TODO: reset this immediatelly when player conquers any castle - } - //if player runs out of time, he shouldn't get the turn (especially AI) checkVictoryLossConditionsForAll();