From: Holger Schemel Date: Thu, 14 Apr 2022 22:57:49 +0000 (+0200) Subject: added warning only once per file when using fallback artwork X-Git-Tag: 4.3.2.0~11 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fb402760dddcc06205acbcc8123ee99a11536b84;p=rocksndiamonds.git added warning only once per file when using fallback artwork --- diff --git a/src/init.c b/src/init.c index 1c1f85e2..c4b787e7 100644 --- a/src/init.c +++ b/src/init.c @@ -6301,6 +6301,8 @@ void ReloadCustomArtwork(int force_reload) UPDATE_BUSY_STATE(); + InitMissingFileHash(); + if (gfx_new_identifier != NULL || force_reload_gfx) { #if 0 @@ -6437,6 +6439,8 @@ void OpenAll(void) InitSimpleRandom(NEW_RANDOMIZE); InitBetterRandom(NEW_RANDOMIZE); + InitMissingFileHash(); + print_timestamp_time("[init global stuff]"); InitSetup(); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 3557e949..7e34711a 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -70,6 +70,7 @@ static int token_comment_position = TOKEN_COMMENT_POSITION_DEFAULT; static SetupFileHash *artworkinfo_cache_old = NULL; static SetupFileHash *artworkinfo_cache_new = NULL; static SetupFileHash *optional_tokens_hash = NULL; +static SetupFileHash *missing_file_hash = NULL; static boolean use_artworkinfo_cache = TRUE; static boolean update_artworkinfo_cache = FALSE; @@ -78,6 +79,16 @@ static boolean update_artworkinfo_cache = FALSE; // file functions // ---------------------------------------------------------------------------- +static void WarnUsingFallback(char *filename) +{ + if (getHashEntry(missing_file_hash, filename) == NULL) + { + setHashEntry(missing_file_hash, filename, ""); + + Warn("cannot find artwork file '%s' (using fallback)", filename); + } +} + static char *getLevelClassDescription(TreeInfo *ti) { int position = ti->sort_priority / 100; @@ -976,7 +987,7 @@ char *getCustomImageFilename(char *basename) { free(filename); - Warn("cannot find artwork file '%s' (using fallback)", basename); + WarnUsingFallback(basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -1047,7 +1058,7 @@ char *getCustomSoundFilename(char *basename) { free(filename); - Warn("cannot find artwork file '%s' (using fallback)", basename); + WarnUsingFallback(basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -1118,7 +1129,7 @@ char *getCustomMusicFilename(char *basename) { free(filename); - Warn("cannot find artwork file '%s' (using fallback)", basename); + WarnUsingFallback(basename); // 6th try: look for fallback artwork in old default artwork directory // (needed to prevent errors when trying to access unused artwork files) @@ -1242,6 +1253,14 @@ boolean CheckTapeDirectoryUploadsComplete(char *level_subdir) return success; } +void InitMissingFileHash(void) +{ + if (missing_file_hash == NULL) + freeSetupFileHash(missing_file_hash); + + missing_file_hash = newSetupFileHash(); +} + void InitTapeDirectory(char *level_subdir) { boolean new_tape_dir = !directoryExists(getTapeDir(level_subdir)); diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 4b2e65f6..573d55b7 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -294,6 +294,7 @@ void MarkTapeDirectoryUploadsAsComplete(char *); void MarkTapeDirectoryUploadsAsIncomplete(char *); boolean CheckTapeDirectoryUploadsComplete(char *); +void InitMissingFileHash(void); void InitTapeDirectory(char *); void InitScoreDirectory(char *); void InitScoreCacheDirectory(char *);