From 53996ad82c3ba78fe9e8e0e8b1f46e7501030c6b Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 1 May 2024 20:40:12 -0400 Subject: [PATCH] Possible ArrayIndexOutOfBounds fix --- core/src/mindustry/ai/ControlPathfinder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/ai/ControlPathfinder.java b/core/src/mindustry/ai/ControlPathfinder.java index 01cfb849df..f5ad811409 100644 --- a/core/src/mindustry/ai/ControlPathfinder.java +++ b/core/src/mindustry/ai/ControlPathfinder.java @@ -413,6 +413,7 @@ public class ControlPathfinder implements Runnable{ Cluster[] dim2 = dim1[pathCost]; + //TODO: how can index out of bounds happen? || clusterIndex >= dim2.length if(dim2 == null) return null; return dim2[clusterIndex]; @@ -827,7 +828,7 @@ public class ControlPathfinder implements Runnable{ if(nextCx >= 0 && nextCy >= 0 && nextCx < cwidth && nextCy < cheight){ Cluster nextCluster = getCreateCluster(team, pathCost, nextCx, nextCy); int relativeDir = (dir + 2) % 4; - LongSeq outerCons = nextCluster.portalConnections[relativeDir] == null ? null : nextCluster.portalConnections[relativeDir][portal]; + LongSeq outerCons = nextCluster.portalConnections[relativeDir] == null || nextCluster.portalConnections[relativeDir].length <= portal ? null : nextCluster.portalConnections[relativeDir][portal]; if(outerCons != null){ checkEdges(request, team, pathCost, current, endNodeIndex, nextCx, nextCy, outerCons); } @@ -1075,6 +1076,10 @@ public class ControlPathfinder implements Runnable{ return getPathPosition(unit, destination, destination, out, noResultFound); } + public boolean getPathPosition(Unit unit, Vec2 destination, Vec2 out, @Nullable boolean[] noResultFound){ + return getPathPosition(unit, destination, destination, out, noResultFound); + } + public boolean getPathPosition(Unit unit, Vec2 destination, Vec2 mainDestination, Vec2 out, @Nullable boolean[] noResultFound){ int costId = unit.type.pathCostId; PathCost cost = idToCost(costId);