From 84aa5955d0b5c0233fa71e5ff90e7fb6556b76f9 Mon Sep 17 00:00:00 2001 From: Ryan Krafnick Date: Sun, 4 Dec 2022 23:35:13 +0100 Subject: [PATCH] Fix plat infinite sound loop (#825) --- src/p_plats.c | 1 + src/s_sound.c | 21 +++++++++++++++++++++ src/s_sound.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/p_plats.c b/src/p_plats.c index 23bba963..6a91c79f 100644 --- a/src/p_plats.c +++ b/src/p_plats.c @@ -368,6 +368,7 @@ int EV_StopPlat(line_t* line) plat_t *plat = pl->plat; // for one with the tag not in stasis if (plat->status != in_stasis && plat->tag == line->tag) { + S_StopLoop((mobj_t *)&plat->sector->soundorg); plat->oldstatus = plat->status; // put it in stasis plat->status = in_stasis; plat->thinker.function.v = NULL; diff --git a/src/s_sound.c b/src/s_sound.c index f98369e0..f7a5e199 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -488,6 +488,27 @@ void S_StopSound(const mobj_t *origin) } } +// +// S_StopLoop +// +void S_StopLoop(const mobj_t *origin) +{ + int cnum; + + //jff 1/22/98 return if sound is not enabled + if(nosfxparm) + return; + + for(cnum = 0; cnum < numChannels; ++cnum) + { + if(channels[cnum].sfxinfo && channels[cnum].origin == origin && channels[cnum].loop) + { + S_StopChannel(cnum); + break; + } + } +} + // [FG] play sounds in full length boolean full_sounds; // [FG] removed map objects may finish their sounds diff --git a/src/s_sound.h b/src/s_sound.h index c5ec226c..bb2ef7ce 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -54,6 +54,7 @@ void S_LoopSound(const mobj_t *origin, int sound_id); // Stop sound for thing at void S_StopSound(const mobj_t *origin); +void S_StopLoop(const mobj_t *origin); void S_StopLoopSounds(void); // [FG] play sounds in full length