added levelset config flag to force using old game engine for BD replays
authorHolger Schemel <holger.schemel@virtion.de>
Mon, 9 Sep 2024 21:45:42 +0000 (23:45 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Mon, 9 Sep 2024 21:48:46 +0000 (23:48 +0200)
src/game_bd/bd_caveengine.c
src/game_bd/bd_gameplay.h
src/game_bd/import_bd.h
src/game_bd/main_bd.c
src/libgame/setup.c
src/libgame/system.h
src/tools.c

index 40a2016e37857bb9c9b1e55d4bc95ecc4c0f2018..cfe930c0174066c890bc7317907feb76a8ebed3b 100644 (file)
@@ -17,9 +17,6 @@
 #include "main_bd.h"
 
 
-// for compatibility with old game engine
-static boolean use_old_game_engine = TRUE;
-
 // for gravity and other routines.
 // these arrays contain the rotated directions.
 // ccw eighth: counter-clockwise, 1/8 turn (45 degrees)
@@ -119,7 +116,7 @@ void gd_cave_set_seconds_sound(GdCave *cave)
 // returns true if the element has a certain property
 static inline boolean has_property(int element, const int property)
 {
-  if (use_old_game_engine)
+  if (game_bd.game->use_old_engine)
     element = non_scanned_pair(element);
 
   return (gd_element_properties[element].properties & property) != 0;
index f54810bca97a6a4e42c1543070eb38b24b4733ca..e6471f8517dea2b544d23d4225463bbbe7a01bd7 100644 (file)
@@ -95,6 +95,8 @@ typedef struct _gd_game
 
   int replay_no_more_movements;
   boolean show_story;          // to remember that story for a particular cave was already shown.
+
+  boolean use_old_engine;      // for game engine compatibility with old replays
 } GdGame;
 
 typedef enum _gd_game_state
index 75e801c00d6115a2db6eef52eef2b01406da33fc..3623552d32f05de23d22fda265b3b411aab176ad 100644 (file)
@@ -40,5 +40,6 @@ byte *TapeCorrectAction_BD(byte *);
 boolean TapeIsPlaying_ReplayBD(void);
 
 boolean isLevelEditorFastStart(void);
+boolean useOldEngine_BD(void);
 
 #endif // IMPORT_BD_H
index 3b9678770c1a3b5d4b3f814b709dba4df9d71c68..ab122bfb34c683975485fcc3613eb86b40d9d6d1 100644 (file)
@@ -347,6 +347,8 @@ void InitGameEngine_BD(void)
   game_bd.game->itermax2[0] = game_bd.game->itermax;
   game_bd.game->itermax2[1] = game_bd.game->itermax;
 
+  game_bd.game->use_old_engine = useOldEngine_BD();
+
   game_bd.player_moving = FALSE;
   game_bd.player_snapping = FALSE;
 
index 42fd3380e7bf761fbf1298c2d80ea956d0106f81..7bfd6fa2562284e6d22c92b521305ee41902e54c 100644 (file)
@@ -2877,8 +2877,9 @@ SetupFileHash *loadSetupFileHash(char *filename)
 #define LEVELINFO_TOKEN_SKIP_LEVELS            33
 #define LEVELINFO_TOKEN_USE_EMC_TILES          34
 #define LEVELINFO_TOKEN_INFO_SCREENS_FROM_MAIN 35
+#define LEVELINFO_TOKEN_REPLAY_WITH_OLD_ENGINE 36
 
-#define NUM_LEVELINFO_TOKENS                   36
+#define NUM_LEVELINFO_TOKENS                   37
 
 static LevelDirTree ldi;
 
@@ -2920,7 +2921,8 @@ static struct TokenInfo levelinfo_tokens[] =
   { TYPE_BOOLEAN,      &ldi.time_limit,        "time_limit"            },
   { TYPE_BOOLEAN,      &ldi.skip_levels,       "skip_levels"           },
   { TYPE_BOOLEAN,      &ldi.use_emc_tiles,     "use_emc_tiles"         },
-  { TYPE_BOOLEAN,      &ldi.info_screens_from_main, "info_screens_from_main" }
+  { TYPE_BOOLEAN,      &ldi.info_screens_from_main, "info_screens_from_main" },
+  { TYPE_BOOLEAN,      &ldi.replay_with_old_engine, "replay_with_old_engine" },
 };
 
 static struct TokenInfo artworkinfo_tokens[] =
@@ -3030,6 +3032,7 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type)
 
     ti->use_emc_tiles = FALSE;
     ti->info_screens_from_main = FALSE;
+    ti->replay_with_old_engine = FALSE;
   }
 }
 
@@ -3117,6 +3120,7 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent)
 
     ti->use_emc_tiles = parent->use_emc_tiles;
     ti->info_screens_from_main = parent->info_screens_from_main;
+    ti->replay_with_old_engine = parent->replay_with_old_engine;
   }
 }
 
@@ -3191,6 +3195,7 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti)
 
   ti_copy->use_emc_tiles       = ti->use_emc_tiles;
   ti_copy->info_screens_from_main = ti->info_screens_from_main;
+  ti_copy->replay_with_old_engine = ti->replay_with_old_engine;
 
   ti_copy->color               = ti->color;
   ti_copy->class_desc          = getStringCopy(ti->class_desc);
index aa445738df5110aa4315cf3a9c6cc6a894a19984..a5ec4ec009ad87c425ea17e66699b6055ce1d727 100644 (file)
@@ -1658,6 +1658,7 @@ struct TreeInfo
 
   boolean use_emc_tiles;       // use (swapped) V5/V6 EMC tiles when set to "true"
   boolean info_screens_from_main; // can invoke info screens from main menu
+  boolean replay_with_old_engine; // use the old BD engine for playing BDCFF replays
 
   int color;                   // color to use on selection screen for this level
   char *class_desc;            // description of level series class
index 7d1201e014d6889e2ded0639b44a15f9153a3d9b..273cb6ae261fa2c587d228806f3e5f770b520d48 100644 (file)
@@ -10664,6 +10664,13 @@ int getBeltSwitchElementFromBeltNrAndBeltDir(int belt_nr, int belt_dir)
   return getBeltSwitchElementFromBeltNrAndBeltDirNr(belt_nr, belt_dir_nr);
 }
 
+boolean useOldEngine_BD(void)
+{
+  return (tape.playing &&
+          tape.bd_replay &&
+          leveldir_current->replay_with_old_engine);
+}
+
 boolean swapTiles_EM(boolean is_pre_emc_cave)
 {
   return is_pre_emc_cave && leveldir_current->use_emc_tiles;