]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix QSI bringing people into paused maps (#36834)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 24 Apr 2025 21:18:26 +0000 (17:18 -0400)
committerGitHub <noreply@github.com>
Thu, 24 Apr 2025 21:18:26 +0000 (14:18 -0700)
Content.Shared/Teleportation/Systems/SwapTeleporterSystem.cs

index 0fbaefc31bf367caa1c1fb89a925dd356d854b16..69805fd58505110de78c8a2eddc6ca32235d4ff8 100644 (file)
@@ -8,6 +8,7 @@ using Content.Shared.Whitelist;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Containers;
 using Robust.Shared.Map.Components;
+using Robust.Shared.Network;
 using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Timing;
@@ -20,6 +21,7 @@ namespace Content.Shared.Teleportation.Systems;
 public sealed class SwapTeleporterSystem : EntitySystem
 {
     [Dependency] private readonly IGameTiming _timing = default!;
+    [Dependency] private readonly INetManager _net = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
     [Dependency] private readonly SharedContainerSystem _container = default!;
@@ -145,19 +147,16 @@ public sealed class SwapTeleporterSystem : EntitySystem
         comp.TeleportTime = null;
 
         Dirty(uid, comp);
-        if (comp.LinkedEnt is not { } linkedEnt)
-        {
+        // We can't run the teleport logic on the client due to PVS range issues.
+        if (_net.IsClient || comp.LinkedEnt is not { } linkedEnt)
             return;
-        }
 
         var teleEnt = GetTeleportingEntity((uid, xform));
         var otherTeleEnt = GetTeleportingEntity((linkedEnt, Transform(linkedEnt)));
+        var teleXform = Transform(teleEnt);
+        var otherTeleXform = Transform(otherTeleEnt);
 
-        _container.TryGetOuterContainer(teleEnt, Transform(teleEnt), out var cont);
-        _container.TryGetOuterContainer(otherTeleEnt, Transform(otherTeleEnt), out var otherCont);
-
-        if (otherCont != null && !_container.CanInsert(teleEnt, otherCont) ||
-            cont != null && !_container.CanInsert(otherTeleEnt, cont))
+        if (!CanSwapTeleport((teleEnt, teleXform), (otherTeleEnt, otherTeleXform)))
         {
             _popup.PopupEntity(Loc.GetString("swap-teleporter-popup-teleport-fail",
                 ("entity", Identity.Entity(linkedEnt, EntityManager))),
@@ -175,6 +174,26 @@ public sealed class SwapTeleporterSystem : EntitySystem
         _transform.SwapPositions(teleEnt, otherTeleEnt);
     }
 
+    /// <summary>
+    /// Checks if two entities are able to swap positions via the teleporter.
+    /// </summary>
+    private bool CanSwapTeleport(
+        Entity<TransformComponent> entity1,
+        Entity<TransformComponent> entity2)
+    {
+        _container.TryGetOuterContainer(entity1, entity1, out var container1);
+        _container.TryGetOuterContainer(entity2, entity2, out var container2);
+
+        if (container2 != null && !_container.CanInsert(entity1, container2) ||
+            container1 != null && !_container.CanInsert(entity2, container1))
+            return false;
+
+        if (IsPaused(entity1) || IsPaused(entity2))
+            return false;
+
+        return true;
+    }
+
     /// <remarks>
     /// HYAH -link
     /// </remarks>