fixed line style drawing with empty space over MM style walls in editor
[rocksndiamonds.git] / src / tools.c
index bfaad2acdd577f844c51428332857eed3b0a9b30..6b817e85cf59cdbc8e012ea189b6c6c1249f8e19 100644 (file)
@@ -1377,9 +1377,10 @@ void SetBorderElement()
   }
 }
 
-void FloodFillLevel(int from_x, int from_y, int fill_element,
-                   short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
-                   int max_fieldx, int max_fieldy)
+void FloodFillLevelExt(int from_x, int from_y, int fill_element,
+                      int max_array_fieldx, int max_array_fieldy,
+                      short field[max_array_fieldx][max_array_fieldy],
+                      int max_fieldx, int max_fieldy)
 {
   int i,x,y;
   int old_element;
@@ -1404,12 +1405,22 @@ void FloodFillLevel(int from_x, int from_y, int fill_element,
     y = from_y + check[i][1];
 
     if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element)
-      FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy);
+      FloodFillLevelExt(x, y, fill_element, max_array_fieldx, max_array_fieldy,
+                       field, max_fieldx, max_fieldy);
   }
 
   safety--;
 }
 
+void FloodFillLevel(int from_x, int from_y, int fill_element,
+                   short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
+                   int max_fieldx, int max_fieldy)
+{
+  FloodFillLevelExt(from_x, from_y, fill_element,
+                   MAX_LEV_FIELDX, MAX_LEV_FIELDY, field,
+                   max_fieldx, max_fieldy);
+}
+
 void SetRandomAnimationValue(int x, int y)
 {
   gfx.anim_random_frame = GfxRandom[x][y];
@@ -2475,12 +2486,14 @@ void DrawLevelField(int x, int y)
 }
 
 static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize,
-                               int (*el2img_function)(int), boolean masked)
+                               int (*el2img_function)(int), boolean masked,
+                               int element_bits_draw)
 {
   int element_base = map_mm_wall_element(element);
   int element_bits = (IS_DF_WALL(element) ?
                      element - EL_DF_WALL_START :
-                     element - EL_MM_WALL_START) & 0x000f;
+                     IS_MM_WALL(element) ?
+                     element - EL_MM_WALL_START : EL_EMPTY) & 0x000f;
   int graphic = el2img_function(element_base);
   int tilesize_draw = tilesize / 2;
   Bitmap *src_bitmap;
@@ -2494,6 +2507,9 @@ static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize,
     int dst_draw_x = dst_x + (i % 2) * tilesize_draw;
     int dst_draw_y = dst_y + (i / 2) * tilesize_draw;
 
+    if (!(element_bits_draw & (1 << i)))
+      continue;
+
     if (element_bits & (1 << i))
     {
       if (masked)
@@ -2512,10 +2528,18 @@ static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize,
   }
 }
 
+void DrawSizedWallParts_MM(int x, int y, int element, int tilesize,
+                          boolean masked, int element_bits_draw)
+{
+  DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize,
+                     element, tilesize, el2edimg, masked, element_bits_draw);
+}
+
 void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize,
                      int (*el2img_function)(int))
 {
-  DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE);
+  DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE,
+                     0x000f);
 }
 
 void DrawSizedElementExt(int x, int y, int element, int tilesize,
@@ -2524,7 +2548,7 @@ void DrawSizedElementExt(int x, int y, int element, int tilesize,
   if (IS_MM_WALL(element))
   {
     DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize,
-                       element, tilesize, el2edimg, masked);
+                       element, tilesize, el2edimg, masked, 0x000f);
   }
   else
   {
@@ -3962,7 +3986,9 @@ static int RequestHandleEvents(unsigned int req_state)
   {
     if (level_solved)
     {
-      SetDrawtoField(DRAW_TO_FIELDBUFFER);
+      /* the MM game engine does not use a special (scrollable) field buffer */
+      if (level.game_engine_type != GAME_ENGINE_TYPE_MM)
+       SetDrawtoField(DRAW_TO_FIELDBUFFER);
 
       HandleGameActions();
 
@@ -7383,6 +7409,27 @@ int map_element_MM_to_RND(int element_mm)
          EL_EMPTY);
 }
 
+int map_action_MM_to_RND(int action_mm)
+{
+  /* all MM actions are defined to exactly match their RND counterparts */
+  return action_mm;
+}
+
+int map_sound_MM_to_RND(int sound_mm)
+{
+  switch (sound_mm)
+  {
+    case SND_MM_GAME_LEVELTIME_CHARGING:
+      return SND_GAME_LEVELTIME_CHARGING;
+
+    case SND_MM_GAME_HEALTH_CHARGING:
+      return SND_GAME_HEALTH_CHARGING;
+
+    default:
+      return SND_UNDEFINED;
+  }
+}
+
 int map_mm_wall_element(int element)
 {
   return (element >= EL_MM_STEEL_WALL_START &&
@@ -8903,6 +8950,8 @@ void ResetFontStatus()
 
 void ChangeViewportPropertiesIfNeeded()
 {
+  boolean use_mini_tilesize = (level.game_engine_type == GAME_ENGINE_TYPE_MM ?
+                              FALSE : setup.small_game_graphics);
   int gfx_game_mode = game_status;
   int gfx_game_mode2 = (game_status == GAME_MODE_EDITOR ? GAME_MODE_DEFAULT :
                        game_status);
@@ -8934,9 +8983,7 @@ void ChangeViewportPropertiesIfNeeded()
   int new_ey           = vp_door_3->y;
   int new_exsize       = vp_door_3->width;
   int new_eysize       = vp_door_3->height;
-  int new_tilesize_var =
-    (setup.small_game_graphics ? MINI_TILESIZE : game.tile_size);
-
+  int new_tilesize_var = (use_mini_tilesize ? MINI_TILESIZE : game.tile_size);
   int tilesize = (gfx_game_mode == GAME_MODE_PLAYING ? new_tilesize_var :
                  gfx_game_mode == GAME_MODE_EDITOR ? MINI_TILESIZE : TILESIZE);
   int new_scr_fieldx = new_sxsize / tilesize;