From 23b8c41a5becce20ca5e487e263785e3daa52921 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 14 Aug 2023 08:11:12 +1200 Subject: [PATCH] Fix round-summary crash (#19090) --- Content.Server/GameTicking/GameTicker.RoundFlow.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index a3efaff9b9..47fded14c9 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -60,7 +60,7 @@ namespace Content.Server.GameTicking /// looking naked in the crew manifest. /// [ViewVariables] - private List _expandPvsEntities = new(); + private HashSet _expandPvsEntities = new(); [ViewVariables] private GameRunLevel _runLevel; @@ -86,6 +86,11 @@ namespace Content.Server.GameTicking SubscribeLocalEvent(OnExpandPvs); } + private void OnEntityDeleted(EntityUid uid) + { + _expandPvsEntities.Remove(uid); + } + /// /// Returns true if the round's map is eligible to be updated. /// @@ -349,6 +354,7 @@ namespace Content.Server.GameTicking // Should already be empty, but just in case. _expandPvsEntities.Clear(); _expandPvsPlayers.Clear(); + EntityManager.EntityDeleted += OnEntityDeleted; //Generate a list of basic player info to display in the end round summary. var listOfPlayerInfo = new List(); @@ -407,7 +413,7 @@ namespace Content.Server.GameTicking // Recursively collect entities for the crew manifest. void RecursePvsEntities(IEnumerable entities) { - _expandPvsEntities.AddRange(entities); + _expandPvsEntities.UnionWith(entities); foreach (var entity in entities) { @@ -516,6 +522,7 @@ namespace Content.Server.GameTicking _allPreviousGameRules.Clear(); + EntityManager.EntityDeleted -= OnEntityDeleted; _expandPvsPlayers.Clear(); _expandPvsEntities.Clear();