From: Holger Schemel Date: Mon, 28 Mar 2022 17:42:42 +0000 (+0200) Subject: added functions to get credits filename (not used yet) X-Git-Tag: 4.3.2.0~56 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c9c4509483fdd52fb18925662c295ba5610237ed;p=rocksndiamonds.git added functions to get credits filename (not used yet) --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 88762de4..ccbd2ed5 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -853,6 +853,37 @@ char *getLevelSetTitleMessageFilename(int nr, boolean initial) return NULL; // cannot find specified artwork file anywhere } +static char *getCreditsBasename(int nr) +{ + static char basename[32]; + + sprintf(basename, "credits_%d.txt", nr + 1); + + return basename; +} + +char *getCreditsFilename(int nr, boolean global) +{ + char *basename = getCreditsBasename(nr); + char *basepath = NULL; + static char *credits_subdir = NULL; + static char *filename = NULL; + + if (credits_subdir == NULL) + credits_subdir = getPath2(DOCS_DIRECTORY, CREDITS_DIRECTORY); + + checked_free(filename); + + // look for credits file in the game's base or current level set directory + basepath = (global ? options.base_directory : getCurrentLevelDir()); + + filename = getPath3(basepath, credits_subdir, basename); + if (fileExists(filename)) + return filename; + + return NULL; // cannot find credits file +} + static char *getCorrectedArtworkBasename(char *basename) { return basename; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 36df605e..69a9175e 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -279,6 +279,7 @@ char *getHelpAnimFilename(void); char *getHelpTextFilename(void); char *getLevelSetInfoFilename(void); char *getLevelSetTitleMessageFilename(int, boolean); +char *getCreditsFilename(int, boolean); char *getImageFilename(char *); char *getCustomImageFilename(char *); char *getCustomSoundFilename(char *); diff --git a/src/libgame/system.h b/src/libgame/system.h index d3ec73c1..8c79f19d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -655,6 +655,7 @@ #define SCORES_DIRECTORY "scores" #define DOCS_DIRECTORY "docs" #define ELEMENTS_DIRECTORY "elements" +#define CREDITS_DIRECTORY "credits" #define CACHE_DIRECTORY "cache" #define CONF_DIRECTORY "conf" #define NETWORK_DIRECTORY "network"