1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

#1228 - prevent second AI activation on AI defeat due to wrong EndTurn packet

This commit is contained in:
Andrii Danylchenko
2022-12-14 22:13:26 +02:00
parent bd7f78b8d5
commit 56bf8ec2c4
6 changed files with 36 additions and 2 deletions

View File

@ -89,7 +89,17 @@ bool SaveGame::applyGh(CGameHandler * gh)
bool EndTurn::applyGh(CGameHandler * gh)
{
PlayerColor player = GS(gh)->currentPlayer;
PlayerColor currentPlayer = GS(gh)->currentPlayer;
if(player != currentPlayer)
{
if(gh->getPlayerStatus(player) == EPlayerStatus::INGAME)
throwAndComplain(gh, "Player attempted to end turn for another player!");
logGlobal->debug("Player attempted to end turn after game over. Ignoring this request.");
return true;
}
throwOnWrongPlayer(gh, player);
if(gh->queries.topQuery(player))
throwAndComplain(gh, "Cannot end turn before resolving queries!");