From: Holger Schemel Date: Mon, 1 Apr 2024 22:54:12 +0000 (+0200) Subject: added also loading non-successful replay when loading native BD level X-Git-Tag: 4.4.0.0-test-1~116 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0d0f19d8ab02ba3a1647851366db259489b99c7e;p=rocksndiamonds.git added also loading non-successful replay when loading native BD level --- 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; }