From: Holger Schemel Date: Tue, 18 Jun 2024 20:08:39 +0000 (+0200) Subject: added checking for help anim/text files in different locations X-Git-Tag: 4.4.0.0-test-2~1 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f13c2c27696c3b64a69e6a91415bd89e8c443dfe;p=rocksndiamonds.git added checking for help anim/text files in different locations Instead of only checking for help anim/text files in the current level set directory, these files are now also checked for - in the configured graphics set directory - in the path from the current to the topmost level set directory This adds some flexibility and optimization for adding help anim/text files for large level collections that all use the same help files. --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 53659bdd..fb63321b 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -823,26 +823,42 @@ char *getFilenameFromCurrentLevelDirUpward(char *basename) return filename; } -char *getHelpAnimFilename(void) +static char *getHelpFilename(char *basename) { static char *filename = NULL; checked_free(filename); - filename = getPath2(getCurrentLevelDir(), HELPANIM_FILENAME); + // 1st try: look for help filename in current level set directory + filename = getPath2(getCurrentLevelDir(), basename); + if (fileExists(filename)) + return filename; - return filename; -} + free(filename); -char *getHelpTextFilename(void) -{ - static char *filename = NULL; + // 2nd try: look for help filename in configured graphics set directory + filename = getPath2(getLevelArtworkDir(ARTWORK_TYPE_GRAPHICS), basename); + if (fileExists(filename)) + return filename; - checked_free(filename); + free(filename); - filename = getPath2(getCurrentLevelDir(), HELPTEXT_FILENAME); + // 3rd try: look for help filename in path from current to topmost level set directory + filename = getStringCopy(getFilenameFromCurrentLevelDirUpward(basename)); + if (fileExists(filename)) + return filename; - return filename; + return NULL; +} + +char *getHelpAnimFilename(void) +{ + return getHelpFilename(HELPANIM_FILENAME); +} + +char *getHelpTextFilename(void) +{ + return getHelpFilename(HELPTEXT_FILENAME); } static char *getLevelSetInfoBasename(int nr)