X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=ccbd2ed5ce6b36bd27db430584f8e2d31ccf78c7;hb=c9c4509483fdd52fb18925662c295ba5610237ed;hp=9ea1754932adb1371c9d994aca8e8af497411e3a;hpb=7a8e465114815815796c2ebbe5f2e018a9265a3f;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 9ea17549..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; @@ -2075,7 +2106,7 @@ unsigned int get_hash_from_key(void *key) return hash; } -static int keys_are_equal(void *key1, void *key2) +int hash_keys_are_equal(void *key1, void *key2) { return (strEqual((char *)key1, (char *)key2)); } @@ -2083,7 +2114,7 @@ static int keys_are_equal(void *key1, void *key2) SetupFileHash *newSetupFileHash(void) { SetupFileHash *new_hash = - create_hashtable(16, 0.75, get_hash_from_key, keys_are_equal); + create_hashtable(16, 0.75, get_hash_from_key, hash_keys_are_equal); if (new_hash == NULL) Fail("create_hashtable() failed -- out of memory"); @@ -3080,6 +3111,17 @@ static void setTreeInfoParentNodes(TreeInfo *node, TreeInfo *node_parent) } } +TreeInfo *addTopTreeInfoNode(TreeInfo *node_first) +{ + // add top tree node with back link node in previous tree + node_first = createTopTreeInfoNode(node_first); + + // set all parent links (back links) in complete tree + setTreeInfoParentNodes(node_first, NULL); + + return node_first; +} + // ---------------------------------------------------------------------------- // functions for handling level and custom artwork info cache @@ -4214,11 +4256,8 @@ static void LoadArtworkInfoFromLevelInfo(ArtworkDirTree **artwork_node) LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, TRUE); LoadArtworkInfoFromLevelInfoExt(artwork_node, NULL, leveldir_first_all, FALSE); - // add top tree node over all three separate sub-trees - *artwork_node = createTopTreeInfoNode(*artwork_node); - - // set all parent links (back links) in complete artwork tree - setTreeInfoParentNodes(*artwork_node, NULL); + // add top tree node over all sub-trees and set parent links + *artwork_node = addTopTreeInfoNode(*artwork_node); } void LoadLevelArtworkInfo(void)