ソースを参照

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

Michał W. Urbańczyk 11 年 前
コミット
e5312887d1
1 ファイル変更4 行追加2 行削除
  1. 4 2
      server/CGameHandler.cpp

+ 4 - 2
server/CGameHandler.cpp

@@ -5193,9 +5193,11 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
 			checkVictoryLossConditions(playerColors);
 			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);
 			states.setFlag(gs->currentPlayer, &PlayerStatus::makingTurn, false);
 		}
 		}
 	}
 	}