]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
patch QSI container issues (#25700)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 3 Mar 2024 06:45:26 +0000 (01:45 -0500)
committerGitHub <noreply@github.com>
Sun, 3 Mar 2024 06:45:26 +0000 (17:45 +1100)
* patch QSI exception

* fuck don't die

Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs

index 98a8955c7bc1003c970af82b748d36b284e7166a..e69a31a1d406e7be2e1a7975d19a1266efd4700b 100644 (file)
@@ -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<TransformComponent> ent)
     {
         var parent = ent.Comp.ParentUid;
+        if (_container.TryGetOuterContainer(ent, ent, out var container))
+            parent = container.Owner;
 
         if (HasComp<MapGridComponent>(parent) || HasComp<MapComponent>(parent))
             return ent;