added asking for restart after game was lost (MM game engine only)
[rocksndiamonds.git] / src / game.c
index 02331879311f3a7680e95bcd80e3a37148220f0e..f8606638343c4427fddb0d3f93790a1d4a4e48e0 100644 (file)
@@ -4227,6 +4227,7 @@ void InitGame()
   }
 
   game.restart_level = FALSE;
+  game.restart_game_message = NULL;
 
   if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     InitGameActions_MM();
@@ -4692,14 +4693,16 @@ void GameEnd()
 
   local_player->LevelSolved_GameEnd = TRUE;
 
-  if (!global.use_envelope_request)
-    CloseDoor(DOOR_CLOSE_1);
-
   if (local_player->LevelSolved_SaveTape)
   {
+    /* make sure that request dialog to save tape does not open door again */
+    if (!global.use_envelope_request)
+      CloseDoor(DOOR_CLOSE_1);
+
     SaveTapeChecked(tape.level_nr);    /* ask to save tape */
   }
 
+  /* if no tape is to be saved, close both doors simultaneously */
   CloseDoor(DOOR_CLOSE_ALL);
 
   if (level_editor_test_game)
@@ -14956,6 +14959,22 @@ void RequestQuitGame(boolean ask_if_really_quit)
                     "Do you really want to quit the game?");
 }
 
+void RequestRestartGame(char *message)
+{
+  game.restart_game_message = NULL;
+
+  if (Request(message, REQ_ASK | REQ_STAY_CLOSED))
+  {
+    StartGameActions(options.network, setup.autorecord, level.random_seed);
+  }
+  else
+  {
+    SetGameStatus(GAME_MODE_MAIN);
+
+    DrawMainMenu();
+  }
+}
+
 
 /* ------------------------------------------------------------------------- */
 /* random generator functions                                                */
@@ -15266,7 +15285,7 @@ void LoadEngineSnapshotValues()
     LoadEngineSnapshotValues_EM();
   if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
     LoadEngineSnapshotValues_SP();
-  if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+  if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     LoadEngineSnapshotValues_MM();
 }