added Deflektor style fixed mirror game elements to MM engine
[rocksndiamonds.git] / src / game_mm / mm_game.c
index c89a900830fa5f97adcf6228d5bd3982645a6e9c..be1bfad64051591d5fc725f781c1064269ef04b6 100644 (file)
@@ -139,11 +139,10 @@ static DelayCounter overload_delay = { 0 };
 #define MM_MASK_GRID_2         5
 #define MM_MASK_GRID_3         6
 #define MM_MASK_GRID_4         7
-#define MM_MASK_GRID_CLOSED    8
-#define MM_MASK_RECTANGLE      9
-#define MM_MASK_CIRCLE         10
+#define MM_MASK_RECTANGLE      8
+#define MM_MASK_CIRCLE         9
 
-#define NUM_MM_MASKS           11
+#define NUM_MM_MASKS           10
 
 // element masks for scanning pixels of MM elements
 static const char mm_masks[NUM_MM_MASKS][16][16 + 1] =
@@ -292,24 +291,6 @@ static const char mm_masks[NUM_MM_MASKS][16][16 + 1] =
     "    XXX  XXXX   ",
     "     XX  XXXXX  ",
   },
-  {
-    " XXXXXX  XXXXXX ",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    " XXXXXXXXXXXXXX ",
-    " XXXXXXXXXXXXXX ",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    "XXXXXXXXXXXXXXXX",
-    " XXXXXX  XXXXXX ",
-  },
   {
     "XXXXXXXXXXXXXXXX",
     "XXXXXXXXXXXXXXXX",
@@ -850,6 +831,7 @@ 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);
 
+  // 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)
   {
@@ -904,7 +886,7 @@ static int getMaskFromElement(int element)
   else if (IS_GRID(element))
     return MM_MASK_GRID_1 + get_element_phase(element);
   else if (IS_DF_GRID(element))
-    return MM_MASK_GRID_CLOSED;
+    return MM_MASK_RECTANGLE;
   else if (IS_RECTANGLE(element))
     return MM_MASK_RECTANGLE;
   else
@@ -989,6 +971,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 +1073,21 @@ static void ScanLaser(void)
 
     if (!IN_LEV_FIELD(ELX, ELY))
     {
+      // laser next step position
+      int x = cSX + LX + XS;
+      int y = cSY + LY + YS;
+
+      // check if next step of laser is still inside visible playfield area
+      if (x >= REAL_SX && x < REAL_SX + FULL_SXSIZE &&
+         y >= REAL_SY && y < REAL_SY + FULL_SYSIZE)
+      {
+       // go on with another step
+       LX += XS;
+       LY += YS;
+
+       continue;
+      }
+
       element = EL_EMPTY;
       laser.dest_element = element;
 
@@ -1694,6 +1692,7 @@ static boolean HitElement(int element, int hit_mask)
       IS_POLAR_CROSS(element) ||
       IS_DF_MIRROR(element) ||
       IS_DF_MIRROR_AUTO(element) ||
+      IS_DF_MIRROR_FIXED(element) ||
       element == EL_PRISM ||
       element == EL_REFRACTOR)
   {
@@ -1712,7 +1711,8 @@ static boolean HitElement(int element, int hit_mask)
     if (IS_MIRROR(element) ||
        IS_MIRROR_FIXED(element) ||
        IS_DF_MIRROR(element) ||
-       IS_DF_MIRROR_AUTO(element))
+       IS_DF_MIRROR_AUTO(element) ||
+       IS_DF_MIRROR_FIXED(element))
       laser.current_angle = get_mirrored_angle(laser.current_angle,
                                               get_element_angle(element));