]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix followers leaking (#20643)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 1 Oct 2023 14:25:06 +0000 (01:25 +1100)
committerGitHub <noreply@github.com>
Sun, 1 Oct 2023 14:25:06 +0000 (10:25 -0400)
Content.Shared/Follower/FollowerSystem.cs

index 339136ffe81ac764315e67f4e5937097c95ab071..38c0e5ada3f52b019f0e65049c7ee89a214f5782 100644 (file)
@@ -33,6 +33,8 @@ public sealed class FollowerSystem : EntitySystem
         SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
         SubscribeLocalEvent<FollowerComponent, MoveInputEvent>(OnFollowerMove);
         SubscribeLocalEvent<FollowerComponent, PullStartedMessage>(OnPullStarted);
+        SubscribeLocalEvent<FollowerComponent, EntityTerminatingEvent>(OnFollowerTerminating);
+
         SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
         SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
         SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
@@ -107,6 +109,11 @@ public sealed class FollowerSystem : EntitySystem
         StopFollowingEntity(uid, component.Following, deparent:false);
     }
 
+    private void OnFollowerTerminating(EntityUid uid, FollowerComponent component, ref EntityTerminatingEvent args)
+    {
+        StopFollowingEntity(uid, component.Following, deparent: false);
+    }
+
     // Since we parent our observer to the followed entity, we need to detach
     // before they get deleted so that we don't get recursively deleted too.
     private void OnFollowedTerminating(EntityUid uid, FollowedComponent component, ref EntityTerminatingEvent args)
@@ -186,7 +193,7 @@ public sealed class FollowerSystem : EntitySystem
 
         RaiseLocalEvent(uid, uidEv, true);
         RaiseLocalEvent(target, targetEv, false);
-        Dirty(followed);
+        Dirty(target, followed);
         RaiseLocalEvent(uid, uidEv);
         RaiseLocalEvent(target, targetEv);