white space changes
[rocksndiamonds.git] / src / game_mm / mm_game.c
index 5cdc8ed3114712b6e97fd8f11d1ce9c22a8f8b21..496cc916756f878650ba455a8ce53623447b926b 100644 (file)
@@ -97,7 +97,6 @@ static void RaiseScoreElement_MM(int);
 static void RemoveMovingField_MM(int, int);
 static void InitMovingField_MM(int, int, int);
 static void ContinueMoving_MM(int, int);
-static void Moving2Blocked_MM(int, int, int *, int *);
 
 static void AddLaserEdge(int, int);
 static void ScanLaser(void);
@@ -364,7 +363,7 @@ static void DrawLaserLines(struct XY *points, int num_points, int mode)
   Pixel pixel_drawto = (mode == DL_LASER_ENABLED ? pen_ray     : pen_bg);
   Pixel pixel_buffer = (mode == DL_LASER_ENABLED ? WHITE_PIXEL : BLACK_PIXEL);
 
-  DrawLines(drawto, points, num_points, pixel_drawto);
+  DrawLines(drawto_mm, points, num_points, pixel_drawto);
 
   BEGIN_NO_HEADLESS
   {
@@ -644,8 +643,8 @@ void InitGameEngine_MM(void)
   BEGIN_NO_HEADLESS
   {
     // initialize laser bitmap to current playfield (screen) size
-    ReCreateBitmap(&laser_bitmap, drawto->width, drawto->height);
-    ClearRectangle(laser_bitmap, 0, 0, drawto->width, drawto->height);
+    ReCreateBitmap(&laser_bitmap, drawto_mm->width, drawto_mm->height);
+    ClearRectangle(laser_bitmap, 0, 0, drawto_mm->width, drawto_mm->height);
   }
   END_NO_HEADLESS
 
@@ -762,7 +761,7 @@ void InitGameActions_MM(void)
 
     DrawLevel_MM();
 
-    BackToFront();
+    BackToFront_MM();
 
 #ifdef DEBUG
     if (setup.quick_doors)
@@ -795,7 +794,7 @@ static void FadeOutLaser(void)
 
     DrawLaser(0, DL_LASER_ENABLED);
 
-    BackToFront();
+    BackToFront_MM();
     Delay_WithScreenUpdates(50);
   }
 
@@ -2567,7 +2566,7 @@ static void OpenGrayBall(int x, int y)
       DrawWalls_MM(x, y, Store[x][y]);
 
       // copy wall tile to spare bitmap for "melting" animation
-      BlitBitmap(drawto, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY,
+      BlitBitmap(drawto_mm, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY,
                 TILEX, TILEY, x * TILEX, y * TILEY);
 
       DrawElement_MM(x, y, EL_GRAY_BALL);
@@ -2600,7 +2599,7 @@ static void OpenGrayBall(int x, int y)
        getGraphicSource(graphic, 0, &bitmap, &gx, &gy);
       }
 
-      BlitBitmap(bitmap, drawto, gx + dx, gy + dy, 6, 6,
+      BlitBitmap(bitmap, drawto_mm, gx + dx, gy + dy, 6, 6,
                 cSX + x * TILEX + dx, cSY + y * TILEY + dy);
 
       laser.redraw = TRUE;
@@ -2653,7 +2652,7 @@ static void OpenEnvelope(int x, int y)
 
       ScanLaser();
 
-      ShowEnvelope_MM(nr);
+      ShowEnvelope(nr);
     }
   }
 }
@@ -2884,26 +2883,28 @@ static void TurnRound(int x, int y)
     int x, y;
   } move_xy[] =
   {
-    { 0, 0 },
-    {-1, 0 },
-    {+1, 0 },
-    { 0, 0 },
-    { 0, -1 },
-    { 0, 0 }, { 0, 0 }, { 0, 0 },
-    { 0, +1 }
+    {  0,  0 },
+    { -1,  0 },
+    { +1,  0 },
+    {  0,  0 },
+    {  0, -1 },
+    {  0,  0 }, { 0, 0 }, { 0, 0 },
+    {  0, +1 }
   };
   static struct
   {
     int left, right, back;
   } turn[] =
   {
-    { 0,       0,              0 },
+    { 0,       0,              0        },
     { MV_DOWN, MV_UP,          MV_RIGHT },
-    { MV_UP,   MV_DOWN,        MV_LEFT },
-    { 0,       0,              0 },
-    { MV_LEFT, MV_RIGHT,       MV_DOWN },
-    { 0,0,0 }, { 0,0,0 },      { 0,0,0 },
-    { MV_RIGHT,        MV_LEFT,        MV_UP }
+    { MV_UP,   MV_DOWN,        MV_LEFT  },
+    { 0,       0,              0        },
+    { MV_LEFT, MV_RIGHT,       MV_DOWN  },
+    { 0,       0,              0        },
+    { 0,       0,              0        },
+    { 0,       0,              0        },
+    { MV_RIGHT,        MV_LEFT,        MV_UP    }
   };
 
   int element = Tile[x][y];
@@ -2951,7 +2952,7 @@ static void StartMoving_MM(int x, int y)
 
     // now make next step
 
-    Moving2Blocked_MM(x, y, &newx, &newy);     // get next screen position
+    Moving2Blocked(x, y, &newx, &newy);        // get next screen position
 
     if (element == EL_PACMAN &&
        IN_LEV_FIELD(newx, newy) && IS_EATABLE4PACMAN(Tile[newx][newy]) &&
@@ -3088,29 +3089,25 @@ boolean ClickElement(int x, int y, int button)
   }
   else if (IS_MCDUFFIN(element))
   {
-    if (!laser.fuse_off)
-    {
-      DrawLaser(0, DL_LASER_DISABLED);
+    boolean has_laser = (x == laser.start_edge.x && y == laser.start_edge.y);
 
-      /*
-      BackToFront();
-      */
-    }
+    if (has_laser && !laser.fuse_off)
+      DrawLaser(0, DL_LASER_DISABLED);
 
     element = get_rotated_element(element, BUTTON_ROTATION(button));
-    laser.start_angle = get_element_angle(element);
-
-    InitLaser();
 
     Tile[x][y] = element;
     DrawField_MM(x, y);
 
-    /*
-    BackToFront();
-    */
+    if (has_laser)
+    {
+      laser.start_angle = get_element_angle(element);
 
-    if (!laser.fuse_off)
-      ScanLaser();
+      InitLaser();
+
+      if (!laser.fuse_off)
+       ScanLaser();
+    }
 
     element_clicked = TRUE;
   }
@@ -3750,7 +3747,7 @@ static void GameActions_MM_Ext(void)
 
       UpdateAndDisplayGameControlValues();
 
-      BackToFront();
+      BackToFront_MM();
     }
 
     Tile[ELX][ELY] = laser.dest_element = EL_FUEL_EMPTY;
@@ -3849,7 +3846,7 @@ static void MovePacMen(void)
     }
 
     DrawField_MM(nx, ny);
-    BackToFront();
+    BackToFront_MM();
 
     if (!laser.fuse_off)
     {
@@ -3890,35 +3887,6 @@ static void InitMovingField_MM(int x, int y, int direction)
     Tile[newx][newy] = EL_BLOCKED;
 }
 
-static void Moving2Blocked_MM(int x, int y, int *goes_to_x, int *goes_to_y)
-{
-  int direction = MovDir[x][y];
-  int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
-  int newy = y + (direction == MV_UP   ? -1 : direction == MV_DOWN  ? +1 : 0);
-
-  *goes_to_x = newx;
-  *goes_to_y = newy;
-}
-
-static void Blocked2Moving_MM(int x, int y,
-                             int *comes_from_x, int *comes_from_y)
-{
-  int oldx = x, oldy = y;
-  int direction = MovDir[x][y];
-
-  if (direction == MV_LEFT)
-    oldx++;
-  else if (direction == MV_RIGHT)
-    oldx--;
-  else if (direction == MV_UP)
-    oldy++;
-  else if (direction == MV_DOWN)
-    oldy--;
-
-  *comes_from_x = oldx;
-  *comes_from_y = oldy;
-}
-
 static int MovingOrBlocked2Element_MM(int x, int y)
 {
   int element = Tile[x][y];
@@ -3927,7 +3895,7 @@ static int MovingOrBlocked2Element_MM(int x, int y)
   {
     int oldx, oldy;
 
-    Blocked2Moving_MM(x, y, &oldx, &oldy);
+    Blocked2Moving(x, y, &oldx, &oldy);
 
     return Tile[oldx][oldy];
   }
@@ -3944,13 +3912,13 @@ static void RemoveMovingField_MM(int x, int y)
 
   if (IS_MOVING(x, y))
   {
-    Moving2Blocked_MM(x, y, &newx, &newy);
+    Moving2Blocked(x, y, &newx, &newy);
     if (Tile[newx][newy] != EL_BLOCKED)
       return;
   }
   else if (Tile[x][y] == EL_BLOCKED)
   {
-    Blocked2Moving_MM(x, y, &oldx, &oldy);
+    Blocked2Moving(x, y, &oldx, &oldy);
     if (!IS_MOVING(oldx, oldy))
       return;
   }