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())