From: Holger Schemel Date: Sun, 7 Sep 2003 19:17:29 +0000 (+0200) Subject: rnd-20030907-2-src X-Git-Tag: 3.0.3^2~1 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ab36ea459d91a62195f4136501a86c5f1196b2b0;p=rocksndiamonds.git rnd-20030907-2-src 2003-09-07 src/libgame/misc.c * added support for loading various music formats through SDL_mixer 2003-09-06 (various source files) * fixed several nasty bugs that may have caused crashes on some systems * added envelope content which gets displayed when collecting envelope * added multiple change event pages for custom elements --- diff --git a/CHANGES b/CHANGES index e57b06e9..974eff7c 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,10 @@ Release Version 3.0.3 [?? ??? ????] - fixed problem with setting mouse cursor in SDL version in fullscreen - fixed problem with flickering when drawing toon animations - fixed problem with player animation when snapping and moving + - fixed several nasty bugs that may have caused crashes on some systems + - added envelope content which gets displayed when collecting envelope + - added multiple change event pages for custom elements + - added support for loading various music formats through SDL_mixer Release Version 3.0.2 [22 AUG 2003] ----------------------------------- diff --git a/ChangeLog b/ChangeLog index 72a85505..7f6dd379 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-09-07 src/libgame/misc.c + * added support for loading various music formats through SDL_mixer + +2003-09-06 (various source files) + * fixed several nasty bugs that may have caused crashes on some systems + * added envelope content which gets displayed when collecting envelope + * added multiple change event pages for custom elements + 2003-08-24 src/game.c * fixed problem with player animation when snapping and moving diff --git a/src/conftime.h b/src/conftime.h index f75d70a6..c0b0e6b3 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-09-06 22:18]" +#define COMPILE_DATE_STRING "[2003-09-07 21:03]" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 70b2a5d6..0d5a658e 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1518,37 +1518,77 @@ boolean fileExists(char *filename) return (access(filename, F_OK) == 0); } -boolean FileIsGraphic(char *filename) +boolean fileHasPrefix(char *basename, char *prefix) { - if (strlen(filename) > 4 && - strcmp(&filename[strlen(filename) - 4], ".pcx") == 0) + static char *basename_lower = NULL; + int basename_length, prefix_length; + + if (basename_lower != NULL) + free(basename_lower); + + if (basename == NULL || prefix == NULL) + return FALSE; + + basename_lower = getStringToLower(basename); + basename_length = strlen(basename_lower); + prefix_length = strlen(prefix); + + if (basename_length > prefix_length + 1 && + basename_lower[prefix_length] == '.' && + strncmp(basename_lower, prefix, prefix_length) == 0) return TRUE; return FALSE; } -boolean FileIsSound(char *basename) +boolean fileHasSuffix(char *basename, char *suffix) { - if (strlen(basename) > 4 && - strcmp(&basename[strlen(basename) - 4], ".wav") == 0) + static char *basename_lower = NULL; + int basename_length, suffix_length; + + if (basename_lower != NULL) + free(basename_lower); + + if (basename == NULL || suffix == NULL) + return FALSE; + + basename_lower = getStringToLower(basename); + basename_length = strlen(basename_lower); + suffix_length = strlen(suffix); + + if (basename_length > suffix_length + 1 && + basename_lower[basename_length - suffix_length - 1] == '.' && + strcmp(&basename_lower[basename_length - suffix_length], suffix) == 0) return TRUE; return FALSE; } -boolean FileIsMusic(char *basename) +boolean FileIsGraphic(char *basename) { - /* "music" can be a WAV (loop) file or (if compiled with SDL) a MOD file */ + return fileHasSuffix(basename, "pcx"); +} +boolean FileIsSound(char *basename) +{ + return fileHasSuffix(basename, "wav"); +} + +boolean FileIsMusic(char *basename) +{ if (FileIsSound(basename)) return TRUE; #if defined(TARGET_SDL) - if (strlen(basename) > 4 && - (strcmp(&basename[strlen(basename) - 4], ".mod") == 0 || - strcmp(&basename[strlen(basename) - 4], ".MOD") == 0 || - strncmp(basename, "mod.", 4) == 0 || - strncmp(basename, "MOD.", 4) == 0)) + if (fileHasPrefix(basename, "mod") || + fileHasSuffix(basename, "mod") || + fileHasSuffix(basename, "s3m") || + fileHasSuffix(basename, "it") || + fileHasSuffix(basename, "xm") || + fileHasSuffix(basename, "midi") || + fileHasSuffix(basename, "mid") || + fileHasSuffix(basename, "mp3") || + fileHasSuffix(basename, "ogg")) return TRUE; #endif