Browse Source

postpone next turn logic after victory / loss status is settled

Andrej Dudenhefner 1 month ago
parent
commit
dec72aa5e1
2 changed files with 4 additions and 4 deletions
  1. 3 3
      server/CGameHandler.cpp
  2. 1 1
      server/processors/TurnOrderProcessor.h

+ 3 - 3
server/CGameHandler.cpp

@@ -3614,9 +3614,6 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
 		}
 		else
 		{
-			// give turn to next player(s)
-			turnOrder->onPlayerEndsGame(player);
-
 			//copy heroes vector to avoid iterator invalidation as removal change PlayerState
 			auto hlp = p->getHeroes();
 			for (const auto * h : hlp) //eliminate heroes
@@ -3654,6 +3651,9 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
 				}
 			}
 			checkVictoryLossConditions(playerColors);
+			// give turn to next player(s)
+			if(gameServer().getState() != EServerState::SHUTDOWN)
+				turnOrder->onPlayerEndsGame(player);
 		}
 	}
 }

+ 1 - 1
server/processors/TurnOrderProcessor.h

@@ -88,7 +88,7 @@ public:
 	/// NetPack call-in
 	bool onPlayerEndsTurn(PlayerColor which);
 
-	/// Ends player turn and removes this player from turn order
+	/// Ends player turn and removes this player from turn order, starting turns for next players if possible
 	void onPlayerEndsGame(PlayerColor which);
 
 	/// Start game (or resume from save) and send PlayerStartsTurn pack to player(s)