From: Holger Schemel Date: Mon, 6 Mar 2023 23:10:11 +0000 (+0100) Subject: fixed reading music from directory if music configured for all levels X-Git-Tag: 4.3.5.2~16 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8856452341f9b8b59665b98d34850744f442caee;p=rocksndiamonds.git fixed reading music from directory if music configured for all levels When collecting music files that may have music info available for the music info screen, do not add music files from music directory if game music is configured for all levels of a level set. This fixes a bug with showing music info for music files that is never played in the game, which happens if there is no "unconfigured" music in a custom music directory (because all contained music is configured in the custom music configuration), so the program falls back to the default music directory (which contains unconfigured music files which can be played as in-game music, but which is never used in this case). --- diff --git a/src/files.c b/src/files.c index 676ebf8a..39f145f5 100644 --- a/src/files.c +++ b/src/files.c @@ -12934,6 +12934,18 @@ static boolean sound_info_listed(struct MusicFileInfo *list, char *basename) return music_info_listed_ext(list, basename, TRUE); } +static boolean checkLevelSetHasMusic_NoConf(void) +{ + int i; + + for (i = leveldir_current->first_level; + i <= leveldir_current->last_level; i++) + if (levelset.music[level_nr] == MUS_UNDEFINED) + return TRUE; + + return FALSE; +} + void LoadMusicInfo(void) { char *music_directory = getCustomMusicDirectory_NoConf(); @@ -12993,6 +13005,10 @@ void LoadMusicInfo(void) } } + // if all levels have game music configured, do not read music from directory + if (!checkLevelSetHasMusic_NoConf()) + read_music_from_directory = FALSE; + if ((dir = openDirectory(music_directory)) == NULL) { Warn("cannot read music directory '%s'", music_directory);