fixed scanning laser outside level, but inside visible playfield area
[rocksndiamonds.git] / src / game_mm / mm_game.c
index ea6faa9527b662366f5dc027f776f994729d3a43..09fa1d04a5a58fa162d416b330fc0d96f6b4f422 100644 (file)
@@ -847,11 +847,12 @@ static void GameOver_MM(int game_over_cause)
 
 static void AddLaserEdge(int lx, int ly)
 {
-  int sxsize = MAX(SXSIZE, lev_fieldx * TILEX);
-  int sysize = MAX(SYSIZE, lev_fieldy * TILEY);
+  int full_sxsize = MAX(FULL_SXSIZE, lev_fieldx * TILEX);
+  int full_sysize = MAX(FULL_SYSIZE, lev_fieldy * TILEY);
 
-  if (dSX + lx < -2 || dSX + lx >= sxsize + 2 ||
-      dSY + ly < -2 || dSY + ly >= sysize + 2)
+  // check if laser is still inside visible playfield area (or inside level)
+  if (cSX + lx < REAL_SX || cSX + lx >= REAL_SX + full_sxsize ||
+      cSY + ly < REAL_SY || cSY + ly >= REAL_SY + full_sysize)
   {
     Warn("AddLaserEdge: out of bounds: %d, %d", lx, ly);
 
@@ -989,6 +990,7 @@ static int ScanPixel(void)
       }
       else
       {
+       // check if laser is still inside visible playfield area
        pixel = (cSX + px < REAL_SX || cSX + px >= REAL_SX + FULL_SXSIZE ||
                 cSY + py < REAL_SY || cSY + py >= REAL_SY + FULL_SYSIZE);
       }
@@ -1090,6 +1092,17 @@ static void ScanLaser(void)
 
     if (!IN_LEV_FIELD(ELX, ELY))
     {
+      // check if laser is still inside visible playfield area
+      if (cSX + LX >= REAL_SX && cSX + LX < REAL_SX + FULL_SXSIZE &&
+         cSY + LY >= REAL_SY && cSY + LY < REAL_SY + FULL_SYSIZE)
+      {
+       // go on with another step
+       LX += XS;
+       LY += YS;
+
+       continue;
+      }
+
       element = EL_EMPTY;
       laser.dest_element = element;