From 3c157a4f2c42eb5b55029198982792589c5e71a8 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 10 Dec 2019 11:40:32 +0200 Subject: [PATCH] - restored stopping of channel by new sound If source actor/sector/polyobject is playing something on the selected channel, stop it before playing a new sound https://forum.zdoom.org/viewtopic.php?t=66613 --- src/sound/s_sound.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 2a38d8592..f74ecef82 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -528,10 +528,27 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, { if (chan->SourceType == type && chan->EntChannel == channel) { - if (type != SOURCE_Unattached) chan->Source = source; - else + bool foundit; + + switch (type) { - chan->Point[0] == pt->X && chan->Point[2] == pt->Z && chan->Point[1] == pt->Y; + case SOURCE_Actor: + case SOURCE_Sector: + case SOURCE_Polyobj: + foundit = chan->Source == source; + break; + case SOURCE_Unattached: + foundit = chan->Point[0] == pt->X && chan->Point[2] == pt->Z && chan->Point[1] == pt->Y; + break; + default: + foundit = false; + break; + } + + if (foundit) + { + StopChannel(chan); + break; } } }