From: Holger Schemel Date: Tue, 30 Apr 2024 22:46:20 +0000 (+0200) Subject: added command line option to dump level set info X-Git-Tag: 4.4.0.0-test-1~19 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e0b898e0ad24e38b076fe2459c826577421a3a1b;p=rocksndiamonds.git added command line option to dump level set info --- diff --git a/src/files.c b/src/files.c index 278938ab..c3f5cf74 100644 --- a/src/files.c +++ b/src/files.c @@ -9041,6 +9041,46 @@ void DumpLevels(void) CloseAllAndExit(0); } +void DumpLevelsetFromFilename_BD(char *filename) +{ + if (leveldir_current == NULL) // no levelsets loaded yet + bd_open_all(); + + if (!LoadNativeLevel_BD(filename, 0, FALSE)) + CloseAllAndExit(0); // function has already printed warning + + PrintLine("-", 79); + Print("Levelset '%s'\n", filename); + PrintLine("-", 79); + + DumpLevelset_BD(); + + PrintLine("-", 79); + + CloseAllAndExit(0); +} + +void DumpLevelset(void) +{ + static LevelDirTree *dumplevelset_leveldir = NULL; + + dumplevelset_leveldir = getTreeInfoFromIdentifier(leveldir_first, + global.dumplevelset_leveldir); + if (dumplevelset_leveldir == NULL) + Fail("no such level identifier: '%s'", global.dumplevelset_leveldir); + + PrintLine("-", 79); + Print("Levelset '%s'\n", dumplevelset_leveldir->identifier); + PrintLine("-", 79); + + Print("Number of levels: %d\n", dumplevelset_leveldir->levels); + Print("First level number: %d\n", dumplevelset_leveldir->first_level); + + PrintLine("-", 79); + + CloseAllAndExit(0); +} + // ============================================================================ // tape file functions diff --git a/src/files.h b/src/files.h index aab1da88..c122716b 100644 --- a/src/files.h +++ b/src/files.h @@ -46,6 +46,8 @@ void SaveLevelTemplate(void); void SaveNativeLevel(struct LevelInfo *); void DumpLevel(struct LevelInfo *); void DumpLevels(void); +void DumpLevelsetFromFilename_BD(char *); +void DumpLevelset(void); boolean SaveLevelChecked(int); void CopyNativeLevel_RND_to_Native(struct LevelInfo *); diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 60e70c20..a060e2e4 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -103,6 +103,7 @@ void setLevelInfoToDefaults_BD_Ext(int, int); void setLevelInfoToDefaults_BD(void); boolean LoadNativeLevel_BD(char *, int, boolean); boolean SaveNativeLevel_BD(char *); +void DumpLevelset_BD(void); void PreparePreviewTileBitmap_BD(Bitmap *, int); void SetPreviewTileBitmapReference_BD(Bitmap *); diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index a3078e99..25eb0631 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -181,6 +181,12 @@ boolean SaveNativeLevel_BD(char *filename) return gd_caveset_save_to_file(filename); } +void DumpLevelset_BD(void) +{ + Print("Number of levels: %d\n", 5 * gd_caveset_count()); + Print("First level number: %d\n", 1); +} + // ============================================================================ // game engine functions diff --git a/src/init.c b/src/init.c index 2529a8ba..807a9a14 100644 --- a/src/init.c +++ b/src/init.c @@ -5196,6 +5196,7 @@ static void InitGlobal(void) global.autoplay_leveldir = NULL; global.patchtapes_leveldir = NULL; global.convert_leveldir = NULL; + global.dumplevelset_leveldir = NULL; global.dumplevel_leveldir = NULL; global.dumptape_leveldir = NULL; global.create_sketch_images_dir = NULL; @@ -5307,6 +5308,23 @@ static void Execute_Command(char *command) exit(0); } + else if (strPrefix(command, "dump levelset ")) + { + char *filename = &command[14]; + + if (fileExists(filename) && isLevelsetFilename_BD(filename)) + { + DumpLevelsetFromFilename_BD(filename); + + exit(0); + } + + char *leveldir = getStringCopy(filename); // read command parameters + + global.dumplevelset_leveldir = leveldir; + + program.headless = TRUE; + } else if (strPrefix(command, "dump level ")) { char *filename = &command[11]; @@ -6691,6 +6709,11 @@ void OpenAll(void) ConvertLevels(); return; } + else if (global.dumplevelset_leveldir) + { + DumpLevelset(); + return; + } else if (global.dumplevel_leveldir) { DumpLevels(); diff --git a/src/main.c b/src/main.c index a0b87261..8ab7313d 100644 --- a/src/main.c +++ b/src/main.c @@ -9078,6 +9078,7 @@ static void print_usage(void) " \"print editorsetup.conf\" print default editor config\n" " \"print helpanim.conf\" print default helpanim config\n" " \"print helptext.conf\" print default helptext config\n" + " \"dump levelset FILE|LEVELDIR\" dump levelset info for LEVELDIR\n" " \"dump level FILE\" dump level data from FILE\n" " \"dump tape FILE\" dump tape data from FILE\n" " \"autoplay LEVELDIR [NR ...]\" play level tapes for LEVELDIR\n" diff --git a/src/main.h b/src/main.h index 1f679aa0..9d02a4fb 100644 --- a/src/main.h +++ b/src/main.h @@ -3884,6 +3884,8 @@ struct GlobalInfo char *convert_leveldir; int convert_level_nr; + char *dumplevelset_leveldir; + char *dumplevel_leveldir; int dumplevel_level_nr;