From 6b028049e0a587089b0a5038ce27caaa4f366cd3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 20 Aug 2018 00:28:41 -0400 Subject: [PATCH] Music lump existence minor fixes --- src/s_sound.c | 9 +++++++-- src/s_sound.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 12c322788..d0927c768 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1385,6 +1385,9 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U return; char newmusic[7]; + boolean digiexists = S_DigExists(mmusic); + boolean midiexists = S_MIDIExists(newmusic); + #if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS) if(LUAh_MusicChange(music_name, mmusic, newmusic, &mflags, &looping)) return; @@ -1400,7 +1403,7 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U return; } - if (S_MusicExists(newmusic, false, true) && !nodigimusic && !digital_disabled) // digmusic? + if (digiexists && !nodigimusic && !digital_disabled) // digmusic? { if (prefadems) //have to queue post-fade // allow even if the music is the same { @@ -1426,7 +1429,7 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U I_SetSongTrack(mflags & MUSIC_TRACKMASK); } } - else if (strncmp(music_name, newmusic, 6) && S_MusicExists(newmusic, true, false) && !nomidimusic && !music_disabled) // midimusic? + else if (strncmp(music_name, newmusic, 6) && midiexists && !nomidimusic && !music_disabled) // midimusic? { // HACK: We don't support fade for MIDI right now, so // just fall to old behavior verbatim. This technically should be implemented in @@ -1440,6 +1443,8 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U return; } } + else if (!midiexists && !digiexists) + CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), newmusic); } musictype_t S_MusicType() diff --git a/src/s_sound.h b/src/s_sound.h index cdcacd14e..e616f13d8 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -174,6 +174,8 @@ const char *S_MusicName(void); // Checks if music name exists boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); +#define S_DigExists(a) S_MusicExists(a, false, true) +#define S_MIDIExists(a) S_MusicExists(a, true, false) void S_StopFadingMusic(void); boolean S_FadeMusicFromLevel(UINT8 target_volume, INT16 source_volume, UINT32 ms);