From 9539c597ddd629b0313c56b8119881515d8da140 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 20 Aug 2018 00:53:32 -0400 Subject: [PATCH] Midimode safeties for song queueing/fading --- src/s_sound.c | 4 ++-- src/sdl/mixer_sound.c | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d0927c768..abc9ee95d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1386,7 +1386,7 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U char newmusic[7]; boolean digiexists = S_DigExists(mmusic); - boolean midiexists = S_MIDIExists(newmusic); + boolean midiexists = S_MIDIExists(mmusic); #if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) if(LUAh_MusicChange(music_name, mmusic, newmusic, &mflags, &looping)) @@ -1405,7 +1405,7 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U if (digiexists && !nodigimusic && !digital_disabled) // digmusic? { - if (prefadems) //have to queue post-fade // allow even if the music is the same + if (prefadems && I_MusicType() != MU_MID) //have to queue post-fade // allow even if the music is the same { I_FadeOutStopMusic(prefadems); I_QueueDigSongPostFade(newmusic, mflags & MUSIC_TRACKMASK, looping, position, fadeinms); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index b5520325f..1b6823429 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -512,11 +512,17 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata) static void run_queue() { - if (queue_stopafterfade) + if (queue_stopafterfade && midimode) + I_StopSong(1337); + else if (queue_stopafterfade && !midimode) I_StopDigSong(); else if (queue_music_name[0]) { - I_StopDigSong(); + if (!midimode) + I_StopDigSong(); + else + I_StopSong(1337); + if (I_StartDigSong(queue_music_name, queue_looping)) { I_SetSongTrack(queue_track); @@ -1252,15 +1258,13 @@ boolean I_FadeMusicFromLevel(UINT8 target_volume, UINT8 source_volume, UINT32 ms return true; } } - else if (!volume_delta) + else if (!volume_delta || midimode) { - if (stopafterfade) - { + if (stopafterfade && !midimode) I_StopDigSong(); - return true; - } - else - return true; + else if (stopafterfade && midimode) + I_StopSong(1337); + return true; } // Round MS to nearest 10 @@ -1309,7 +1313,7 @@ boolean I_FadeInStartDigSong(const char *musicname, UINT16 track, boolean loopin { if (musicname[0] == 0) return true; // nothing to play - else if (queuepostfade && is_fading) + else if (queuepostfade && is_fading && !midimode) { strncpy(queue_music_name, musicname, 7); queue_music_name[6] = 0;