]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix multi-ghosts (#22964)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 25 Dec 2023 13:19:12 +0000 (00:19 +1100)
committerGitHub <noreply@github.com>
Mon, 25 Dec 2023 13:19:12 +0000 (00:19 +1100)
* Fix multi-ghosts

* Fix mind visits

Content.Server/Body/Systems/BodySystem.cs
Content.Server/Ghost/GhostSystem.cs
Content.Server/Mind/MindSystem.cs

index 763e53de00b49a57f5040b93f8a95253b0b5db62..351239c73a4fda7e0e8ee6d7a999f98118b4f460 100644 (file)
@@ -15,6 +15,7 @@ using Robust.Shared.Player;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using System.Numerics;
+using Content.Shared.Movement.Systems;
 using Robust.Shared.Audio.Systems;
 
 namespace Content.Server.Body.Systems;
@@ -41,6 +42,13 @@ public sealed class BodySystem : SharedBodySystem
 
     private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
     {
+        // If they haven't actually moved then ignore it.
+        if ((args.Component.HeldMoveButtons &
+             (MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
+        {
+            return;
+        }
+
         if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mindId, out var mind))
         {
             mind.TimeOfDeath ??= _gameTiming.RealTime;
index 9a0b74e2dfa8a2c2aeffcddecf58bb70fb9a662b..acdeca9af00953c37b3f2bd7b4f378906a1c22ae 100644 (file)
@@ -15,6 +15,7 @@ using Content.Shared.Mind.Components;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
 using Content.Shared.Movement.Events;
+using Content.Shared.Movement.Systems;
 using Content.Shared.Storage.Components;
 using Robust.Server.GameObjects;
 using Robust.Server.Player;
@@ -116,6 +117,13 @@ namespace Content.Server.Ghost
 
         private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref MoveInputEvent args)
         {
+            // If they haven't actually moved then ignore it.
+            if ((args.Component.HeldMoveButtons &
+                 (MoveButtons.Down | MoveButtons.Left | MoveButtons.Up | MoveButtons.Right)) == 0x0)
+            {
+                return;
+            }
+
             // Let's not ghost if our mind is visiting...
             if (HasComp<VisitingMindComponent>(uid))
                 return;
index 3039cad25a11a152769950c80e0f5292c199458a..5e84e6c94e95e71c38215ad3756a35cd3cc86de5 100644 (file)
@@ -171,14 +171,17 @@ public sealed class MindSystem : SharedMindSystem
             return;
         }
 
-        if (GetSession(mind) is { } session)
-            _players.SetAttachedEntity(session, entity);
-
         mind.VisitingEntity = entity;
 
         // EnsureComp instead of AddComp to deal with deferred deletions.
         var comp = EnsureComp<VisitingMindComponent>(entity);
         comp.MindId = mindId;
+
+        // Do this AFTER the entity changes above as this will fire off a player-detached event
+        // which will run ghosting twice.
+        if (GetSession(mind) is { } session)
+            _players.SetAttachedEntity(session, entity);
+
         Log.Info($"Session {mind.Session?.Name} visiting entity {entity}.");
     }