Use strrchr instead of strchr for music filename extension in case there are dots in the filename

This commit is contained in:
zicodxx 2010-06-14 10:43:30 +00:00
parent 196a149c71
commit 36e20a419a
3 changed files with 8 additions and 7 deletions

View file

@ -5,6 +5,7 @@ D1X-Rebirth Changelog
include/args.h, include/physfsx.h, main/newmenu.h, main/inferno.c, main/menu.c, main/songs.c, main/songs.h, main/config.c, main/config.h, main/gameseq.c, main/digiobj.c, main/digi.h, main/game.c, main/gamecntl.c, misc/args.c, d1x.ini, arch/sdl/digi_mixer.c, arch/sdl/digi_mixer_music.c, arch/sdl/init.c, arch/sdl/jukebox.c, arch/sdl/digi.c, arch/sdl/digi_audio.c, arch/include/digi_audio.h, arch/include/digi_mixer.h, arch/include/digi_mixer_music.h, arch/include/jukebox.h: Increased SDL_mixer music abilities to play non-hmp from HOGs, having Level-music path to play, options to specify non-level tracks and added various playing order methods; Abstracted SDL_mixer- and Redbook-interfaces; Simplified program flow through all music functions
arch/include/window.h: Added missing newline at EOF
arch/sdl/jukebox.c: Small fix and improvement for Jukebox path detection
arch/sdl/digi_mixer_music.c, main/songs.c: Use strrchr instead of strchr for music filename extension in case there are dots in the filename
20100503
--------

View file

@ -75,7 +75,7 @@ int mix_play_file(char *filename, int loop, void (*hook_finished_track)())
mix_free_music(); // stop and free what we're already playing, if anything
fptr = strchr(filename, '.');
fptr = strrchr(filename, '.');
if (fptr == NULL)
return 0;

View file

@ -125,12 +125,12 @@ void songs_init()
Songs[i].melodic_bank_file,
Songs[i].drum_bank_file );
if (strchr(Songs[i].filename, '.'))
if (!stricmp(strchr(Songs[i].filename, '.'), ".hmp") ||
!stricmp(strchr(Songs[i].filename, '.'), ".mp3") ||
!stricmp(strchr(Songs[i].filename, '.'), ".ogg") ||
!stricmp(strchr(Songs[i].filename, '.'), ".aif") ||
!stricmp(strchr(Songs[i].filename, '.'), ".mid")
if (strrchr(Songs[i].filename, '.'))
if (!stricmp(strrchr(Songs[i].filename, '.'), ".hmp") ||
!stricmp(strrchr(Songs[i].filename, '.'), ".mp3") ||
!stricmp(strrchr(Songs[i].filename, '.'), ".ogg") ||
!stricmp(strrchr(Songs[i].filename, '.'), ".aif") ||
!stricmp(strrchr(Songs[i].filename, '.'), ".mid")
)
i++;
}