From e5312887d1f16972073fa835004b42da3d5d910b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sat, 1 Feb 2014 16:08:01 +0000 Subject: [PATCH] Fixed possible crash at the game start (when victory conditions are checked before currentPlayer is set). --- server/CGameHandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index a6ca96cc6..4d688a2e3 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5193,9 +5193,11 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player) checkVictoryLossConditions(playerColors); } - //If player making turn has lost his turn must be over as well - if(gs->getPlayer(gs->currentPlayer)->status != EPlayerStatus::INGAME) + auto playerInfo = gs->getPlayer(gs->currentPlayer, false); + // If we are called before the actual game start, there might be no current player + if(playerInfo && playerInfo->status != EPlayerStatus::INGAME) { + // If player making turn has lost his turn must be over as well states.setFlag(gs->currentPlayer, &PlayerStatus::makingTurn, false); } }