From f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:06:09 +0200 Subject: fixed errors when path is zero --- src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 9829b4ec9..386fb8bbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -265,6 +265,7 @@ object IslandGraphs { private fun onCurrentPath(): Boolean { val path = fastestPath ?: return false + if (path.isEmpty()) return false val closest = path.nodes.minBy { it.position.distanceSqToPlayer() } val distance = closest.position.distanceToPlayer() if (distance > 7) return false @@ -441,12 +442,14 @@ object IslandGraphs { if (label == "") return val path = fastestPath ?: return var distance = 0.0 - for ((a, b) in path.zipWithNext()) { - distance += a.position.distance(b.position) + if (path.isNotEmpty()) { + for ((a, b) in path.zipWithNext()) { + distance += a.position.distance(b.position) + } + val distanceToPlayer = path.first().position.distanceToPlayer() + distance += distanceToPlayer + distance = distance.roundTo(1) } - val distanceToPlayer = path.first().position.distanceToPlayer() - distance += distanceToPlayer - distance = distance.roundTo(1) if (distance == lastDistance) return lastDistance = distance -- cgit