From 1a3e92c0c3e94065574c0ccd92df4d80ce6fa4e9 Mon Sep 17 00:00:00 2001 From: Pyrethus Date: Fri, 2 Feb 2024 12:16:25 +0200 Subject: [PATCH] Fix xpglobes crash on level 99 --- .../src/main/kotlin/XPGlobesPlugin/XPTable.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt b/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt index ff6ddd41..90cb88ab 100644 --- a/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt +++ b/plugin-playground/src/main/kotlin/XPGlobesPlugin/XPTable.kt @@ -27,6 +27,10 @@ object XPTable { var lowIndex = 0 var highIndex = xpTable.size - 1 + if (xp >= xpTable[highIndex]) { + return Pair(Constants.MAX_LEVEL, xp - xpTable[highIndex]) // Level is max or above, return the highest level + } + while (lowIndex <= highIndex) { val midIndex = (lowIndex + highIndex) / 2 when { @@ -40,6 +44,7 @@ object XPTable { } } - return Pair(Constants.INVALID_LEVEL, 0) // If xp is above all defined levels + return Pair(Constants.INVALID_LEVEL, 0) // If xp is below all defined levels } + }