fixed nasty bug that stopped animations when defining 'door_2' off-screen
[rocksndiamonds.git] / src / tools.c
index 9b573f66c2c2bbebb0880b9d882808ce1135d4e0..55a28fc40d0cf13ef90ec1df29c3910bb15e5661 100644 (file)
@@ -759,6 +759,13 @@ void BackToFront()
       y2 = MAX(y2, EY + EYSIZE);
     }
 
+    // make sure that at least one pixel is blitted, and inside the screen
+    // (else nothing is blitted, causing the animations not to be updated)
+    x1 = MIN(MAX(0, x1), WIN_XSIZE - 1);
+    y1 = MIN(MAX(0, y1), WIN_YSIZE - 1);
+    x2 = MIN(MAX(1, x2), WIN_XSIZE);
+    y2 = MIN(MAX(1, y2), WIN_YSIZE);
+
     BlitBitmap(backbuffer, window, x1, y1, x2 - x1, y2 - y1, x1, y1);
   }
 
@@ -8398,7 +8405,11 @@ void PlayMenuMusicExt(int music)
 
 void PlayMenuMusic()
 {
-  PlayMenuMusicExt(menu.music[game_status]);
+  char *curr_music = getCurrentlyPlayingMusicFilename();
+  char *next_music = getMusicListEntry(menu.music[game_status])->filename;
+
+  if (!strEqual(curr_music, next_music))
+    PlayMenuMusicExt(menu.music[game_status]);
 }
 
 void PlayMenuSoundsAndMusic()
@@ -8407,9 +8418,24 @@ void PlayMenuSoundsAndMusic()
   PlayMenuMusic();
 }
 
+static void FadeMenuSounds()
+{
+  FadeSounds();
+}
+
+static void FadeMenuMusic()
+{
+  char *curr_music = getCurrentlyPlayingMusicFilename();
+  char *next_music = getMusicListEntry(menu.music[game_status])->filename;
+
+  if (!strEqual(curr_music, next_music))
+    FadeMusic();
+}
+
 void FadeMenuSoundsAndMusic()
 {
-  FadeSoundsAndMusic();
+  FadeMenuSounds();
+  FadeMenuMusic();
 }
 
 void PlaySoundActivating()