1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fixed possible crash at the game start (when victory conditions are checked before currentPlayer is set).

This commit is contained in:
Michał W. Urbańczyk 2014-02-01 16:08:01 +00:00
parent 14535c1c7b
commit e5312887d1

View File

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