fixed support for restart key when playing BD games with multiple lives
authorHolger Schemel <holger.schemel@virtion.de>
Sun, 5 Jan 2025 21:04:17 +0000 (22:04 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Sun, 5 Jan 2025 21:04:28 +0000 (22:04 +0100)
src/events.c
src/tape.c

index bdec3b21e54c895883dace90b3eda317fb1430cd..16a84e920db34dcc2a446938fa1d0a682c395974 100644 (file)
@@ -1409,16 +1409,6 @@ static void HandleButtonOrFinger(int mx, int my, int button)
 
 static boolean checkTextInputKey(Key key)
 {
-  static int game_status_last_static = -1;
-  int game_status_last = game_status_last_static;      // game status from previous function call
-
-  game_status_last_static = game_status;               // set game status for next function call
-
-  // needed after ending game using restart key without asking in BD engine with last life
-  // (to handle race condition due to handling all key events as key event and text event)
-  if (game_status_last == GAME_MODE_PLAYING)
-    return FALSE;
-
   // when playing, only handle raw key events and ignore text input
   if (game_status == GAME_MODE_PLAYING)
     return FALSE;
index a4b8ed96dcc34fcc492198d11a5fe615bad41f54..cefc170f9b66a357e11327bc27bc0890e9f4934a 100644 (file)
@@ -1411,28 +1411,24 @@ void TapeRestartGame(void)
     return;
   }
 
+  if (!checkRestartGame("Restart game?"))
+    return;
+
   if (level.game_engine_type == GAME_ENGINE_TYPE_BD &&
       setup.bd_multiple_lives && game_status == GAME_MODE_PLAYING)
   {
     if (game_bd.global_lives > 1)
     {
-      if (!checkRestartGame("Restart game?"))
-        return;
-
+      // decrement number of lives (also for intermissions; will be added later)
       game_bd.global_lives--;
     }
     else
     {
-      RequestQuitGame(FALSE);
-
-      return;
+      // new BD game with multiple lives started, so set initial number of lives and global score
+      game_bd.global_lives = level.native_bd_level->caveset->initial_lives;
+      game_bd.global_score = 0;
     }
   }
-  else
-  {
-    if (!checkRestartGame("Restart game?"))
-      return;
-  }
 
   StartGameActions(network.enabled, setup.autorecord, level.random_seed);
 }