diff --git a/README.md b/README.md index ca57297..83b5de7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A cache library written in Kotlin. # Implementation Just use cache if you do not require any of the revision specific loaders. ``` -cache = { module = "com.runetopic.cache:cache", version.ref "1.4.18-SNAPSHOT" } +cache = { module = "com.runetopic.cache:cache", version.ref "1.4.19-SNAPSHOT" } loader = { module = "com.runetopic.cache:loader", version.ref "647.6.4-SNAPSHOT" } ``` diff --git a/cache/build.gradle.kts b/cache/build.gradle.kts index 1b5bf1e..69688bb 100644 --- a/cache/build.gradle.kts +++ b/cache/build.gradle.kts @@ -4,7 +4,7 @@ plugins { signing } -version = "1.4.18-SNAPSHOT" +version = "1.4.19-SNAPSHOT" java { withJavadocJar() diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5IndexDecoder.kt b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5IndexDecoder.kt index eb288ec..47eae44 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5IndexDecoder.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5IndexDecoder.kt @@ -47,22 +47,23 @@ internal fun decode( val groups = hashMapOf() (0 until count).forEach { - val groupReferenceTableData = datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(it)) + val groupId = groupIds[it] + + val groupReferenceTableData = datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(groupId)) val data = if (groupReferenceTableData.isEmpty()) byteArrayOf() else try { groupReferenceTableData.decompress() } catch (exception: ZipException) { groupReferenceTableData } - val groupId = groupIds[it] - groups[it] = (Group( + groups[groupId] = (Group( groupId, groupNameHashes[groupId], groupCrcs[groupId], groupWhirlpools[groupId], groupRevisions[groupId], intArrayOf(),//TODO - decodeFiles(fileIds, fileNameHashes, data, groupFileIds[it], it), + decodeFiles(fileIds, fileNameHashes, data, groupFileIds[groupId], groupId), data )) } @@ -206,7 +207,7 @@ internal fun decodeFiles( groupId: Int ): Map { if (data.isEmpty()) return hashMapOf(Pair(0, File.DEFAULT)) - if (count == 1) return hashMapOf(Pair(0, File(fileIds[groupId][0], fileNameHashes[groupId][0], data))) + if (count <= 1) return hashMapOf(Pair(0, File(fileIds[groupId][0], fileNameHashes[groupId][0], data))) var position = data.size val chunks = data[--position].toInt() and 0xFF