fixed stopping sounds while (un)covering screen when using BD engine
authorHolger Schemel <holger.schemel@virtion.de>
Tue, 14 Jan 2025 22:36:17 +0000 (23:36 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Tue, 14 Jan 2025 22:36:19 +0000 (23:36 +0100)
When using the BD engine, this change prevents stopping (fading)
sounds after covering the screen if immediately followed by uncovering
the screen again when either restarting a game or starting a new game
directly after finishing the previous game.

src/game.c

index 03b555bff585023b6b8a65fbdb35fe47288ad52c..2f31bc7ff50946c0a0adc0411778d83e8adeb748 100644 (file)
@@ -1126,6 +1126,7 @@ static void PlayLevelSoundElementActionIfLoop(int, int, int, int);
 static void PlayLevelSoundActionIfLoop(int, int, int);
 static void StopLevelSoundActionIfLoop(int, int, int);
 static void PlayLevelMusic(void);
+static void FadeLevelMusic(void);
 static void FadeLevelSoundsAndMusic(void);
 
 static void HandleGameButtons(struct GadgetInfo *);
@@ -3717,6 +3718,16 @@ static void DebugPrintPlayerStatus(char *message)
 }
 #endif
 
+static boolean checkKeepPlayingSoundsWhenRestarting(boolean restarting)
+{
+  // keep playing continuous loop sound during covering and uncovering screen for BD engine
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD &&
+      restarting && game.keep_panel_open_when_restarting)
+    return TRUE;
+
+  return FALSE;
+}
+
 static boolean checkCloseGamePanelDoor(boolean restarting)
 {
   // do not close game panel door if game restart was triggered by CE action
@@ -3820,7 +3831,10 @@ void InitGame(void)
   // cover BD screen before closing game panel door
   CoverScreen();
 
-  FadeLevelSoundsAndMusic();
+  if (checkKeepPlayingSoundsWhenRestarting(restarting))
+    FadeLevelMusic();
+  else
+    FadeLevelSoundsAndMusic();
 
   if (checkCloseGamePanelDoor(restarting))
     CloseDoor(DOOR_CLOSE_1);