aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-10-02 18:06:09 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-10-02 18:06:09 +0200
commitf8fd5fb7e2e449d9a49bf8982c8acc4549602d9a (patch)
tree20f0daa9cc98c82f90743ba29e6937a7bf0c382a /src/main/java/at/hannibal2/skyhanni/data
parentcc3ea04a7534b187673a05151f1f102ff869ce4c (diff)
downloadskyhanni-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.kt13
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