code cleanup (MM engine)
[rocksndiamonds.git] / src / game_mm / mm_game.c
index 6b8d02aeba340cbae2f6c72d414747dc6904344f..4f4af5f87c9aac8c71acb7a51ab4ffd0803cf6e6 100644 (file)
@@ -349,6 +349,10 @@ void InitGameEngine_MM()
 #endif
 
   DrawLevel_MM();
+}
+
+void InitGameEngine_MM_AfterFadingIn()
+{
   InitCycleElements();
   InitLaser();
 
@@ -503,36 +507,34 @@ int ScanPixel()
 
     for (i=0; i<4; i++)
     {
+      int px = LX + (i % 2) * 2;
+      int py = LY + (i / 2) * 2;
+      int dx = px % TILEX;
+      int dy = py % TILEY;
+      int lx = (px + TILEX) / TILEX - 1;  /* ...+TILEX...-1 to get correct */
+      int ly = (py + TILEY) / TILEY - 1;  /* negative values!              */
       Pixel pixel;
-      int px, py, lx, ly;
-
-      px = SX + LX + (i % 2) * 2;
-      py = SY + LY + (i / 2) * 2;
-      lx = (px - SX + TILEX) / TILEX - 1;  /* ...+TILEX...-1 to get correct */
-      ly = (py - SY + TILEY) / TILEY - 1;  /* negative values!              */
 
       if (IN_LEV_FIELD(lx, ly))
       {
        int element = Feld[lx][ly];
 
        if (element == EL_EMPTY || element == EL_EXPLODING_TRANSP)
+       {
          pixel = 0;
+       }
        else if (IS_WALL(element) || IS_WALL_CHANGING(element))
        {
-         int pos =
-           ((py - SY - ly * TILEY) / MINI_TILEX) * 2 +
-           (px - SX - lx * TILEX) / MINI_TILEY;
+         int pos = dy / MINI_TILEY * 2 + dx / MINI_TILEX;
 
          pixel = ((element & (1 << pos)) ? 1 : 0);
        }
        else
        {
          int graphic_mask = getMaskFromElement(element);
-         int mask_x, mask_y;
-         int dx = px - lx * TILEX;
-         int dy = py - ly * TILEY;
          Bitmap *bitmap;
          int src_x, src_y;
+         int mask_x, mask_y;
 
          getGraphicSource(graphic_mask, 0, &bitmap, &src_x, &src_y);
 
@@ -544,11 +546,8 @@ int ScanPixel()
       }
       else
       {
-       if (px < REAL_SX || px >= REAL_SX + FULL_SXSIZE ||
-           py < REAL_SY || py >= REAL_SY + FULL_SYSIZE)
-         pixel = 1;
-       else
-         pixel = 0;
+       pixel = (SX + px < REAL_SX || SX + px >= REAL_SX + FULL_SXSIZE ||
+                SY + py < REAL_SY || SY + py >= REAL_SY + FULL_SYSIZE);
       }
 
       if ((Sign[laser.current_angle] & (1 << i)) && pixel)
@@ -2131,6 +2130,7 @@ static void Explode_MM(int x, int y, int phase, int mode)
       Store[x][y] = EL_EMPTY;
     }
 
+    Feld[x][y] = Store[x][y];
     Store[x][y] = Store2[x][y] = 0;
     MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0;
     InitField(x, y, FALSE);
@@ -2680,7 +2680,7 @@ void ColorCycling(void)
   }
 }
 
-void GameActions_MM(byte action[MAX_PLAYERS], boolean warp_mode)
+static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode)
 {
   static unsigned int action_delay = 0;
   static unsigned int pacman_delay = 0;
@@ -3356,6 +3356,14 @@ void GameActions_MM(byte action[MAX_PLAYERS], boolean warp_mode)
   return;
 }
 
+void GameActions_MM(byte action[MAX_PLAYERS], boolean warp_mode)
+{
+  if (!button_status)
+    ClickElement(0, 0, MB_NOT_PRESSED);
+
+  GameActions_MM_Ext(action, warp_mode);
+}
+
 void MovePacMen()
 {
   static int p = -1;