diff --git a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs index 98a8955c7b..e69a31a1d4 100644 --- a/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs +++ b/Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Popups; using Content.Shared.Teleportation.Components; using Content.Shared.Verbs; using Robust.Shared.Audio.Systems; +using Robust.Shared.Containers; using Robust.Shared.Map.Components; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; @@ -20,6 +21,7 @@ public sealed class SwapTeleporterSystem : EntitySystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; @@ -155,6 +157,13 @@ public sealed class SwapTeleporterSystem : EntitySystem var pos = teleEntXform.Coordinates; var otherPos = otherTeleEntXform.Coordinates; + if (_transform.ContainsEntity(teleEnt, (otherTeleEnt, otherTeleEntXform)) || + _transform.ContainsEntity(otherTeleEnt, (teleEnt, teleEntXform))) + { + Log.Error($"Invalid teleport swap attempt between {ToPrettyString(teleEnt)} and {ToPrettyString(otherTeleEnt)}"); + return; + } + _transform.SetCoordinates(teleEnt, otherPos); _transform.SetCoordinates(otherTeleEnt, pos); } @@ -185,6 +194,8 @@ public sealed class SwapTeleporterSystem : EntitySystem private EntityUid GetTeleportingEntity(Entity ent) { var parent = ent.Comp.ParentUid; + if (_container.TryGetOuterContainer(ent, ent, out var container)) + parent = container.Owner; if (HasComp(parent) || HasComp(parent)) return ent;