From 4cb96dba6d1f8219e7ede831813b2a55a346ace7 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 2 Nov 2022 12:12:50 +1100 Subject: [PATCH] Clear path on exception (#12335) Should hopefully avoid it spamming in future. --- .../NPC/Pathfinding/PathfindingSystem.cs | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs index 1392da58b8..fccce2e65f 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs @@ -93,16 +93,24 @@ namespace Content.Server.NPC.Pathfinding var request = _pathRequests[i]; - switch (request) + try { - case AStarPathRequest astar: - results[i] = UpdateAStarPath(astar); - break; - case BFSPathRequest bfs: - results[i] = UpdateBFSPath(_random, bfs); - break; - default: - throw new NotImplementedException(); + switch (request) + { + case AStarPathRequest astar: + results[i] = UpdateAStarPath(astar); + break; + case BFSPathRequest bfs: + results[i] = UpdateBFSPath(_random, bfs); + break; + default: + throw new NotImplementedException(); + } + } + catch (Exception) + { + results[i] = PathResult.NoPath; + throw; } }); @@ -123,6 +131,7 @@ namespace Content.Server.NPC.Pathfinding switch (result) { case PathResult.Continuing: + DebugTools.Assert(path.Frontier.Count > 0); break; case PathResult.PartialPath: case PathResult.Path: