diff --git a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java index 9aa32813..e3700a56 100644 --- a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java +++ b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java @@ -185,9 +185,7 @@ private PathfinderResult executePathing( while (!nodeQueue.isEmpty() && depth.getDepth() <= pathfinderConfiguration.getMaxIterations()) { - if (isAborted()) { - return finishPathing(PathState.ABORTED, fallbackNode); - } + if (isAborted()) return abortedPathing(fallbackNode); Node currentNode = nodeQueue.deleteMin().getValue(); fallbackNode = currentNode; @@ -204,7 +202,7 @@ private PathfinderResult executePathing( start, target, currentNode, depth, nodeQueue, examinedPositions, filters, filterStages); } - aborted = false; + aborted = false; // just in case return backupPathfindingOrFailure(depth, start, target, filters, fallbackNode); } catch (Exception e) { @@ -212,6 +210,11 @@ private PathfinderResult executePathing( } } + private PathfinderResult abortedPathing(Node fallbackNode) { + aborted = false; + return finishPathing(PathState.ABORTED, fallbackNode); + } + private boolean isAborted() { return aborted; }