Prevent follower recursion (#15921)
This commit is contained in:
@@ -65,9 +65,15 @@ public sealed class FollowerSystem : EntitySystem
|
||||
public void StartFollowingEntity(EntityUid follower, EntityUid entity)
|
||||
{
|
||||
// No recursion for you
|
||||
if (Transform(entity).ParentUid == follower)
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user