Skip to content

Commit 02bb1c7

Browse files
Merge pull request #22 from runetopic/development
Add fix to the file decoding.
2 parents 747c68e + e9f6eda commit 02bb1c7

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A cache library written in Kotlin.
2828
# Implementation
2929
Just use cache if you do not require any of the revision specific loaders.
3030
```
31-
cache = { module = "com.runetopic.cache:cache", version.ref "1.4.18-SNAPSHOT" }
31+
cache = { module = "com.runetopic.cache:cache", version.ref "1.4.19-SNAPSHOT" }
3232
loader = { module = "com.runetopic.cache:loader", version.ref "647.6.4-SNAPSHOT" }
3333
```
3434

cache/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
signing
55
}
66

7-
version = "1.4.18-SNAPSHOT"
7+
version = "1.4.19-SNAPSHOT"
88

99
java {
1010
withJavadocJar()

cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5IndexDecoder.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,23 @@ internal fun decode(
4747

4848
val groups = hashMapOf<Int, Group>()
4949
(0 until count).forEach {
50-
val groupReferenceTableData = datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(it))
50+
val groupId = groupIds[it]
51+
52+
val groupReferenceTableData = datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(groupId))
5153
val data = if (groupReferenceTableData.isEmpty()) byteArrayOf() else try {
5254
groupReferenceTableData.decompress()
5355
} catch (exception: ZipException) {
5456
groupReferenceTableData
5557
}
5658

57-
val groupId = groupIds[it]
58-
groups[it] = (Group(
59+
groups[groupId] = (Group(
5960
groupId,
6061
groupNameHashes[groupId],
6162
groupCrcs[groupId],
6263
groupWhirlpools[groupId],
6364
groupRevisions[groupId],
6465
intArrayOf(),//TODO
65-
decodeFiles(fileIds, fileNameHashes, data, groupFileIds[it], it),
66+
decodeFiles(fileIds, fileNameHashes, data, groupFileIds[groupId], groupId),
6667
data
6768
))
6869
}
@@ -206,7 +207,7 @@ internal fun decodeFiles(
206207
groupId: Int
207208
): Map<Int, File> {
208209
if (data.isEmpty()) return hashMapOf(Pair(0, File.DEFAULT))
209-
if (count == 1) return hashMapOf(Pair(0, File(fileIds[groupId][0], fileNameHashes[groupId][0], data)))
210+
if (count <= 1) return hashMapOf(Pair(0, File(fileIds[groupId][0], fileNameHashes[groupId][0], data)))
210211

211212
var position = data.size
212213
val chunks = data[--position].toInt() and 0xFF

0 commit comments

Comments
 (0)