fixed bugs when re-charging laser with fuel element in MM engine
authorHolger Schemel <info@artsoft.org>
Tue, 3 Jan 2023 23:52:58 +0000 (00:52 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 3 Jan 2023 23:52:58 +0000 (00:52 +0100)
src/game_mm/mm_game.c

index d001df011b9c3bcc5e3ffe9294122ca767746e5d..7ab1c98a3b8be997de2b995266bf14a0bf4df134 100644 (file)
@@ -3679,24 +3679,27 @@ static void GameActions_MM_Ext(void)
 
   if (element == EL_FUEL_FULL && CT > 10)
   {
-    for (i = game_mm.energy_left; i <= MAX_LASER_ENERGY; i+=2)
+    int num_init_game_frames = INIT_GAME_ACTIONS_DELAY;
+    int start = num_init_game_frames * game_mm.energy_left / native_mm_level.time;
+
+    for (i = start; i <= num_init_game_frames; i++)
     {
-#if 0
-      BlitBitmap(pix[PIX_DOOR], drawto,
-                DOOR_GFX_PAGEX4 + XX_ENERGY,
-                DOOR_GFX_PAGEY1 + YY_ENERGY + ENERGY_YSIZE - i,
-                ENERGY_XSIZE, i, DX_ENERGY,
-                DY_ENERGY + ENERGY_YSIZE - i);
-#endif
+      if (i == num_init_game_frames)
+       StopSound_MM(SND_MM_GAME_LEVELTIME_CHARGING);
+      else if (setup.sound_loops)
+       PlaySoundLoop_MM(SND_MM_GAME_LEVELTIME_CHARGING);
+      else
+       PlaySound_MM(SND_MM_GAME_LEVELTIME_CHARGING);
 
-      redraw_mask |= REDRAW_DOOR_1;
-      BackToFront();
+      game_mm.energy_left = native_mm_level.time * i / num_init_game_frames;
 
-      Delay_WithScreenUpdates(20);
+      UpdateAndDisplayGameControlValues();
+
+      BackToFront();
     }
 
-    game_mm.energy_left = MAX_LASER_ENERGY;
-    Tile[ELX][ELY] = EL_FUEL_EMPTY;
+    Tile[ELX][ELY] = laser.dest_element = EL_FUEL_EMPTY;
+
     DrawField_MM(ELX, ELY);
 
     DrawLaser(0, DL_LASER_ENABLED);