From a17dea0acf38a46aa0161f0ad33eede8d3a07ebd Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 25 Nov 2024 14:24:49 -0500 Subject: [PATCH] Fixed #10346 --- core/src/mindustry/ai/ControlPathfinder.java | 32 +++++++++++--------- core/src/mindustry/world/Tile.java | 1 + 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/src/mindustry/ai/ControlPathfinder.java b/core/src/mindustry/ai/ControlPathfinder.java index b14dfe8813..ba9e3e6c75 100644 --- a/core/src/mindustry/ai/ControlPathfinder.java +++ b/core/src/mindustry/ai/ControlPathfinder.java @@ -343,24 +343,26 @@ public class ControlPathfinder implements Runnable{ } public void updateTile(Tile tile){ - tile.getLinkedTiles(t -> { - int x = t.x, y = t.y, mx = x % clusterSize, my = y % clusterSize, cx = x / clusterSize, cy = y / clusterSize, cluster = cx + cy * cwidth; + tile.getLinkedTiles(this::updateSingleTile); + } - //is at the edge of a cluster; this means the portals may have changed. - if(mx == 0 || my == 0 || mx == clusterSize - 1 || my == clusterSize - 1){ + public void updateSingleTile(Tile t){ + int x = t.x, y = t.y, mx = x % clusterSize, my = y % clusterSize, cx = x / clusterSize, cy = y / clusterSize, cluster = cx + cy * cwidth; - if(mx == 0) queueClusterUpdate(cx - 1, cy); //left - if(my == 0) queueClusterUpdate(cx, cy - 1); //bottom - if(mx == clusterSize - 1) queueClusterUpdate(cx + 1, cy); //right - if(my == clusterSize - 1) queueClusterUpdate(cx, cy + 1); //top + //is at the edge of a cluster; this means the portals may have changed. + if(mx == 0 || my == 0 || mx == clusterSize - 1 || my == clusterSize - 1){ - queueClusterUpdate(cx, cy); - //TODO: recompute edge clusters too. - }else{ - //there is no need to recompute portals for block updates that are not on the edge. - queue.post(() -> clustersToInnerUpdate.add(cluster)); - } - }); + if(mx == 0) queueClusterUpdate(cx - 1, cy); //left + if(my == 0) queueClusterUpdate(cx, cy - 1); //bottom + if(mx == clusterSize - 1) queueClusterUpdate(cx + 1, cy); //right + if(my == clusterSize - 1) queueClusterUpdate(cx, cy + 1); //top + + queueClusterUpdate(cx, cy); + //TODO: recompute edge clusters too. + }else{ + //there is no need to recompute portals for block updates that are not on the edge. + queue.post(() -> clustersToInnerUpdate.add(cluster)); + } } void queueClusterUpdate(int cx, int cy){ diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 4cd41c2b45..95282758dd 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -293,6 +293,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{ if(build != null){ build.onProximityUpdate(); } + pathfinder.updateTile(this); } public boolean isEditorTile(){