added support for "player is moving up/down" graphics for BD engine
[rocksndiamonds.git] / src / game.c
index 9127a1b6a5be48bc22c593b6ff728b8a02269192..506def33ce0682ae91f3903b2802715300dcba56 100644 (file)
@@ -3974,8 +3974,6 @@ void InitGame(void)
 
   game.explosions_delayed = TRUE;
 
-  game.envelope_active = FALSE;
-
   // special case: set custom artwork setting to initial value
   game.use_masked_elements = game.use_masked_elements_initial;
 
@@ -4622,6 +4620,8 @@ 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();
@@ -5161,10 +5161,19 @@ void GameEnd(void)
   // used instead of "level_nr" (needed for network games)
   int last_level_nr = levelset.level_nr;
   boolean tape_saved = FALSE;
+  boolean game_over = checkGameFailed();
 
   // 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 game over and automatically asking for game restart
+  if (game_over && setup.ask_on_game_over)
+    return;
+
+  // do not handle game end if request dialog is already active
+  if (checkRequestActive())
+    return;
+
   if (game.LevelSolved)
     game.LevelSolved_GameEnd = TRUE;
 
@@ -15863,7 +15872,7 @@ static int getSoundEffect_BD(int element_bd, int sample)
 
 void PlayLevelSound_BD(int xx, int yy, int element_bd, int sample)
 {
-  int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+  int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
   int sound_effect = getSoundEffect_BD(element, sample);
   int sound_action = getSoundAction_BD(sample);
   boolean is_loop_sound = IS_LOOP_SOUND(sound_effect);
@@ -15887,7 +15896,7 @@ void PlayLevelSound_BD(int xx, int yy, int element_bd, int sample)
 
 void StopSound_BD(int element_bd, int sample)
 {
-  int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+  int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
   int sound_effect = getSoundEffect_BD(element, sample);
 
   if (sound_effect != SND_UNDEFINED)
@@ -15896,7 +15905,7 @@ void StopSound_BD(int element_bd, int sample)
 
 boolean isSoundPlaying_BD(int element_bd, int sample)
 {
-  int element = (element_bd > -1 ? map_element_BD_to_RND(element_bd) : 0);
+  int element = (element_bd > -1 ? map_element_BD_to_RND_game(element_bd) : 0);
   int sound_effect = getSoundEffect_BD(element, sample);
 
   if (sound_effect != SND_UNDEFINED)
@@ -16343,7 +16352,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
@@ -16412,6 +16421,11 @@ boolean checkGameEnded(void)
   return (checkGameSolved() || checkGameFailed());
 }
 
+boolean checkRequestActive(void)
+{
+  return (game.request_active || game.envelope_active || game.any_door_active);
+}
+
 
 // ----------------------------------------------------------------------------
 // random generator functions