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