From 0d0f19d8ab02ba3a1647851366db259489b99c7e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 2 Apr 2024 00:54:12 +0200 Subject: [PATCH] added also loading non-successful replay when loading native BD level --- src/files.c | 3 +++ src/game_bd/main_bd.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/files.c b/src/files.c index 157564d8..cf353286 100644 --- a/src/files.c +++ b/src/files.c @@ -4607,6 +4607,9 @@ static void CopyNativeTape_BD_to_RND(struct LevelInfo *level) } TapeHaltRecording(); + + if (!replay->success) + Warn("BD replay is marked as not successful"); } diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 6b3ba104..77af13a2 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -95,6 +95,30 @@ void setLevelInfoToDefaults_BD(void) setLevelInfoToDefaults_BD_Ext(0, 0); } +static List *getNativeLevelReplay_BD_Ext(List *item, boolean only_successful_replays) +{ + // look for replay that was recorded for the current difficulty level + while (item != NULL && + (item->data == NULL || + (((GdReplay *)item->data)->success == FALSE && only_successful_replays) || + ((GdReplay *)item->data)->level != native_bd_level.level_nr)) + item = item->next; + + return item; +} + +static List *getNativeLevelReplay_BD(List *replays) +{ + // 1st try: look for successful replay + List *item = getNativeLevelReplay_BD_Ext(replays, TRUE); + + if (item != NULL) + return item; + + // 2nd try: look for any replay + return getNativeLevelReplay_BD_Ext(replays, FALSE); +} + boolean LoadNativeLevel_BD(char *filename, int level_pos, boolean level_info_only) { static char *filename_loaded = NULL; @@ -137,16 +161,9 @@ boolean LoadNativeLevel_BD(char *filename, int level_pos, boolean level_info_onl // check if this cave has any replays if (native_bd_level.cave->replays != NULL) { - List *item = native_bd_level.cave->replays; - - // try to find replay that was recorded for this difficulty level - while (item != NULL && - (item->data == NULL || - ((GdReplay *)item->data)->success == FALSE || - ((GdReplay *)item->data)->level != native_bd_level.level_nr)) - item = item->next; + List *item = getNativeLevelReplay_BD(native_bd_level.cave->replays); - // matching replay found + // check if any matching replay was found if (item != NULL) native_bd_level.replay = (GdReplay *)item->data; } -- 2.34.1