From 5ea213c9062d39020289fa6102dd0a142ada0c7e Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Fri, 24 Mar 2023 01:09:58 -0400 Subject: [PATCH] Fix cardboard box remote control exploits (#14494) --- .../CardboardBox/CardboardBoxSystem.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Content.Server/CardboardBox/CardboardBoxSystem.cs b/Content.Server/CardboardBox/CardboardBoxSystem.cs index 2cfdf126a1..890ff0f4e2 100644 --- a/Content.Server/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Server/CardboardBox/CardboardBoxSystem.cs @@ -32,6 +32,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem SubscribeLocalEvent(AfterStorageClosed); SubscribeLocalEvent(OnNoHandInteracted); SubscribeLocalEvent(OnEntInserted); + SubscribeLocalEvent(OnEntRemoved); SubscribeLocalEvent(OnDamage); } @@ -50,7 +51,6 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem //Remove the mover after the box is opened and play the effect if it hasn't been played yet. if (component.Mover != null) { - RemComp(component.Mover.Value); if (_timing.CurTime > component.EffectCooldown) { RaiseNetworkEvent(new PlayBoxEffectMessage(component.Owner, component.Mover.Value), Filter.PvsExcept(component.Owner)); @@ -59,8 +59,6 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem } } - component.Mover = null; - // If this box has a stealth/chameleon effect, disable the stealth effect while the box is open. _stealth.SetEnabled(uid, false); } @@ -102,4 +100,17 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem _mover.SetRelay(args.Entity, uid, relay); component.Mover = args.Entity; } + + /// + /// Through e.g. teleporting, it's possible for the mover to exit the box without opening it. + /// Handle those situations but don't play the sound. + /// + private void OnEntRemoved(EntityUid uid, CardboardBoxComponent component, EntRemovedFromContainerMessage args) + { + if (args.Entity != component.Mover) + return; + + RemComp(component.Mover.Value); + component.Mover = null; + } } -- 2.51.2