From 8856452341f9b8b59665b98d34850744f442caee Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 7 Mar 2023 00:10:11 +0100 Subject: [PATCH] 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). --- src/files.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); -- 2.34.1