From eb017c47e0685e8a43fe8b3a022429017c67c6bc Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 3 Feb 2018 00:58:16 +0100 Subject: [PATCH] moved handling game music with negative ID from mixer to helper function - this fixes checking next played game music if it has a negative music ID - negative music IDs are used for (game) music files not specified in a GIC --- src/libgame/sound.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 8a5ab84e..15354b68 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -303,32 +303,11 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) { SoundInfo *snd_info; int i, k; - int num_sounds = getSoundListSize(); - int num_music = getMusicListSize(); if (IS_MUSIC(snd_ctrl)) - { - if (snd_ctrl.nr >= num_music) /* invalid music */ - return; - - if (snd_ctrl.nr < 0) /* undefined music */ - { - if (num_music_noconf == 0) /* no fallback music available */ - return; - - snd_ctrl.nr = UNMAP_NOCONF_MUSIC(snd_ctrl.nr) % num_music_noconf; - snd_info = Music_NoConf[snd_ctrl.nr]; - } - else - snd_info = getMusicInfoEntryFromMusicID(snd_ctrl.nr); - } + snd_info = getMusicInfoEntryFromMusicID(snd_ctrl.nr); else - { - if (snd_ctrl.nr < 0 || snd_ctrl.nr >= num_sounds) - return; - snd_info = getSoundInfoEntryFromSoundID(snd_ctrl.nr); - } if (snd_info == NULL) return; @@ -735,9 +714,19 @@ static MusicInfo *getMusicInfoEntryFromMusicID(int pos) (MusicInfo **)(pos < num_list_entries ? music_info->artwork_list : music_info->dynamic_artwork_list); - if (pos < 0 || pos >= num_music) /* invalid music */ + if (pos >= num_music) /* invalid music */ return NULL; + if (pos < 0) /* undefined music */ + { + if (num_music_noconf == 0) /* no fallback music available */ + return NULL; + + pos = UNMAP_NOCONF_MUSIC(pos) % num_music_noconf; + + return Music_NoConf[pos]; + } + return mus_info[list_pos]; } -- 2.34.1