From de51b1c5760ccc1e035e0fe1bf2a28e640fe300b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 6 Jan 2025 20:16:42 +0100 Subject: [PATCH] fixed undefined caveset data when using non-native BD engine levels --- src/game_bd/main_bd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index b23cbe98..5156b392 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -56,11 +56,18 @@ void bd_close_all(void) void setLevelInfoToDefaults_BD_Ext(int width, int height) { + static GdCavesetData *caveset = NULL; // used if no native cave loaded GdCave *cave = native_bd_level.cave; + if (caveset != NULL) + gd_caveset_data_free(caveset); + if (cave != NULL) gd_cave_free(cave); + // get empty caveset, using default values + caveset = gd_caveset_data_new(); + // get empty cave, using default values cave = gd_cave_new(); @@ -81,7 +88,7 @@ void setLevelInfoToDefaults_BD_Ext(int width, int height) cave->selectable = TRUE; cave->intermission = FALSE; - native_bd_level.caveset = NULL; + native_bd_level.caveset = caveset; native_bd_level.cave = cave; native_bd_level.replay = NULL; @@ -157,6 +164,7 @@ boolean LoadNativeLevel_BD(char *filename, int level_pos, boolean level_info_onl // set better initial cave speed (to set better native replay tape length) set_initial_cave_speed(native_bd_level.cave); + // caveset data for native levels managed separately -- do not free it! native_bd_level.caveset = gd_caveset_data; native_bd_level.loaded_from_caveset = TRUE; -- 2.34.1