From 4cc304453b04480c43e9a4083dd4273b5fd1357e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 9 Sep 2024 23:45:42 +0200 Subject: [PATCH] added levelset config flag to force using old game engine for BD replays --- src/game_bd/bd_caveengine.c | 5 +---- src/game_bd/bd_gameplay.h | 2 ++ src/game_bd/import_bd.h | 1 + src/game_bd/main_bd.c | 2 ++ src/libgame/setup.c | 9 +++++++-- src/libgame/system.h | 1 + src/tools.c | 7 +++++++ 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 40a2016e..cfe930c0 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -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; diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index f54810bc..e6471f85 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -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 diff --git a/src/game_bd/import_bd.h b/src/game_bd/import_bd.h index 75e801c0..3623552d 100644 --- a/src/game_bd/import_bd.h +++ b/src/game_bd/import_bd.h @@ -40,5 +40,6 @@ byte *TapeCorrectAction_BD(byte *); boolean TapeIsPlaying_ReplayBD(void); boolean isLevelEditorFastStart(void); +boolean useOldEngine_BD(void); #endif // IMPORT_BD_H diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 3b967877..ab122bfb 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -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; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 42fd3380..7bfd6fa2 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -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); diff --git a/src/libgame/system.h b/src/libgame/system.h index aa445738..a5ec4ec0 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -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 diff --git a/src/tools.c b/src/tools.c index 7d1201e0..273cb6ae 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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; -- 2.34.1