fixed drawing overloaded laser when rotating McDuffin in MM engine
[rocksndiamonds.git] / src / game_mm / mm_game.c
index c3d573db93c59ff2430e378f4c7595246b49e1fe..b4fef9625ddd6fc80289cf23b7f948e183a3d4a2 100644 (file)
@@ -573,10 +573,13 @@ static void InitLaser(void)
 
   AddLaserEdge(LX, LY);                // set laser starting edge
 
+  int color_up = 0xFF * laser.overload_value / MAX_LASER_OVERLOAD;
+  int color_down = 0xFF - color_up;
+
   pen_ray = GetPixelFromRGB(window,
-                           native_mm_level.laser_red   * 0xFF,
-                           native_mm_level.laser_green * 0xFF,
-                           native_mm_level.laser_blue  * 0xFF);
+                           (native_mm_level.laser_red   ? 0xFF : color_up),
+                           (native_mm_level.laser_green ? color_down : 0x00),
+                           (native_mm_level.laser_blue  ? color_down : 0x00));
 }
 
 void InitGameEngine_MM(void)
@@ -740,6 +743,27 @@ static void FadeOutLaser(boolean overloaded)
     StopSound_MM(SND_MM_GAME_HEALTH_CHARGING);
 }
 
+static void GameOver_MM(int game_over_cause)
+{
+  // do not handle game over if request dialog is already active
+  if (game.request_active)
+    return;
+
+  game_mm.game_over = TRUE;
+  game_mm.game_over_cause = game_over_cause;
+
+  if (setup.ask_on_game_over)
+    game.restart_game_message = (game_over_cause == GAME_OVER_BOMB ?
+                                "Bomb killed Mc Duffin! Play it again?" :
+                                game_over_cause == GAME_OVER_NO_ENERGY ?
+                                "Out of magic energy! Play it again?" :
+                                game_over_cause == GAME_OVER_OVERLOADED ?
+                                "Magic spell hit Mc Duffin! Play it again?" :
+                                NULL);
+
+  SetTileCursorActive(FALSE);
+}
+
 void AddLaserEdge(int lx, int ly)
 {
   int clx = dSX + lx;
@@ -2512,10 +2536,7 @@ static void Explode_MM(int x, int y, int phase, int mode)
       Bang_MM(laser.start_edge.x, laser.start_edge.y);
       Store[x][y] = EL_EMPTY;
 
-      game_mm.game_over = TRUE;
-      game_mm.game_over_cause = GAME_OVER_BOMB;
-
-      SetTileCursorActive(FALSE);
+      GameOver_MM(GAME_OVER_DELAYED);
 
       laser.overloaded = FALSE;
     }
@@ -2523,7 +2544,7 @@ static void Explode_MM(int x, int y, int phase, int mode)
     {
       Store[x][y] = EL_EMPTY;
 
-      game.restart_game_message = "Bomb killed Mc Duffin! Play it again?";
+      GameOver_MM(GAME_OVER_BOMB);
     }
 
     Tile[x][y] = Store[x][y];
@@ -3174,6 +3195,10 @@ static void GameActions_MM_Ext(void)
     }
   }
 
+  // skip all following game actions if game is over
+  if (game_mm.game_over)
+    return;
+
   if (FrameReached(&energy_delay))
   {
     if (game_mm.energy_left > 0)
@@ -3186,12 +3211,7 @@ static void GameActions_MM_Ext(void)
     {
       FadeOutLaser(FALSE);
 
-      game_mm.game_over = TRUE;
-      game_mm.game_over_cause = GAME_OVER_NO_ENERGY;
-
-      SetTileCursorActive(FALSE);
-
-      game.restart_game_message = "Out of magic energy! Play it again?";
+      GameOver_MM(GAME_OVER_NO_ENERGY);
 
       return;
     }
@@ -3293,12 +3313,7 @@ static void GameActions_MM_Ext(void)
 
       FadeOutLaser(TRUE);
 
-      game_mm.game_over = TRUE;
-      game_mm.game_over_cause = GAME_OVER_OVERLOADED;
-
-      SetTileCursorActive(FALSE);
-
-      game.restart_game_message = "Magic spell hit Mc Duffin! Play it again?";
+      GameOver_MM(GAME_OVER_OVERLOADED);
 
       return;
     }