X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsetup.c;h=524be341fb412a8b0c3fec3c1a24d91bf9ad8435;hb=90620849f8c48a86c5f76233501672fbbeb8aa08;hp=a5e2e0617aff9c4fbb386d87795f0f90a9715726;hpb=dfe0a71a9939e0c55bb54dcc92db1749e8e21747;p=rocksndiamonds.git diff --git a/src/libgame/setup.c b/src/libgame/setup.c index a5e2e061..524be341 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -79,7 +79,7 @@ static char *levelclass_desc[NUM_LEVELCLASS_DESC] = IS_LEVELCLASS_USER(n) ? 7 : \ 9) -#define TOKEN_VALUE_POSITION 30 +#define TOKEN_VALUE_POSITION 40 #define MAX_COOKIE_LEN 256 @@ -387,6 +387,81 @@ char *getCustomImageFilename(char *basename) return NULL; /* cannot find image file */ } +char *getCustomSoundFilename(char *basename) +{ + static char *filename = NULL; + + if (filename != NULL) + free(filename); + + /* 1st try: look for special artwork in current level series directory */ + filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename); + if (fileExists(filename)) + return filename; + + /* 2nd try: look for special artwork in private artwork directory */ + filename = getPath2(getUserSoundsDir(), basename); + if (fileExists(filename)) + return filename; + + /* 3rd try: look for special artwork in configured artwork directory */ + filename = getPath2(getSetupArtworkDir(artwork.snd_current), basename); + if (fileExists(filename)) + return filename; + + /* 4th try: look for default artwork in new default artwork directory */ + filename = getPath2(getDefaultSoundsDir(SOUNDS_SUBDIR), basename); + if (fileExists(filename)) + return filename; + + /* 5th try: look for default artwork in old default artwork directory */ + filename = getPath2(options.sounds_directory, basename); + if (fileExists(filename)) + return filename; + + return NULL; /* cannot find image file */ +} + +char *getCustomSoundConfigFilename() +{ + return getCustomSoundFilename(SOUNDSINFO_FILENAME); +} + +char *getCustomMusicDirectory(void) +{ + static char *directory = NULL; + + if (directory != NULL) + free(directory); + + /* 1st try: look for special artwork in current level series directory */ + directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY); + if (fileExists(directory)) + return directory; + + /* 2nd try: look for special artwork in private artwork directory */ + directory = getStringCopy(getUserMusicDir()); + if (fileExists(directory)) + return directory; + + /* 3rd try: look for special artwork in configured artwork directory */ + directory = getStringCopy(getSetupArtworkDir(artwork.mus_current)); + if (fileExists(directory)) + return directory; + + /* 4th try: look for default artwork in new default artwork directory */ + directory = getStringCopy(getDefaultMusicDir(MUSIC_SUBDIR)); + if (fileExists(directory)) + return directory; + + /* 5th try: look for default artwork in old default artwork directory */ + directory = getStringCopy(options.music_directory); + if (fileExists(directory)) + return directory; + + return NULL; /* cannot find image file */ +} + void InitTapeDirectory(char *level_subdir) { createDirectory(getUserDataDir(), "user data", PERMS_PRIVATE); @@ -1579,12 +1654,12 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, if (node_parent == NULL) /* top level group */ { - artwork_new->basepath = base_directory; - artwork_new->fullpath = artwork_new->filename; + artwork_new->basepath = getStringCopy(base_directory); + artwork_new->fullpath = getStringCopy(artwork_new->filename); } else /* sub level group */ { - artwork_new->basepath = node_parent->basepath; + artwork_new->basepath = getStringCopy(node_parent->basepath); artwork_new->fullpath = getPath2(node_parent->fullpath, directory_name); }