Fixed #10346
This commit is contained in:
@@ -343,24 +343,26 @@ public class ControlPathfinder implements Runnable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateTile(Tile tile){
|
public void updateTile(Tile tile){
|
||||||
tile.getLinkedTiles(t -> {
|
tile.getLinkedTiles(this::updateSingleTile);
|
||||||
int x = t.x, y = t.y, mx = x % clusterSize, my = y % clusterSize, cx = x / clusterSize, cy = y / clusterSize, cluster = cx + cy * cwidth;
|
}
|
||||||
|
|
||||||
//is at the edge of a cluster; this means the portals may have changed.
|
public void updateSingleTile(Tile t){
|
||||||
if(mx == 0 || my == 0 || mx == clusterSize - 1 || my == clusterSize - 1){
|
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
|
//is at the edge of a cluster; this means the portals may have changed.
|
||||||
if(my == 0) queueClusterUpdate(cx, cy - 1); //bottom
|
if(mx == 0 || my == 0 || mx == clusterSize - 1 || my == clusterSize - 1){
|
||||||
if(mx == clusterSize - 1) queueClusterUpdate(cx + 1, cy); //right
|
|
||||||
if(my == clusterSize - 1) queueClusterUpdate(cx, cy + 1); //top
|
|
||||||
|
|
||||||
queueClusterUpdate(cx, cy);
|
if(mx == 0) queueClusterUpdate(cx - 1, cy); //left
|
||||||
//TODO: recompute edge clusters too.
|
if(my == 0) queueClusterUpdate(cx, cy - 1); //bottom
|
||||||
}else{
|
if(mx == clusterSize - 1) queueClusterUpdate(cx + 1, cy); //right
|
||||||
//there is no need to recompute portals for block updates that are not on the edge.
|
if(my == clusterSize - 1) queueClusterUpdate(cx, cy + 1); //top
|
||||||
queue.post(() -> clustersToInnerUpdate.add(cluster));
|
|
||||||
}
|
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){
|
void queueClusterUpdate(int cx, int cy){
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
if(build != null){
|
if(build != null){
|
||||||
build.onProximityUpdate();
|
build.onProximityUpdate();
|
||||||
}
|
}
|
||||||
|
pathfinder.updateTile(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEditorTile(){
|
public boolean isEditorTile(){
|
||||||
|
|||||||
Reference in New Issue
Block a user