Fix cardboard box remote control exploits (#14494)
This commit is contained in:
@@ -32,6 +32,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
|
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
|
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||||
|
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||||
|
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(OnDamage);
|
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(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.
|
//Remove the mover after the box is opened and play the effect if it hasn't been played yet.
|
||||||
if (component.Mover != null)
|
if (component.Mover != null)
|
||||||
{
|
{
|
||||||
RemComp<RelayInputMoverComponent>(component.Mover.Value);
|
|
||||||
if (_timing.CurTime > component.EffectCooldown)
|
if (_timing.CurTime > component.EffectCooldown)
|
||||||
{
|
{
|
||||||
RaiseNetworkEvent(new PlayBoxEffectMessage(component.Owner, component.Mover.Value), Filter.PvsExcept(component.Owner));
|
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.
|
// If this box has a stealth/chameleon effect, disable the stealth effect while the box is open.
|
||||||
_stealth.SetEnabled(uid, false);
|
_stealth.SetEnabled(uid, false);
|
||||||
}
|
}
|
||||||
@@ -102,4 +100,17 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
_mover.SetRelay(args.Entity, uid, relay);
|
_mover.SetRelay(args.Entity, uid, relay);
|
||||||
component.Mover = args.Entity;
|
component.Mover = args.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
private void OnEntRemoved(EntityUid uid, CardboardBoxComponent component, EntRemovedFromContainerMessage args)
|
||||||
|
{
|
||||||
|
if (args.Entity != component.Mover)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RemComp<RelayInputMoverComponent>(component.Mover.Value);
|
||||||
|
component.Mover = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user