From 8d8d4029a75093f2a3720743d92ad24d1435d45c Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 12 Oct 2023 19:16:21 +0700 Subject: [PATCH] Fix btree keys not being properly compared --- src/main/kotlin/ru/dbotthepony/kstarbound/io/BTreeDB.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/BTreeDB.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/BTreeDB.kt index bb4c9f40..01d76cc6 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/io/BTreeDB.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/BTreeDB.kt @@ -30,9 +30,9 @@ private operator fun ByteArray.compareTo(b: ByteArray): Int { require(size == b.size) { "Keys are not of same size (${size} vs ${b.size})" } for (i in indices) { - if (this[i] > b[i]) { + if (this[i].toInt() and 0xFF > b[i].toInt() and 0xFF) { return 1 - } else if (this[i] < b[i]) { + } else if (this[i].toInt() and 0xFF < b[i].toInt() and 0xFF) { return -1 } }