Skip to content

Commit

Permalink
refact: maxIterationsReached-check
Browse files Browse the repository at this point in the history
was taken from backupPathfindingOrFailure and placed infront.
  • Loading branch information
Metaphoriker committed Sep 3, 2024
1 parent 1547783 commit b541f72
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ private PathfinderResult executePathing(

tick(start, target, currentNode, depth, nodeQueue, examinedPositions, filters);
}
return backupPathfindingOrFailure(depth, start, target, filters, fallbackNode);

Optional<PathfinderResult> maxIterationsResult = maxIterationsReached(depth, fallbackNode);
if (maxIterationsResult.isPresent()) {
return maxIterationsResult.get();
}

return backupPathfindingOrFailure(start, target, filters, fallbackNode);
} catch (Exception e) {
throw ErrorLogger.logFatalErrorWithStacktrace("Failed to find path", e);
}
Expand Down Expand Up @@ -259,16 +265,7 @@ private PathfinderResult resetAbortedAndFinishPathing(PathState pathState, Node

/** If the pathfinder has failed to find a path, it will try to still give a result. */
private PathfinderResult backupPathfindingOrFailure(
Depth depth,
PathPosition start,
PathPosition target,
List<PathFilter> filters,
Node fallbackNode) {

Optional<PathfinderResult> maxIterationsResult = maxIterationsReached(depth, fallbackNode);
if (maxIterationsResult.isPresent()) {
return maxIterationsResult.get();
}
PathPosition start, PathPosition target, List<PathFilter> filters, Node fallbackNode) {

Optional<PathfinderResult> counterCheckResult = counterCheck(start, target, filters);
if (counterCheckResult.isPresent()) {
Expand Down

0 comments on commit b541f72

Please sign in to comment.