]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Prevent follower recursion (#15921)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sun, 30 Apr 2023 01:44:14 +0000 (13:44 +1200)
committerGitHub <noreply@github.com>
Sun, 30 Apr 2023 01:44:14 +0000 (11:44 +1000)
Content.Shared/Follower/FollowerSystem.cs

index 1493ce444545accfe09f3cd6b5d7cc8745e83f5a..9547cca0ce86c3a3591df3a16123b2abf15a46a3 100644 (file)
@@ -65,8 +65,14 @@ public sealed class FollowerSystem : EntitySystem
     public void StartFollowingEntity(EntityUid follower, EntityUid entity)
     {
         // No recursion for you
-        if (Transform(entity).ParentUid == follower)
-            return;
+        var targetXform = Transform(entity);
+        while (targetXform.ParentUid.IsValid())
+        {
+            if (targetXform.ParentUid == follower)
+                return;
+
+            targetXform = Transform(targetXform.ParentUid);
+        }
 
         var followerComp = EnsureComp<FollowerComponent>(follower);
         followerComp.Following = entity;