fixed scanning laser outside level, but inside visible playfield area
[rocksndiamonds.git] / src / game_mm / mm_game.c
index 49200caade5d438a5e50782e2a5517d9fa9fe5c2..09fa1d04a5a58fa162d416b330fc0d96f6b4f422 100644 (file)
@@ -850,8 +850,9 @@ static void AddLaserEdge(int lx, int ly)
   int full_sxsize = MAX(FULL_SXSIZE, lev_fieldx * TILEX);
   int full_sysize = MAX(FULL_SYSIZE, lev_fieldy * TILEY);
 
-  if (SX + dSX + lx < REAL_SX || SX + dSX + lx >= REAL_SX + full_sxsize ||
-      SY + dSY + ly < REAL_SY || SY + dSY + ly >= REAL_SY + full_sysize)
+  // 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;