Fix ghost following bug (#19035)

This commit is contained in:
Leon Friedrich
2023-08-13 13:21:42 +12:00
committed by GitHub
parent 175660c800
commit 7fd9d4fa4f

View File

@@ -10,6 +10,7 @@ using Content.Shared.Verbs;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Events; using Robust.Shared.Map.Events;
using Robust.Shared.Network;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
@@ -23,6 +24,7 @@ public sealed class FollowerSystem : EntitySystem
[Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedJointSystem _jointSystem = default!; [Dependency] private readonly SharedJointSystem _jointSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
[Dependency] private readonly INetManager _netMan = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -188,16 +190,22 @@ public sealed class FollowerSystem : EntitySystem
RaiseLocalEvent(uid, uidEv); RaiseLocalEvent(uid, uidEv);
RaiseLocalEvent(target, targetEv); RaiseLocalEvent(target, targetEv);
if (!Deleted(uid) && deparent) if (!deparent || !TryComp(uid, out TransformComponent? xform))
{ return;
var xform = Transform(uid);
_transform.AttachToGridOrMap(uid, xform); _transform.AttachToGridOrMap(uid, xform);
if (xform.MapUid == null) if (xform.MapUid != null)
return;
if (_netMan.IsClient)
{ {
_transform.DetachParentToNull(uid, xform);
return;
}
Log.Warning($"A follower has been detached to null-space and will be deleted. Follower: {ToPrettyString(uid)}. Followed: {ToPrettyString(target)}");
QueueDel(uid); QueueDel(uid);
} }
}
}
/// <summary> /// <summary>
/// Forces all of an entity's followers to stop following it. /// Forces all of an entity's followers to stop following it.