diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt index f33cded2..2d384d1f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/entities/PathFinder.kt @@ -645,7 +645,7 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d // release memory associated with structures openNodes = PriorityQueue() closedNodes = HashSet() - closest = Node(roundToNode(start)) + // closest = Node(roundToNode(start)) } init { @@ -691,7 +691,11 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d LOGGER.warn("Path finder tried to consider more than 40000 nodes (goal $goal, closest take $closest, distance ${closest.position.distance(goal)}, onGround ${onGround(closest.position)})") if (!canContinue()) { - result = KOptional(null as List?) + if (parameters.returnBest) { + result = KOptional(closest.reconstructPath()) + } else { + result = KOptional(null as List?) + } } if (result.isPresent)