diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt b/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt index 8107dc94..30a0b09b 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt @@ -31,8 +31,10 @@ public inline class Js5MasterIndex(public val entries: MutableList = muta val entry = store.read(Js5Archive.ARCHIVESET, archive).use { buf -> val checksum = buf.crc32() - val version = Js5Index.read(buf).version - // TODO(gpe): should we throw an exception if there are trailing bytes here? + val version = Js5Compression.uncompress(buf).use { uncompressed -> + Js5Index.read(uncompressed).version + } + // TODO(gpe): should we throw an exception if there are trailing bytes here or in the block above? Entry(version, checksum) } diff --git a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt index 443cbb43..39b99e43 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt @@ -27,13 +27,13 @@ object Js5MasterIndexTest { assertEquals( Js5MasterIndex( mutableListOf( - Js5MasterIndex.Entry(0, 379203374), - Js5MasterIndex.Entry(0x12345678, -717247318), + Js5MasterIndex.Entry(0, 609698396), + Js5MasterIndex.Entry(0x12345678, 78747481), Js5MasterIndex.Entry(0, 0), - Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), 895417101), + Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), -456081154), Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 0), - Js5MasterIndex.Entry(0xAA55AA55.toInt(), -627983571) + Js5MasterIndex.Entry(0xAA55AA55.toInt(), 186613982) ) ), index ) diff --git a/cache/src/test/resources/org/openrs2/cache/master-index/255/0.dat b/cache/src/test/resources/org/openrs2/cache/master-index/255/0.dat index a786e127..8b4eb145 100644 Binary files a/cache/src/test/resources/org/openrs2/cache/master-index/255/0.dat and b/cache/src/test/resources/org/openrs2/cache/master-index/255/0.dat differ diff --git a/cache/src/test/resources/org/openrs2/cache/master-index/255/1.dat b/cache/src/test/resources/org/openrs2/cache/master-index/255/1.dat index a8c24c5d..23d831e4 100644 Binary files a/cache/src/test/resources/org/openrs2/cache/master-index/255/1.dat and b/cache/src/test/resources/org/openrs2/cache/master-index/255/1.dat differ diff --git a/cache/src/test/resources/org/openrs2/cache/master-index/255/3.dat b/cache/src/test/resources/org/openrs2/cache/master-index/255/3.dat index 540f4779..b8ff04cc 100644 Binary files a/cache/src/test/resources/org/openrs2/cache/master-index/255/3.dat and b/cache/src/test/resources/org/openrs2/cache/master-index/255/3.dat differ diff --git a/cache/src/test/resources/org/openrs2/cache/master-index/255/6.dat b/cache/src/test/resources/org/openrs2/cache/master-index/255/6.dat index 35a00753..c44e92a3 100644 Binary files a/cache/src/test/resources/org/openrs2/cache/master-index/255/6.dat and b/cache/src/test/resources/org/openrs2/cache/master-index/255/6.dat differ