moved handling game over condition from MM game engine to main engine
authorHolger Schemel <info@artsoft.org>
Sun, 12 Mar 2023 14:55:49 +0000 (15:55 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 12 Mar 2023 14:56:26 +0000 (15:56 +0100)
src/game.c
src/game_mm/export.h
src/game_mm/mm_game.c

index 2ae8886f5c6d7fe80f49c4676c4ccc7568240b21..d91d8ac3ec629de5625ce29485531dba7c64bfa9 100644 (file)
@@ -15668,6 +15668,10 @@ static char *getRestartGameMessage(void)
   char *game_over_text = "Game over!";
   char *play_again_text = " Play it again?";
 
+  if (level.game_engine_type == GAME_ENGINE_TYPE_MM &&
+      game_mm.game_over_message != NULL)
+    game_over_text = game_mm.game_over_message;
+
   snprintf(message, MAX_OUTPUT_LINESIZE, "%s%s", game_over_text,
           (play_again ? play_again_text : ""));
 
index 6fbe1aa9a9b3c750f4a74db8c7f53f628849a725..4c98623de60b0a7b9e1291909e03a0d9b868a97b 100644 (file)
@@ -147,6 +147,7 @@ struct GameInfo_MM
   boolean level_solved;
   boolean game_over;
   int game_over_cause;
+  char *game_over_message;
 
   boolean cheat_no_overload;
   boolean cheat_no_explosion;
index 8cc08bc47527ed8dd825ac912233a32b631f4d93..d57c5a3b0911f66ff6f1f05ee6bfcf734b23fd52 100644 (file)
@@ -669,6 +669,7 @@ void InitGameEngine_MM(void)
   game_mm.level_solved = FALSE;
   game_mm.game_over = FALSE;
   game_mm.game_over_cause = 0;
+  game_mm.game_over_message = NULL;
 
   game_mm.laser_overload_value = 0;
   game_mm.laser_enabled = FALSE;
@@ -805,25 +806,15 @@ static void FadeOutLaser(void)
 
 static void GameOver_MM(int game_over_cause)
 {
-  // do not handle game over if request dialog is already active
-  if (game.request_active)
-    return;
-
   game_mm.game_over = TRUE;
   game_mm.game_over_cause = game_over_cause;
-
-  // do not ask to play again if game was never actually played
-  if (!game.GamePlayed)
-    return;
-
-  if (setup.ask_on_game_over)
-    game.restart_game_message = (game_over_cause == GAME_OVER_BOMB ?
-                                "Bomb killed Mc Duffin! Play it again?" :
-                                game_over_cause == GAME_OVER_NO_ENERGY ?
-                                "Out of magic energy! Play it again?" :
-                                game_over_cause == GAME_OVER_OVERLOADED ?
-                                "Magic spell hit Mc Duffin! Play it again?" :
-                                NULL);
+  game_mm.game_over_message = (game_over_cause == GAME_OVER_BOMB ?
+                              "Bomb killed Mc Duffin!" :
+                              game_over_cause == GAME_OVER_NO_ENERGY ?
+                              "Out of magic energy!" :
+                              game_over_cause == GAME_OVER_OVERLOADED ?
+                              "Magic spell hit Mc Duffin!" :
+                              NULL);
 
   SetTileCursorActive(FALSE);
 }