From: Holger Schemel Date: Sat, 9 Apr 2022 18:04:36 +0000 (+0200) Subject: added "levelinfo.conf" options to rename levels with title "nameless level" X-Git-Tag: 4.3.2.0~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7991a249fc798c3b7330def99bf61a33717a4ea1;p=rocksndiamonds.git added "levelinfo.conf" options to rename levels with title "nameless level" --- diff --git a/src/files.c b/src/files.c index 3564470c..3278b0c6 100644 --- a/src/files.c +++ b/src/files.c @@ -6566,6 +6566,13 @@ static void LoadLevel_InitSettings(struct LevelInfo *level) { // adjust level settings for (non-native) Sokoban-style levels LoadLevel_InitSettings_SB(level); + + // rename levels with title "nameless level" or if renaming is forced + if (leveldir_current->empty_level_name != NULL && + (strEqual(level->name, NAMELESS_LEVEL_NAME) || + leveldir_current->force_level_name)) + snprintf(level->name, MAX_LEVEL_NAME_LEN + 1, + leveldir_current->empty_level_name, level_nr); } static void LoadLevel_InitStandardElements(struct LevelInfo *level) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 60bb5685..3557e949 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -2636,11 +2636,13 @@ SetupFileHash *loadSetupFileHash(char *filename) #define LEVELINFO_TOKEN_FILENAME 24 #define LEVELINFO_TOKEN_FILETYPE 25 #define LEVELINFO_TOKEN_SPECIAL_FLAGS 26 -#define LEVELINFO_TOKEN_HANDICAP 27 -#define LEVELINFO_TOKEN_SKIP_LEVELS 28 -#define LEVELINFO_TOKEN_USE_EMC_TILES 29 +#define LEVELINFO_TOKEN_EMPTY_LEVEL_NAME 27 +#define LEVELINFO_TOKEN_FORCE_LEVEL_NAME 28 +#define LEVELINFO_TOKEN_HANDICAP 29 +#define LEVELINFO_TOKEN_SKIP_LEVELS 30 +#define LEVELINFO_TOKEN_USE_EMC_TILES 31 -#define NUM_LEVELINFO_TOKENS 30 +#define NUM_LEVELINFO_TOKENS 32 static LevelDirTree ldi; @@ -2674,6 +2676,8 @@ static struct TokenInfo levelinfo_tokens[] = { TYPE_STRING, &ldi.level_filename, "filename" }, { TYPE_STRING, &ldi.level_filetype, "filetype" }, { TYPE_STRING, &ldi.special_flags, "special_flags" }, + { TYPE_STRING, &ldi.empty_level_name, "empty_level_name" }, + { TYPE_BOOLEAN, &ldi.force_level_name, "force_level_name" }, { TYPE_BOOLEAN, &ldi.handicap, "handicap" }, { TYPE_BOOLEAN, &ldi.skip_levels, "skip_levels" }, { TYPE_BOOLEAN, &ldi.use_emc_tiles, "use_emc_tiles" } @@ -2771,6 +2775,9 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type) ti->special_flags = NULL; + ti->empty_level_name = NULL; + ti->force_level_name = FALSE; + ti->levels = 0; ti->first_level = 0; ti->last_level = 0; @@ -2853,6 +2860,9 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent) ti->special_flags = getStringCopy(parent->special_flags); + ti->empty_level_name = getStringCopy(parent->empty_level_name); + ti->force_level_name = parent->force_level_name; + ti->levels = parent->levels; ti->first_level = parent->first_level; ti->last_level = parent->last_level; @@ -2915,6 +2925,9 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti) ti_copy->special_flags = getStringCopy(ti->special_flags); + ti_copy->empty_level_name = getStringCopy(ti->empty_level_name); + ti_copy->force_level_name = ti->force_level_name; + ti_copy->levels = ti->levels; ti_copy->first_level = ti->first_level; ti_copy->last_level = ti->last_level; diff --git a/src/libgame/system.h b/src/libgame/system.h index cf2bf163..15391399 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1623,6 +1623,9 @@ struct TreeInfo char *special_flags; // flags for special actions performed on level file + char *empty_level_name; // name pattern if level title is "nameless level" + boolean force_level_name; // force also renaming non-nameless level titles + int levels; // number of levels in level series int first_level; // first level number (to allow start with 0 or 1) int last_level; // last level number (automatically calculated)