Fix xpglobes crash on level 99

This commit is contained in:
Pyrethus 2024-02-02 12:16:25 +02:00
parent 70a79c3785
commit 1a3e92c0c3

View file

@ -27,6 +27,10 @@ object XPTable {
var lowIndex = 0 var lowIndex = 0
var highIndex = xpTable.size - 1 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) { while (lowIndex <= highIndex) {
val midIndex = (lowIndex + highIndex) / 2 val midIndex = (lowIndex + highIndex) / 2
when { 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
} }
} }