added level editor option for buggy BD style conveyor belts
authorHolger Schemel <holger.schemel@virtion.de>
Tue, 5 Nov 2024 18:05:34 +0000 (19:05 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Tue, 5 Nov 2024 16:14:35 +0000 (17:14 +0100)
This makes the change from the last commit optional in the level
editor, deactivating it for existing levels in GDash formats (and
therefore also replays), so neither existing levels (caves) nor tapes
(replays) will be broken anymore by that change. For newly created
levels in R'n'D format, however, this change will be activated by
default, using the new, fixed conveyor belt behavior.

src/editor.c
src/files.c
src/game_bd/bd_cave.h
src/game_bd/bd_cavedb.c
src/game_bd/bd_caveengine.c
src/main.h

index 332abb54b2016cb63143b23aab23a5465da121e2..97e77f6a3fd39b73c5211e0e825a4e0f24ff1ad0 100644 (file)
@@ -867,6 +867,7 @@ enum
   GADGET_ID_BD_REPLICATORS_ACTIVE,
   GADGET_ID_BD_CONVEYOR_BELTS_ACTIVE,
   GADGET_ID_BD_CONVEYOR_BELTS_CHANGED,
+  GADGET_ID_BD_CONVEYOR_BELTS_BUGGY,
   GADGET_ID_BD_WATER_CANNOT_FLOW_DOWN,
   GADGET_ID_BD_HAMMER_WALLS_REAPPEAR,
   GADGET_ID_BD_INFINITE_ROCKETS,
@@ -1268,6 +1269,7 @@ enum
   ED_CHECKBUTTON_ID_BD_REPLICATORS_ACTIVE,
   ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_ACTIVE,
   ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_CHANGED,
+  ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_BUGGY,
   ED_CHECKBUTTON_ID_BD_WATER_CANNOT_FLOW_DOWN,
   ED_CHECKBUTTON_ID_BD_HAMMER_WALLS_REAPPEAR,
   ED_CHECKBUTTON_ID_BD_INFINITE_ROCKETS,
@@ -4396,6 +4398,14 @@ static struct
     NULL, NULL,
     "Change direction",                                "Switch conveyor belt direction"
   },
+  {
+    ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_BUGGY,
+    ED_ELEMENT_SETTINGS_XPOS(0),               ED_ELEMENT_SETTINGS_YPOS(2),
+    GADGET_ID_BD_CONVEYOR_BELTS_BUGGY,         GADGET_ID_NONE,
+    &level.bd_conveyor_belts_buggy,
+    NULL, NULL,
+    "Use buggy conveyor belts",                        "Bumpy pushing rocks on belt from left"
+  },
   {
     ED_CHECKBUTTON_ID_BD_WATER_CANNOT_FLOW_DOWN,
     ED_ELEMENT_SETTINGS_XPOS(0),               ED_ELEMENT_SETTINGS_YPOS(0),
@@ -13167,6 +13177,7 @@ static void DrawPropertiesConfig(void)
   {
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_ACTIVE);
     MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_CHANGED);
+    MapCheckbuttonGadget(ED_CHECKBUTTON_ID_BD_CONVEYOR_BELTS_BUGGY);
   }
 
   if (properties_element == EL_BDX_WATER)
index 886be93d62d0b01c5fc47dfc6edb1ae5b6856b47..e73fe2385bd5ccb2fd063e3c9a8f57d0d70c32c0 100644 (file)
@@ -987,6 +987,11 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
     &li.bd_conveyor_belts_changed,     FALSE
   },
+  {
+    EL_BDX_CONVEYOR_LEFT,              -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(3),
+    &li.bd_conveyor_belts_buggy,       FALSE
+  },
 
   {
     EL_BDX_WATER,                      -1,
@@ -4427,6 +4432,7 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level)
 
   cave->conveyor_belts_active          = level->bd_conveyor_belts_active;
   cave->conveyor_belts_direction_changed= level->bd_conveyor_belts_changed;
+  cave->conveyor_belts_buggy           = level->bd_conveyor_belts_buggy;
 
   cave->water_does_not_flow_down       = level->bd_water_cannot_flow_down;
 
@@ -4614,6 +4620,7 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level)
 
   level->bd_conveyor_belts_active      = cave->conveyor_belts_active;
   level->bd_conveyor_belts_changed     = cave->conveyor_belts_direction_changed;
+  level->bd_conveyor_belts_buggy       = cave->conveyor_belts_buggy;
 
   level->bd_water_cannot_flow_down     = cave->water_does_not_flow_down;
 
index cc412d003349263de56ee6dabcca272b8c4fbe9a..3c3bc74dc6bc4896602b5872dbc22d4df14492ba 100644 (file)
@@ -496,6 +496,7 @@ typedef struct _gd_cave
 
   boolean conveyor_belts_active;
   boolean conveyor_belts_direction_changed;
+  boolean conveyor_belts_buggy;                // use old, buggy conveyor belt behavior
 
   // effects
   GdElement explosion_effect;           // explosion converts to this element after its last stage.
index 263809c1b4f72602219cefbcf9baa6c87180c2de..c1b5cb93be8287c78937518803120de04af24c13 100644 (file)
@@ -2720,6 +2720,11 @@ const GdStructDescriptor gd_cave_properties[] =
     N_("Direction changed"), CAVE_OFFSET(conveyor_belts_direction_changed), 1,
     N_("If the conveyor belts' movement is changed, ie. they are running in the opposite direction. As you can freely use left and right going versions of the conveyor belt in a cave, it is not recommended to change this setting, rather you should select the correct one from the element box when drawing.")
   },
+  {
+    "ConveyorBelt.buggy", GD_TYPE_BOOLEAN, 0,
+    N_("Buggy conveyor belt"), CAVE_OFFSET(conveyor_belts_buggy), 1,
+    N_("If it is true, pushing an object onto an active (going right) conveyor belt from the left side results in that object immediately jumping another tile to the right before moving further on the conveyor belt. Otherwise, the conveyor belt works as expected, and objects being pushed onto it from the left side move normally.")
+  },
 
   // water
   {
@@ -3215,6 +3220,7 @@ GdPropertyDefault gd_cave_defaults_gdash[] =
   // conveyor belt
   { CAVE_OFFSET(conveyor_belts_active),                                TRUE                            },
   { CAVE_OFFSET(conveyor_belts_direction_changed),             FALSE                           },
+  { CAVE_OFFSET(conveyor_belts_buggy),                         TRUE                            },
 
   // slime
   { CAVE_OFFSET(slime_predictable),                            TRUE                            },
index 107441d51798de6c05b536465e00aae47b16f238..b4c9219efb27a15610e1af579bd0872a52a70e6f 100644 (file)
@@ -3680,8 +3680,9 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire,
                 int old_x = getx(cave, raw_x, raw_y);
                 int old_y = gety(cave, raw_x, raw_y);
 
-                // only move game element if not already moving in that direction
-                if (game_bd.game->dir_buffer_to[old_y][old_x] != move_dir)
+                // only move game element if not already moving in that direction (or if buggy)
+                if (game_bd.game->dir_buffer_to[old_y][old_x] != move_dir ||
+                    cave->conveyor_belts_buggy)
                 {
                   store_dir(cave, x, y, GD_MV_UP, O_SPACE);        // place a space ...
                   store_dir(cave, old_x, old_y, move_dir, tile);   // and move element.
@@ -3714,8 +3715,9 @@ void gd_cave_iterate(GdCave *cave, GdDirection player_move, boolean player_fire,
                 int old_x = getx(cave, raw_x, raw_y);
                 int old_y = gety(cave, raw_x, raw_y);
 
-                // only move game element if not already moving in that direction
-                if (game_bd.game->dir_buffer_to[old_y][old_x] != move_dir)
+                // only move game element if not already moving in that direction (or if buggy)
+                if (game_bd.game->dir_buffer_to[old_y][old_x] != move_dir ||
+                    cave->conveyor_belts_buggy)
                 {
                   store_dir(cave, x, y, GD_MV_DOWN, O_SPACE);      // place a space ...
                   store_dir(cave, old_x, old_y, move_dir, tile);   // and move element.
index b4b5eeaf4ab354bcd8afe968c882e749f3d186b6..e09fd3044f135dbdee599d09733975578e60f723 100644 (file)
@@ -3876,6 +3876,7 @@ struct LevelInfo
   int bd_replicator_create_delay;      // BD replicator delay between replications (in BD frames)
   boolean bd_conveyor_belts_active;    // BD conveyor belts start in active state if enabled
   boolean bd_conveyor_belts_changed;   // BD conveyor belts direction is changed if enabled
+  boolean bd_conveyor_belts_buggy;     // BD conveyor belts setting to implement buggy behaviour
   boolean bd_water_cannot_flow_down;   // BD water does not flow downwards if enabled
   int bd_nut_content;                  // BD nut contains the specified game element
   int bd_hammer_walls_break_delay;     // BD hammer time for breaking walls (in BD frames)