X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fsetup.c;h=3ff14a1ca9cc614cd7c8d4998c9a5c4c85f1ace8;hb=30f635b58c076871cee2630ce15ffd7019764b2e;hp=985c160a245b9f3b16f33ecedb2e9a79b4c99c9c;hpb=04cfb5daeff6cbceef152fc01ad5852407c0c918;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 985c160a..3ff14a1c 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -602,6 +602,15 @@ char *getCustomImageFilename(char *basename) if (fileExists(filename)) return filename; +#if CREATE_SPECIAL_EDITION + free(filename); + + /* 6th try: look for fallback artwork in old default artwork directory */ + filename = getPath2(options.graphics_directory, GFX_FALLBACK_FILENAME); + if (fileExists(filename)) + return filename; +#endif + return NULL; /* cannot find specified artwork file anywhere */ } @@ -660,6 +669,15 @@ char *getCustomSoundFilename(char *basename) if (fileExists(filename)) return filename; +#if CREATE_SPECIAL_EDITION + free(filename); + + /* 6th try: look for fallback artwork in old default artwork directory */ + filename = getPath2(options.sounds_directory, SND_FALLBACK_FILENAME); + if (fileExists(filename)) + return filename; +#endif + return NULL; /* cannot find specified artwork file anywhere */ } @@ -718,6 +736,15 @@ char *getCustomMusicFilename(char *basename) if (fileExists(filename)) return filename; +#if CREATE_SPECIAL_EDITION + free(filename); + + /* 6th try: look for fallback artwork in old default artwork directory */ + filename = getPath2(options.music_directory, MUS_FALLBACK_FILENAME); + if (fileExists(filename)) + return filename; +#endif + return NULL; /* cannot find specified artwork file anywhere */ } @@ -1609,11 +1636,15 @@ static void printSetupFileHash(SetupFileHash *hash) #define ALLOW_TOKEN_VALUE_SEPARATOR_BEING_WHITESPACE 1 #define CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING 0 +#define CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH 0 static boolean token_value_separator_found = FALSE; #if CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING static boolean token_value_separator_warning = FALSE; #endif +#if CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH +static boolean token_already_exists_warning = FALSE; +#endif static boolean getTokenValueFromSetupLineExt(char *line, char **token_ptr, char **value_ptr, @@ -1769,13 +1800,16 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, void *insert_ptr = NULL; boolean read_continued_line = FALSE; FILE *file; - int line_nr = 0; - int token_count = 0; + int line_nr = 0, token_count = 0, include_count = 0; #if CHECK_TOKEN_VALUE_SEPARATOR__WARN_IF_MISSING token_value_separator_warning = FALSE; #endif +#if CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH + token_already_exists_warning = FALSE; +#endif + if (!(file = fopen(filename, MODE_READ))) { Error(ERR_WARN, "cannot open configuration file '%s'", filename); @@ -1865,6 +1899,8 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, free(basepath); free(basename); free(filename_include); + + include_count++; } else { @@ -1874,9 +1910,34 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, else { if (is_hash) + { +#if CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH + char *old_value = + getHashEntry((SetupFileHash *)setup_file_data, token); + + if (old_value != NULL) + { + if (!token_already_exists_warning) + { + Error(ERR_INFO_LINE, "-"); + Error(ERR_WARN, "duplicate token(s) found in config file:"); + Error(ERR_INFO, "- config file: '%s'", filename); + + token_already_exists_warning = TRUE; + } + + Error(ERR_INFO, "- token: '%s' (in line %d)", token, line_nr); + Error(ERR_INFO, " old value: '%s'", old_value); + Error(ERR_INFO, " new value: '%s'", value); + } +#endif + setHashEntry((SetupFileHash *)setup_file_data, token, value); + } else + { insert_ptr = addListEntry((SetupFileList *)insert_ptr, token, value); + } token_count++; } @@ -1890,7 +1951,12 @@ static boolean loadSetupFileData(void *setup_file_data, char *filename, Error(ERR_INFO_LINE, "-"); #endif - if (token_count == 0) +#if CHECK_TOKEN__WARN_IF_ALREADY_EXISTS_IN_HASH + if (token_already_exists_warning) + Error(ERR_INFO_LINE, "-"); +#endif + + if (token_count == 0 && include_count == 0) Error(ERR_WARN, "configuration file '%s' is empty", filename); if (top_recursion_level) @@ -2854,8 +2920,10 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, char *level_directory, char *directory_name) { +#if 0 static unsigned long progress_delay = 0; unsigned long progress_delay_value = 100; /* (in milliseconds) */ +#endif char *directory_path = getPath2(level_directory, directory_name); char *filename = getPath2(directory_path, LEVELINFO_FILENAME); SetupFileHash *setup_file_hash; @@ -2956,9 +3024,14 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, leveldir_new->last_level : leveldir_new->first_level); #if 1 +#if 1 + DrawInitTextExt(leveldir_new->name, 150, FC_YELLOW, + leveldir_new->level_group); +#else if (leveldir_new->level_group || DelayReached(&progress_delay, progress_delay_value)) DrawInitText(leveldir_new->name, 150, FC_YELLOW); +#endif #else DrawInitText(leveldir_new->name, 150, FC_YELLOW); #endif @@ -3405,8 +3478,10 @@ void LoadArtworkInfo() void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, LevelDirTree *level_node) { +#if 0 static unsigned long progress_delay = 0; unsigned long progress_delay_value = 100; /* (in milliseconds) */ +#endif int type = (*artwork_node)->type; /* recursively check all level directories for artwork sub-directories */ @@ -3452,6 +3527,9 @@ void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node, } #if 1 + DrawInitTextExt(level_node->name, 150, FC_YELLOW, + level_node->level_group); +#else if (level_node->level_group || DelayReached(&progress_delay, progress_delay_value)) DrawInitText(level_node->name, 150, FC_YELLOW);