From a0332c2f2edd640df3a71f860ace11e4803e47ee Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 24 Mar 2023 13:47:38 +1100 Subject: [PATCH] Don't spawn midi timer for inactive instruments (#14300) --- Content.Client/Instruments/InstrumentSystem.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Client/Instruments/InstrumentSystem.cs b/Content.Client/Instruments/InstrumentSystem.cs index 11ceb36df5..009fa6bcc5 100644 --- a/Content.Client/Instruments/InstrumentSystem.cs +++ b/Content.Client/Instruments/InstrumentSystem.cs @@ -87,7 +87,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem if (!Resolve(uid, ref instrument) || instrument.Renderer == null) return; - instrument.Renderer.TrackingEntity = instrument.Owner; + instrument.Renderer.TrackingEntity = uid; instrument.Renderer.DisablePercussionChannel = !instrument.AllowPercussion; instrument.Renderer.DisableProgramChangeEvent = !instrument.AllowProgramChange; @@ -127,7 +127,9 @@ public sealed class InstrumentSystem : SharedInstrumentSystem // We dispose of the synth two seconds from now to allow the last notes to stop from playing. // Don't use timers bound to the entity in case it is getting deleted. - Timer.Spawn(2000, () => { renderer?.Dispose(); }); + if (renderer != null) + Timer.Spawn(2000, () => { renderer.Dispose(); }); + instrument.Renderer = null; instrument.MidiEventBuffer.Clear(); -- 2.51.2