fixed another bug with game restart request when opening/closing doors
[rocksndiamonds.git] / src / game.c
index 2c16aa62c93d95c8a5344eb9f5d44aea92955c54..ec86a61f86edcfde7e1b1fbe15decc49a91f41b1 100644 (file)
@@ -4621,6 +4621,7 @@ void InitGame(void)
   game.restart_level = FALSE;
   game.request_active = FALSE;
   game.envelope_active = FALSE;
+  game.any_door_active = FALSE;
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     InitGameActions_MM();
@@ -5164,6 +5165,10 @@ void GameEnd(void)
   // Important note: This function is not only called after "GameWon()", but also after
   // "game over" (if automatically asking for restarting the game is disabled in setup)
 
+  // do not handle game end if request dialog is already active
+  if (checkRequestActive())
+    return;
+
   if (game.LevelSolved)
     game.LevelSolved_GameEnd = TRUE;
 
@@ -16342,7 +16347,7 @@ boolean CheckRestartGame(void)
   }
 
   // do not ask to play again if request dialog is already active
-  if (game.request_active)
+  if (checkRequestActive())
     return FALSE;
 
   // do not ask to play again if request dialog already handled
@@ -16411,6 +16416,11 @@ boolean checkGameEnded(void)
   return (checkGameSolved() || checkGameFailed());
 }
 
+boolean checkRequestActive(void)
+{
+  return (game.request_active || game.envelope_active || game.any_door_active);
+}
+
 
 // ----------------------------------------------------------------------------
 // random generator functions