瀏覽代碼

Fixing cell pathfinding
We should have not increment the iterator when a loc was removed.

Reported by: maneco2, Dimisgr
http://www.l2jserver.com/forum/viewtopic.php?f=89&p=186465#p186465

p3110145 10 年之前
父節點
當前提交
1e5f63c2af
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      L2J_Server/java/com/l2jserver/gameserver/pathfinding/cellnodes/CellPathFinding.java

+ 5 - 3
L2J_Server/java/com/l2jserver/gameserver/pathfinding/cellnodes/CellPathFinding.java

@@ -199,13 +199,14 @@ public class CellPathFinding extends PathFinding
 			int currentY = y;
 			int currentZ = z;
 			
-			for (int i = 0; i < path.size() - 1; i++)
+			int midPoint = 0;
+			while (endPoint.hasNext())
 			{
-				AbstractNodeLoc locMiddle = path.get(i);
+				AbstractNodeLoc locMiddle = path.get(midPoint);
 				AbstractNodeLoc locEnd = endPoint.next();
 				if (GeoData.getInstance().canMove(currentX, currentY, currentZ, locEnd.getX(), locEnd.getY(), locEnd.getZ(), instanceId))
 				{
-					path.remove(i);
+					path.remove(midPoint);
 					remove = true;
 					if (debug)
 					{
@@ -217,6 +218,7 @@ public class CellPathFinding extends PathFinding
 					currentX = locMiddle.getX();
 					currentY = locMiddle.getY();
 					currentZ = locMiddle.getZ();
+					midPoint++;
 				}
 			}
 		}