Fix Js5MasterIndex::create

It didn't uncompress the index files before parsing them.

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 3cb7ee13f9
commit fa20f1e118
  1. 6
      cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt
  2. 8
      cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt
  3. BIN
      cache/src/test/resources/org/openrs2/cache/master-index/255/0.dat
  4. BIN
      cache/src/test/resources/org/openrs2/cache/master-index/255/1.dat
  5. BIN
      cache/src/test/resources/org/openrs2/cache/master-index/255/3.dat
  6. BIN
      cache/src/test/resources/org/openrs2/cache/master-index/255/6.dat

@ -31,8 +31,10 @@ public inline class Js5MasterIndex(public val entries: MutableList<Entry> = muta
val entry = store.read(Js5Archive.ARCHIVESET, archive).use { buf -> val entry = store.read(Js5Archive.ARCHIVESET, archive).use { buf ->
val checksum = buf.crc32() val checksum = buf.crc32()
val version = Js5Index.read(buf).version val version = Js5Compression.uncompress(buf).use { uncompressed ->
// TODO(gpe): should we throw an exception if there are trailing bytes here? 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) Entry(version, checksum)
} }

@ -27,13 +27,13 @@ object Js5MasterIndexTest {
assertEquals( assertEquals(
Js5MasterIndex( Js5MasterIndex(
mutableListOf( mutableListOf(
Js5MasterIndex.Entry(0, 379203374), Js5MasterIndex.Entry(0, 609698396),
Js5MasterIndex.Entry(0x12345678, -717247318), Js5MasterIndex.Entry(0x12345678, 78747481),
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 0),
Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), 895417101), Js5MasterIndex.Entry(0x9ABCDEF0.toInt(), -456081154),
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 0),
Js5MasterIndex.Entry(0, 0), Js5MasterIndex.Entry(0, 0),
Js5MasterIndex.Entry(0xAA55AA55.toInt(), -627983571) Js5MasterIndex.Entry(0xAA55AA55.toInt(), 186613982)
) )
), index ), index
) )

Loading…
Cancel
Save