From 60fe1d32fb8cac7e4cdc315c19d8895813111259 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 May 2021 11:51:51 +0200 Subject: [PATCH] - Blood: unpositioned sounds must be limited to one per channel. --- source/common/audio/sound/s_sound.cpp | 7 +------ source/core/gamecontrol.cpp | 8 ++++---- source/games/blood/src/sound.cpp | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index 7fdbd74c6..8ec5fc76b 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -929,12 +929,7 @@ void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, int void SoundEngine::StopActorSounds(int sourcetype, const void* actor, int chanmin, int chanmax) { const bool all = (chanmin == 0 && chanmax == 0); - if (!all && chanmax > chanmin) - { - const int temp = chanmax; - chanmax = chanmin; - chanmin = temp; - } + if (chanmax < chanmin) std::swap(chanmin, chanmax); FSoundChan* chan = Channels; while (chan != nullptr) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 0beea4a0c..cbc366675 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1192,10 +1192,10 @@ void S_SetSoundPaused(int state) if (paused == 0) { S_ResumeSound(true); - if (GSnd != nullptr) - { - GSnd->SetInactive(SoundRenderer::INACTIVE_Active); - } + } + if (GSnd != nullptr) + { + GSnd->SetInactive(SoundRenderer::INACTIVE_Active); } } else diff --git a/source/games/blood/src/sound.cpp b/source/games/blood/src/sound.cpp index 28dae78bb..d3a626cb5 100644 --- a/source/games/blood/src/sound.cpp +++ b/source/games/blood/src/sound.cpp @@ -181,6 +181,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop, else nVolume = 255; } if (bLoop) chanflags |= CHANF_LOOP; + soundEngine->StopActorSounds(SOURCE_None, nullptr, nChannel + 1, nChannel + 1); soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), chanflags, snd, nVolume / 255.f, ATTN_NONE); } }