diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-10-02 18:06:09 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-10-02 18:06:09 +0200 |
commit | f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a (patch) | |
tree | 20f0daa9cc98c82f90743ba29e6937a7bf0c382a /src/main/java/at/hannibal2/skyhanni/data | |
parent | cc3ea04a7534b187673a05151f1f102ff869ce4c (diff) | |
download | skyhanni-f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a.tar.gz skyhanni-f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a.tar.bz2 skyhanni-f8fd5fb7e2e449d9a49bf8982c8acc4549602d9a.zip |
fixed errors when path is zero
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 13 |
1 files changed, 8 insertions, 5 deletions
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 |