From 41c8e382a4da56db4e7f2875cc4d527d734fa7ed Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 1 Nov 2022 22:50:35 +1100 Subject: [PATCH] Hotfix path empty frontier issue (#12334) --- Content.Server/NPC/Pathfinding/PathfindingSystem.AStar.cs | 6 ++++++ Content.Server/NPC/Pathfinding/PathfindingSystem.BFS.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.AStar.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.AStar.cs index 366fd8133f..2bc4c60a3c 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.AStar.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.AStar.cs @@ -30,6 +30,12 @@ public sealed partial class PathfindingSystem // Re-validate nodes else { + // Theoretically this shouldn't be happening, but practically... + if (request.Frontier.Count == 0) + { + return PathResult.NoPath; + } + (_, currentNode) = request.Frontier.Peek(); if (!currentNode.IsValid()) diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.BFS.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.BFS.cs index cde593d5a7..3968952965 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.BFS.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.BFS.cs @@ -25,6 +25,12 @@ public sealed partial class PathfindingSystem // Re-validate nodes else { + // Theoretically this shouldn't be happening, but practically... + if (request.Frontier.Count == 0) + { + return PathResult.NoPath; + } + (_, currentNode) = request.Frontier.Peek(); if (!currentNode.IsValid())