fixed advancing laser position on slopes from non-center position
[rocksndiamonds.git] / src / game_mm / mm_game.c
index 6ff1d678b886f0d648c66116da20de848fdce39f..b21f119727e415b455afcdf9f477d23220c53949 100644 (file)
@@ -837,6 +837,9 @@ void InitGameActions_MM(void)
     AdvanceFrameCounter();
     AdvanceGfxFrame();
 
+    if (PendingEscapeKeyEvent())
+      continue;
+
 #ifdef DEBUG
     if (setup.quick_doors)
       continue;
@@ -1898,13 +1901,27 @@ static boolean HitElement(int element, int hit_mask)
     XS = 2 * Step[laser.current_angle].x;
     YS = 2 * Step[laser.current_angle].y;
 
-    if (!IS_22_5_ANGLE(laser.current_angle))   // 90° or 45° angle
-      step_size = 8;
-    else
-      step_size = 4;
+    if (through_center)
+    {
+      // start from center position for all game elements but slope
+      if (!IS_22_5_ANGLE(laser.current_angle)) // 90° or 45° angle
+       step_size = 8;
+      else
+       step_size = 4;
 
-    LX += step_size * XS;
-    LY += step_size * YS;
+      LX += step_size * XS;
+      LY += step_size * YS;
+    }
+    else
+    {
+      // advance laser position until reaching the next tile (slopes)
+      while (LX / TILEX == ELX && (LX + 2) / TILEX == ELX &&
+            LY / TILEY == ELY && (LY + 2) / TILEY == ELY)
+      {
+       LX += XS;
+       LY += YS;
+      }
+    }
 
     // draw sparkles on mirror
     if ((IS_MIRROR(element) ||
@@ -1978,7 +1995,7 @@ static boolean HitElement(int element, int hit_mask)
          {
            int pos = getMaskFromElement(element_side);
 
-           if (mm_masks[pos][dx / 2][dx / 2] == 'X')
+           if (mm_masks[pos][dx / 2][dy / 2] == 'X')
              laser.overloaded = TRUE;
          }
        }