From fa20f1e11809663a5082376b280d7a320545f7a9 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 25 Dec 2020 19:02:23 +0000 Subject: [PATCH] Fix Js5MasterIndex::create It didn't uncompress the index files before parsing them. Signed-off-by: Graham --- .../kotlin/org/openrs2/cache/Js5MasterIndex.kt | 6 ++++-- .../kotlin/org/openrs2/cache/Js5MasterIndexTest.kt | 8 ++++---- .../org/openrs2/cache/master-index/255/0.dat | Bin 4 -> 9 bytes .../org/openrs2/cache/master-index/255/1.dat | Bin 8 -> 13 bytes .../org/openrs2/cache/master-index/255/3.dat | Bin 8 -> 13 bytes .../org/openrs2/cache/master-index/255/6.dat | Bin 8 -> 13 bytes 6 files changed, 8 insertions(+), 6 deletions(-) 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 a786e127004dd9e94e88fda7742d248237ad8885..8b4eb14584cf6a6e018f4118842e08d5b35d1f8f 100644 GIT binary patch literal 9 OcmZQzU|?Wj1rh)NF#rkx literal 4 LcmZQ&U|;|M02lxU 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 a8c24c5d92e730bbd43118188954e843531d41b4..23d831e44d0b19340e0f917ad7c80472c0847534 100644 GIT binary patch literal 13 ScmZQzU|`^26EX>_05Sjt$pIq( literal 8 PcmZP*G6}0-U|;|M1$+S; 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 540f477942d9a57337d5da5f60844387684640f3..b8ff04cc5faf5f830a2498ef6b4db606bd086c7d 100644 GIT binary patch literal 13 TcmZQzU|`^2o3-cO2Ot9g5jg`h literal 8 PcmZRZwddXk1_lNI5bOgh 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 35a00753a1fa705ca653ddffd10690c3ca29996b..c44e92a33bdc5ee521aa832bc5305c04cbdacfe3 100644 GIT binary patch literal 13 TcmZQzU|`^2TNS!06vzMo3(o=# literal 8 PcmZQu6}l>vfq?-43xWa#