From b0a18ebc5bdb956fe20e66cb5b40665b817bc114 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 26 Aug 2020 00:44:23 +1000 Subject: [PATCH] Fix AiReachable crash (#1913) This system haunts my nightmares and I'm gonna refactor it before release. Co-authored-by: Metal Gear Sloth --- .../AI/Pathfinding/Accessible/AiReachableSystem.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index 3470365282..4f866d3348 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -130,6 +130,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible _regions.Clear(); _cachedAccessible.Clear(); _queuedCacheDeletions.Clear(); + _mapManager.OnGridRemoved -= GridRemoved; } public void ResettingCleanup() @@ -626,6 +627,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// private void GenerateRegions(PathfindingChunk chunk) { + // Grid deleted while update queued. + if (!_mapManager.TryGetGrid(chunk.GridId, out _)) + { + return; + } + if (!_regions.ContainsKey(chunk.GridId)) { _regions.Add(chunk.GridId, new Dictionary>());