From e303ac4a034aa45e8cf2f2b8c98aa96df558dfce Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 24 Apr 2022 14:09:44 -0400 Subject: [PATCH] fix list updating exception --- .../game/server/pathfinding/NavMeshUtils.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/electrosphere/game/server/pathfinding/NavMeshUtils.java b/src/main/java/electrosphere/game/server/pathfinding/NavMeshUtils.java index 01246008..c7d87095 100644 --- a/src/main/java/electrosphere/game/server/pathfinding/NavMeshUtils.java +++ b/src/main/java/electrosphere/game/server/pathfinding/NavMeshUtils.java @@ -128,15 +128,19 @@ public class NavMeshUtils { // ); toRemove.clear(); //TODO: iterate this backwards and check for x adjacency, if no adjacency end loop early + List neighborUpdateList = new LinkedList(); for(SecondPhaseBox interim : secondPhaseBoxes){ if(firstPhaseBox.yStart == interim.boundMinY && firstPhaseBox.yEnd == interim.boundMaxY && firstPhaseBox.x == interim.boundMaxX){ for(SecondPhaseBox neighbor : interim.getNeighbors()){ - neighbor.removeNeighbor(interim); - interim.removeNeighbor(neighbor); - neighbor.addNeighbor(newBox); - newBox.addNeighbor(neighbor); + neighborUpdateList.add(neighbor); // System.out.println("ADD NEIGHBOR: " + neighbor.boundMaxX + " " + neighbor.boundMaxY + " " + neighbor.boundMinX + " " + neighbor.boundMinY); } + for(SecondPhaseBox update : neighborUpdateList){ + update.removeNeighbor(interim); + interim.removeNeighbor(update); + update.addNeighbor(newBox); + newBox.addNeighbor(update); + } toRemove.add(interim); newBox.setBoundMinX(interim.getBoundMinX()); //TODO: calculate new min/max height