From db07b48eb133cce6e5ef4778cb9e2b692ae87dd9 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:09:55 +0000 Subject: [PATCH] Fix Organs causing PVS Reload. (#45958) Race condition :P --- Content.Shared/Body/OrganRelationSystem.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Body/OrganRelationSystem.cs b/Content.Shared/Body/OrganRelationSystem.cs index d5236277e8..ac727151a4 100644 --- a/Content.Shared/Body/OrganRelationSystem.cs +++ b/Content.Shared/Body/OrganRelationSystem.cs @@ -18,10 +18,10 @@ public sealed partial class OrganRelationSystem : EntitySystem private void OnChildShutdown(Entity ent, ref ComponentShutdown args) { - if (ent.Comp.Parent is not { } parentUid) + // Parent shut down before the child. + if (ent.Comp.Parent is not { } parentUid || !_parent.TryComp(parentUid, out var parentComp)) return; - var parentComp = _parent.Comp(parentUid); parentComp.Children.Remove(ent); Dirty(parentUid, parentComp); } @@ -33,9 +33,11 @@ public sealed partial class OrganRelationSystem : EntitySystem foreach (var childUid in ent.Comp.Children) { - var childComp = _child.Comp(childUid); - childComp.Parent = null; + // Child shut down before the parent. + if (!_child.TryComp(childUid, out var childComp)) + continue; + childComp.Parent = null; Dirty(childUid, childComp); } }