From: Holger Schemel Date: Tue, 7 May 2024 21:58:11 +0000 (+0200) Subject: added functions to check if native BD cave or caveset has levels X-Git-Tag: 4.4.0.0-test-1~6 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9136de29eeefa86ceff295c76baf6eefb93b1a21;p=rocksndiamonds.git added functions to check if native BD cave or caveset has levels --- diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index d946bac4..6a22a637 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -1678,3 +1678,60 @@ unsigned int gd_cave_adler_checksum(GdCave *cave) gd_cave_adler_checksum_more(cave, &a, &b); return (b << 16) + a; } + +boolean gd_cave_has_levels(GdCave *cave) +{ + GdCave c = *cave; + int *cave_level_value[] = + { + c.level_diamonds, + c.level_speed, + c.level_ckdelay, + c.level_time, + c.level_magic_wall_time, + c.level_amoeba_time, + c.level_amoeba_threshold, + c.level_amoeba_2_time, + c.level_amoeba_2_threshold, + c.level_slime_permeability, + c.level_slime_permeability_c64, + c.level_slime_seed_c64, + c.level_hatching_delay_frame, + c.level_hatching_delay_time, + c.level_bonus_time, + c.level_penalty_time, + + NULL + }; + int i, j; + + for (i = 0; cave_level_value[i] != NULL; i++) + for (j = 1; j < 5; j++) + if (cave_level_value[i][j] != cave_level_value[i][0]) + return TRUE; + + for (j = 1; j < 5; j++) + if (cave->level_rand[j] != j && + cave->level_rand[j - 1] != j - 1 && + cave->level_rand[j] != cave->level_rand[0]) + return TRUE; + + for (j = 1; j < 5; j++) + if (cave->level_timevalue[j] != j + 1 && + cave->level_timevalue[j - 1] != j && + cave->level_timevalue[j] != cave->level_timevalue[0]) + return TRUE; + + return FALSE; +} + +boolean gd_caveset_has_levels(void) +{ + List *iter; + + for (iter = gd_caveset; iter != NULL; iter = iter->next) + if (gd_cave_has_levels((GdCave *)iter->data)) + return TRUE; + + return FALSE; +} diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index aea976e8..1a85776a 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -721,4 +721,7 @@ void gd_replay_store_movement(GdReplay *replay, GdDirection player_move, boolean unsigned int gd_cave_adler_checksum(GdCave *cave); void gd_cave_adler_checksum_more(GdCave *cave, unsigned int *a, unsigned int *b); +boolean gd_cave_has_levels(GdCave *cave); +boolean gd_caveset_has_levels(void); + #endif // BD_CAVE_H diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 25eb0631..f69f440e 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -183,7 +183,9 @@ boolean SaveNativeLevel_BD(char *filename) void DumpLevelset_BD(void) { - Print("Number of levels: %d\n", 5 * gd_caveset_count()); + int num_levels_per_cave = (gd_caveset_has_levels() ? 5 : 1); + + Print("Number of levels: %d\n", num_levels_per_cave * gd_caveset_count()); Print("First level number: %d\n", 1); }