# HG changeset patch # User Adam Kaminski # Date 1625852632 14400 # Fri Jul 09 13:43:52 2021 -0400 # Node ID f7dd765a9675dc97ae837bf8810cc198a412e483 # Parent eb90011ecb6022b24be2a9bf69692dd12da05bb7 Added the function S_StopAllUnattachedSounds to stop all positioned or unattached sounds that are still playing. diff -r eb90011ecb60 -r f7dd765a9675 src/s_sound.cpp --- a/src/s_sound.cpp Fri Jul 09 11:43:56 2021 -0400 +++ b/src/s_sound.cpp Fri Jul 09 13:43:52 2021 -0400 @@ -1675,6 +1675,28 @@ //========================================================================== // +// [AK] S_StopAllUnattachedSounds +// +// Stops all positioned or unattached sounds that are still playing. +//========================================================================== + +void S_StopAllUnattachedSounds () +{ + FSoundChan *chan = Channels; + while (chan != NULL) + { + FSoundChan *next = chan->NextChan; + if ((chan->SourceType == SOURCE_None) || (chan->SourceType == SOURCE_Unattached)) + { + S_StopChannel(chan); + } + + chan = next; + } +} + +//========================================================================== +// // S_RelinkSound // // Moves all the sounds from one thing to another. If the destination is diff -r eb90011ecb60 -r f7dd765a9675 src/s_sound.h --- a/src/s_sound.h Fri Jul 09 11:43:56 2021 -0400 +++ b/src/s_sound.h Fri Jul 09 13:43:52 2021 -0400 @@ -303,6 +303,9 @@ // [BB] Stop sound of an actor for all channels void S_StopAllSoundsFromActor (AActor *ent); +// [AK] Stops all positioned or unattached sounds. +void S_StopAllUnattachedSounds (void); + // Is the sound playing on one of the emitter's channels? bool S_GetSoundPlayingInfo (const AActor *actor, int sound_id); bool S_GetSoundPlayingInfo (const sector_t *sector, int sound_id);