From a7b198d7eeb9814393c975b0bbfa79e214063fcd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Sep 2020 19:20:25 +0200 Subject: [PATCH] - Stop music when ending a level, or when going back to the menu in Blood. Also play the sound on Blood's summary screen as an UI sound. Fixes #349 --- source/blood/src/d_menu.cpp | 1 + source/blood/src/endgame.cpp | 2 +- source/blood/src/sound.cpp | 5 +++-- source/blood/src/sound.h | 3 ++- source/core/mainloop.cpp | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index e56a7c866..3f6448f0d 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -288,6 +288,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* t void GameInterface::QuitToTitle() { + Mus_Stop(); gameaction = ga_mainmenu; } diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index ef2d3193e..8a907e365 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -167,7 +167,7 @@ class DBloodSummaryScreen : public DScreenJob void GameInterface::LevelCompleted(MapRecord *map, int skill) { JobDesc job = { Create() }; - sndStartSample(268, 128, -1, false); + sndStartSample(268, 128, -1, false, CHANF_UI); RunScreenJob(&job, 1, [=](bool) { soundEngine->StopAllChannels(); diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 9a686e363..784930880 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -158,7 +158,7 @@ void sndStartSample(const char *pzSound, int nVolume, int nChannel) } } -void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop) +void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop, EChanFlags chanflags) { if (!SoundEnabled()) return; @@ -173,7 +173,8 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop) if (udata) nVolume = std::min(Scale(udata[2], 255, 100), 255); else nVolume = 255; } - soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), (bLoop? CHANF_LOOP : EChanFlags::FromInt(0)), snd, nVolume / 255.f, ATTN_NONE); + if (bLoop) chanflags |= CHANF_LOOP; + soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), chanflags, snd, nVolume / 255.f, ATTN_NONE); } } diff --git a/source/blood/src/sound.h b/source/blood/src/sound.h index e82632207..b3dd7085a 100644 --- a/source/blood/src/sound.h +++ b/source/blood/src/sound.h @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "misc.h" #include "raze_music.h" +#include "s_soundinternal.h" BEGIN_BLD_NS @@ -45,7 +46,7 @@ struct SFX int sndGetRate(int format); void sndStartSample(const char *pzSound, int nVolume, int nChannel = -1); -void sndStartSample(unsigned int nSound, int nVolume, int nChannel = -1, bool bLoop = false); +void sndStartSample(unsigned int nSound, int nVolume, int nChannel = -1, bool bLoop = false, EChanFlags soundflags = CHANF_NONE); void sndStartWavID(unsigned int nSound, int nVolume, int nChannel = -1); void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel = -1); void sndKillAllSounds(void); diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 693bb079f..2f1dddbd1 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -147,6 +147,7 @@ static void GameTicker() case ga_completed: FX_StopAllSounds(); FX_SetReverb(0); + Mus_Stop(); if (g_nextmap == currentLevel) { // if the same level is restarted, skip any progression stuff like summary screens or cutscenes.