From 6dd6b79db6655dd1421c2ad9a47d7f5a0a1ba6f1 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:58:48 +1200 Subject: [PATCH] Fix PVS exception (#5196) --- .../GameObjects/EntitySystems/UserInterfaceSystem.cs | 3 +++ Robust.Server/GameStates/PvsSystem.Overrides.cs | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Robust.Server/GameObjects/EntitySystems/UserInterfaceSystem.cs b/Robust.Server/GameObjects/EntitySystems/UserInterfaceSystem.cs index 7780aaed5..9bc5791a6 100644 --- a/Robust.Server/GameObjects/EntitySystems/UserInterfaceSystem.cs +++ b/Robust.Server/GameObjects/EntitySystems/UserInterfaceSystem.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Robust.Server.GameStates; using Robust.Shared.GameObjects; +using Robust.Shared.Utility; namespace Robust.Server.GameObjects; @@ -23,6 +24,8 @@ public sealed class UserInterfaceSystem : SharedUserInterfaceSystem foreach (var ui in buis) { + DebugTools.Assert(ent.Comp.OpenInterfaces[ui].Count > 0); + DebugTools.Assert(HasComp(ui)); args.Entities.Add(ui); } } diff --git a/Robust.Server/GameStates/PvsSystem.Overrides.cs b/Robust.Server/GameStates/PvsSystem.Overrides.cs index 1a0324c49..0b395579b 100644 --- a/Robust.Server/GameStates/PvsSystem.Overrides.cs +++ b/Robust.Server/GameStates/PvsSystem.Overrides.cs @@ -100,7 +100,13 @@ internal sealed partial class PvsSystem /// private bool RecursivelyAddOverride(PvsSession session, EntityUid uid, GameTick fromTick, bool addChildren) { - var xform = _xformQuery.GetComponent(uid); + if (!_xformQuery.TryGetComponent(uid, out var xform)) + { + // Can happen if systems add deleted entities to PVS move event. + Log.Error($"Attempted to add non-existent entity {uid} to PVS override for session {session.Session}"); + return false; + } + var parent = xform.ParentUid; // First we process all parents. This is because while this entity may already have been added