From: Holger Schemel Date: Wed, 12 Apr 2023 11:57:20 +0000 (+0200) Subject: added sorting unconfigured music files by filename X-Git-Tag: 4.3.6.0~32 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=1322810321b274b4c1f1ad8f5598196c93f7452b;p=rocksndiamonds.git added sorting unconfigured music files by filename Before, unconfigured music files were played in the order they were stored in the file system (that is, in unpredictable order). This change adds sorting them by filename. --- diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 2b1ccd87..177992d7 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -587,6 +587,14 @@ static void *Load_WAV_or_MOD(char *filename) return NULL; } +static int compareMusicInfo(const void *object1, const void *object2) +{ + const MusicInfo *mi1 = *((MusicInfo **)object1); + const MusicInfo *mi2 = *((MusicInfo **)object2); + + return strcmp(mi1->source_filename, mi2->source_filename); +} + static void LoadCustomMusic_NoConf(void) { static boolean draw_init_text = TRUE; // only draw at startup @@ -664,6 +672,9 @@ static void LoadCustomMusic_NoConf(void) closeDirectory(dir); + // sort music files by filename + qsort(Music_NoConf, num_music_noconf, sizeof(MusicInfo *), compareMusicInfo); + draw_init_text = FALSE; }