From 3ff67be9faee4b722a130fbad7c7429778603539 Mon Sep 17 00:00:00 2001 From: Kugamo Date: Wed, 22 Jun 2022 12:33:14 -0500 Subject: [PATCH] Fixes possible runtimers (#18044) whatever did call `stop()` with a valid `remove_thing` and with a nulled `output_atoms` shouldnt happen again. I think it was because I wasnt setting muted, or output_atoms lost its type when all `output_atoms` were removed. --- code/__DEFINES/sound.dm | 2 +- code/datums/looping_sounds/looping_sound.dm | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/__DEFINES/sound.dm b/code/__DEFINES/sound.dm index ba2bb37743f..2654e33644f 100644 --- a/code/__DEFINES/sound.dm +++ b/code/__DEFINES/sound.dm @@ -14,7 +14,7 @@ //THIS SHOULD ALWAYS BE THE LOWEST ONE! //KEEP IT UPDATED -#define CHANNEL_HIGHEST_AVAILABLE 1016 +#define CHANNEL_HIGHEST_AVAILABLE 1015 #define MAX_INSTRUMENT_CHANNELS (128 * 6) diff --git a/code/datums/looping_sounds/looping_sound.dm b/code/datums/looping_sounds/looping_sound.dm index 4a3f1108ffd..2cd87ae81b2 100644 --- a/code/datums/looping_sounds/looping_sound.dm +++ b/code/datums/looping_sounds/looping_sound.dm @@ -52,7 +52,7 @@ /datum/looping_sound/proc/start(atom/add_thing) if(add_thing) - output_atoms |= add_thing + LAZYADD(output_atoms, add_thing) if(!muted) return muted = FALSE @@ -60,8 +60,8 @@ /datum/looping_sound/proc/stop(atom/remove_thing, do_not_mute) if(remove_thing) - output_atoms -= remove_thing - if(do_not_mute) + LAZYREMOVE(output_atoms, remove_thing) + if(do_not_mute && length(output_atoms)) //if there are no output_atoms then we mute regardless of your preferance return if(muted) return @@ -80,8 +80,7 @@ var/sound/S = sound(soundfile) if(direct) S.channel = channel || SSsounds.random_available_channel() - for(var/i in 1 to atoms_cache.len) - var/atom/thing = atoms_cache[i] + for(var/atom/thing in atoms_cache) if(direct) if(ismob(thing)) var/mob/M = thing