Fix round-summary crash (#19090)

This commit is contained in:
Leon Friedrich
2023-08-14 08:11:12 +12:00
committed by GitHub
parent d842b5e39e
commit 23b8c41a5b

View File

@@ -60,7 +60,7 @@ namespace Content.Server.GameTicking
/// looking naked in the crew manifest. /// looking naked in the crew manifest.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
private List<EntityUid> _expandPvsEntities = new(); private HashSet<EntityUid> _expandPvsEntities = new();
[ViewVariables] [ViewVariables]
private GameRunLevel _runLevel; private GameRunLevel _runLevel;
@@ -86,6 +86,11 @@ namespace Content.Server.GameTicking
SubscribeLocalEvent<ExpandPvsEvent>(OnExpandPvs); SubscribeLocalEvent<ExpandPvsEvent>(OnExpandPvs);
} }
private void OnEntityDeleted(EntityUid uid)
{
_expandPvsEntities.Remove(uid);
}
/// <summary> /// <summary>
/// Returns true if the round's map is eligible to be updated. /// Returns true if the round's map is eligible to be updated.
/// </summary> /// </summary>
@@ -349,6 +354,7 @@ namespace Content.Server.GameTicking
// Should already be empty, but just in case. // Should already be empty, but just in case.
_expandPvsEntities.Clear(); _expandPvsEntities.Clear();
_expandPvsPlayers.Clear(); _expandPvsPlayers.Clear();
EntityManager.EntityDeleted += OnEntityDeleted;
//Generate a list of basic player info to display in the end round summary. //Generate a list of basic player info to display in the end round summary.
var listOfPlayerInfo = new List<RoundEndMessageEvent.RoundEndPlayerInfo>(); var listOfPlayerInfo = new List<RoundEndMessageEvent.RoundEndPlayerInfo>();
@@ -407,7 +413,7 @@ namespace Content.Server.GameTicking
// Recursively collect entities for the crew manifest. // Recursively collect entities for the crew manifest.
void RecursePvsEntities(IEnumerable<EntityUid> entities) void RecursePvsEntities(IEnumerable<EntityUid> entities)
{ {
_expandPvsEntities.AddRange(entities); _expandPvsEntities.UnionWith(entities);
foreach (var entity in entities) foreach (var entity in entities)
{ {
@@ -516,6 +522,7 @@ namespace Content.Server.GameTicking
_allPreviousGameRules.Clear(); _allPreviousGameRules.Clear();
EntityManager.EntityDeleted -= OnEntityDeleted;
_expandPvsPlayers.Clear(); _expandPvsPlayers.Clear();
_expandPvsEntities.Clear(); _expandPvsEntities.Clear();