diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs index 6bdd26e8fe..6db22c59ab 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs @@ -31,11 +31,6 @@ public sealed partial class PathfindingSystem // Probably can't pool polys as there might be old pathfinding refs to them. - private readonly ObjectPool> _neighborPolyPool = - new DefaultObjectPool>(new DefaultPooledObjectPolicy>(), MaxPoolSize); - - private static int MaxPoolSize = Environment.ProcessorCount * 2 * ChunkSize * ChunkSize; - private void InitializeGrid() { SubscribeLocalEvent(OnGridInit); @@ -561,7 +556,7 @@ public sealed partial class PathfindingSystem (Vector2) (poly.TopRight + Vector2i.One) / SubStep + polyOffset); var polyData = points[x * SubStep + poly.Left, y * SubStep + poly.Bottom].Data; - var neighbors = _neighborPolyPool.Get(); + var neighbors = new HashSet(); tilePoly.Add(new PathPoly(grid.GridEntityId, chunk.Origin, GetIndex(x, y), box, polyData, neighbors)); } } @@ -574,7 +569,7 @@ public sealed partial class PathfindingSystem { var index = x * ChunkSize + y; var polys = chunkPolys[index]; - ref var existing = ref chunk.Polygons[index]; + var existing = chunk.Polygons[index]; var isEquivalent = true; @@ -629,13 +624,11 @@ public sealed partial class PathfindingSystem foreach (var neighbor in poly.Neighbors) { neighbor.Neighbors.Remove(poly); - poly.Neighbors.Remove(neighbor); } // If any paths have a ref to it let them know that the class is no longer a valid node. poly.Data.Flags = PathfindingBreadcrumbFlag.Invalid; poly.Neighbors.Clear(); - _neighborPolyPool.Return(poly.Neighbors); } private void BuildNavmesh(GridPathfindingChunk chunk, GridPathfindingComponent component)