From: Holger Schemel Date: Mon, 27 Oct 2014 23:15:18 +0000 (+0100) Subject: fixed some smaller issues with loading custom artwork X-Git-Tag: 4.0.0.0-rc1~320 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4fb7d637c3bcc3381918636fdd22733ff7bae3ac;p=rocksndiamonds.git fixed some smaller issues with loading custom artwork --- diff --git a/ChangeLog b/ChangeLog index d98af9f9..5a7a6ee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-10-27 + * fixed some smaller issues with loading custom artwork + 2014-10-22 * added warnings when using undefined element and graphic names in custom artwork definitions (like ".crumbled_like" or ".clone_from") diff --git a/src/conftime.h b/src/conftime.h index 75c7e4d5..545fff3a 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-10-23 00:22" +#define COMPILE_DATE_STRING "2014-10-27 21:31" diff --git a/src/files.c b/src/files.c index 343c6d94..793151ca 100644 --- a/src/files.c +++ b/src/files.c @@ -9257,7 +9257,7 @@ void LoadMusicInfo() if (music_already_used) continue; - if (!FileIsMusic(basename)) + if (!FileIsMusic(dir_entry->filename)) continue; if (!music_info_listed(music_file_info, basename)) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index eb2f8f0c..c123892d 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2209,7 +2209,9 @@ boolean directoryExists(char *dir_name) if (dir_name == NULL) return FALSE; - boolean success = (access(dir_name, F_OK) == 0); + struct stat file_status; + boolean success = (stat(dir_name, &file_status) == 0 && + (file_status.st_mode & S_IFMT) == S_IFDIR); #if defined(PLATFORM_ANDROID) if (!success) @@ -2297,40 +2299,37 @@ boolean fileHasSuffix(char *basename, char *suffix) return FALSE; } -static boolean FileCouldBeArtwork(char *basename) +static boolean FileCouldBeArtwork(char *filename) { + char *basename = getBaseNamePtr(filename); + return (!strEqual(basename, ".") && !strEqual(basename, "..") && !fileHasSuffix(basename, "txt") && - !fileHasSuffix(basename, "conf")); + !fileHasSuffix(basename, "conf") && + !directoryExists(filename)); } boolean FileIsGraphic(char *filename) { - char *basename = getBaseNamePtr(filename); - - return FileCouldBeArtwork(basename); + return FileCouldBeArtwork(filename); } boolean FileIsSound(char *filename) { - char *basename = getBaseNamePtr(filename); - - return FileCouldBeArtwork(basename); + return FileCouldBeArtwork(filename); } boolean FileIsMusic(char *filename) { - char *basename = getBaseNamePtr(filename); - - return FileCouldBeArtwork(basename); + return FileCouldBeArtwork(filename); } -boolean FileIsArtworkType(char *basename, int type) +boolean FileIsArtworkType(char *filename, int type) { - if ((type == TREE_TYPE_GRAPHICS_DIR && FileIsGraphic(basename)) || - (type == TREE_TYPE_SOUNDS_DIR && FileIsSound(basename)) || - (type == TREE_TYPE_MUSIC_DIR && FileIsMusic(basename))) + if ((type == TREE_TYPE_GRAPHICS_DIR && FileIsGraphic(filename)) || + (type == TREE_TYPE_SOUNDS_DIR && FileIsSound(filename)) || + (type == TREE_TYPE_MUSIC_DIR && FileIsMusic(filename))) return TRUE; return FALSE; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index e60c8424..b07f2fdf 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -3026,9 +3026,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, { while ((dir_entry = readDirectory(dir)) != NULL) { - char *entry_name = dir_entry->basename; - - if (FileIsArtworkType(entry_name, type)) + if (FileIsArtworkType(dir_entry->filename, type)) { valid_file_found = TRUE; diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 591ea7d4..5ace5922 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -598,7 +598,6 @@ void LoadCustomMusic_NoConf(void) while ((dir_entry = readDirectory(dir)) != NULL) /* loop all entries */ { char *basename = dir_entry->basename; - char *filename = NULL; MusicInfo *mus_info = NULL; boolean music_already_used = FALSE; int i; @@ -621,12 +620,8 @@ void LoadCustomMusic_NoConf(void) if (draw_init_text) DrawInitText(basename, 150, FC_YELLOW); - filename = getPath2(music_directory, basename); - - if (FileIsMusic(basename)) - mus_info = Load_WAV_or_MOD(filename); - - free(filename); + if (FileIsMusic(dir_entry->filename)) + mus_info = Load_WAV_or_MOD(dir_entry->filename); if (mus_info) {