Skip to content

Commit

Permalink
Fix second pass bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Dec 17, 2024
1 parent 95fb503 commit a9e336b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/appeng/me/pathfinding/PathingCalculation.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,14 @@ private boolean tryUseChannel(GridNode start) {
* Propagates assignment to all nodes by performing a DFS. The implementation is iterative to avoid stack overflow.
*/
private void propagateAssignments() {
visited.clear();
List<Object> stack = new ArrayList<>();
Set<IPathItem> controllerNodes = new HashSet<>();

for (var node : grid.getMachineNodes(ControllerBlockEntity.class)) {
visited.add((IPathItem) node);
controllerNodes.add((IPathItem) node);
for (var gcc : node.getConnections()) {
var gc = (GridConnection) gcc;
if (!(gc.getOtherSide(node).getOwner() instanceof ControllerBlockEntity)) {
visited.add(gc);
stack.add(gc);
}
}
Expand All @@ -239,7 +238,10 @@ private void propagateAssignments() {
} else {
stack.add(SUBTREE_END);
for (var pi : ((IPathItem) current).getPossibleOptions()) {
if (visited.add(pi)) {
// The neighbor could either be: a child, the parent, or in a different tree if it is closer to
// another controller. It is a child if we are its parent.
// We need to exclude controller nodes because their getControllerRoute() is nonsense.
if (!controllerNodes.contains(pi) && pi.getControllerRoute() == current) {
stack.add(pi);
}
}
Expand Down

0 comments on commit a9e336b

Please sign in to comment.