fixed handling laser when clicking on one of several McDuffins in MM engine
authorHolger Schemel <info@artsoft.org>
Fri, 31 Mar 2023 14:09:18 +0000 (16:09 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 31 Mar 2023 14:09:18 +0000 (16:09 +0200)
src/game_mm/mm_game.c

index c5cfa1d562c738c32adbd5c5d6ec84cdc8d8c61b..6162d7a0d16fa9f767d4a2fdd218326ed26a8a9d 100644 (file)
@@ -3088,29 +3088,25 @@ boolean ClickElement(int x, int y, int button)
   }
   else if (IS_MCDUFFIN(element))
   {
-    if (!laser.fuse_off)
-    {
-      DrawLaser(0, DL_LASER_DISABLED);
+    boolean has_laser = (x == laser.start_edge.x && y == laser.start_edge.y);
 
-      /*
-      BackToFront();
-      */
-    }
+    if (has_laser && !laser.fuse_off)
+      DrawLaser(0, DL_LASER_DISABLED);
 
     element = get_rotated_element(element, BUTTON_ROTATION(button));
-    laser.start_angle = get_element_angle(element);
-
-    InitLaser();
 
     Tile[x][y] = element;
     DrawField_MM(x, y);
 
-    /*
-    BackToFront();
-    */
+    if (has_laser)
+    {
+      laser.start_angle = get_element_angle(element);
 
-    if (!laser.fuse_off)
-      ScanLaser();
+      InitLaser();
+
+      if (!laser.fuse_off)
+       ScanLaser();
+    }
 
     element_clicked = TRUE;
   }