From b8081a335ace8dd463b24c567c701cf2df451bfc Mon Sep 17 00:00:00 2001
From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Date: Mon, 1 May 2023 16:11:51 +1200
Subject: [PATCH] Fix queued deletion error log (#3982)
---
Robust.Client/GameObjects/ClientEntityManager.cs | 6 +++++-
Robust.Shared/GameObjects/EntityManager.cs | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Robust.Client/GameObjects/ClientEntityManager.cs b/Robust.Client/GameObjects/ClientEntityManager.cs
index 652514235..00df4cb9b 100644
--- a/Robust.Client/GameObjects/ClientEntityManager.cs
+++ b/Robust.Client/GameObjects/ClientEntityManager.cs
@@ -72,8 +72,12 @@ namespace Robust.Client.GameObjects
return;
}
+ if (ShuttingDown)
+ return;
+
// Client-side entity deletion is not supported and will cause errors.
- Logger.Error($"Predicting the queued deletion of a networked entity: {ToPrettyString(uid)}. Trace: {Environment.StackTrace}");
+ if (_client.RunLevel == ClientRunLevel.Connected || _client.RunLevel == ClientRunLevel.InGame)
+ Logger.Error($"Predicting the queued deletion of a networked entity: {ToPrettyString(uid)}. Trace: {Environment.StackTrace}");
}
///
diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs
index 5ff64054f..a29b14ed8 100644
--- a/Robust.Shared/GameObjects/EntityManager.cs
+++ b/Robust.Shared/GameObjects/EntityManager.cs
@@ -70,6 +70,9 @@ namespace Robust.Shared.GameObjects
public event Action? EntityDirtied; // only raised after initialization
public bool Started { get; protected set; }
+
+ public bool ShuttingDown { get; protected set; }
+
public bool Initialized { get; protected set; }
///
@@ -107,10 +110,12 @@ namespace Robust.Shared.GameObjects
public virtual void Shutdown()
{
+ ShuttingDown = true;
FlushEntities();
_eventBus.ClearEventTables();
_entitySystemManager.Shutdown();
ClearComponents();
+ ShuttingDown = false;
Started = false;
}
@@ -118,12 +123,14 @@ namespace Robust.Shared.GameObjects
{
_componentFactory.ComponentAdded -= OnComponentAdded;
_componentFactory.ComponentReferenceAdded -= OnComponentReferenceAdded;
+ ShuttingDown = true;
FlushEntities();
_entitySystemManager.Clear();
_eventBus.Dispose();
_eventBus = null!;
ClearComponents();
+ ShuttingDown = false;
Initialized = false;
Started = false;
}