Skip to content

Commit

Permalink
Merge pull request #22 from runetopic/development
Browse files Browse the repository at this point in the history
Add fix to the file decoding.
  • Loading branch information
ultraviolet-jordan authored Oct 26, 2021
2 parents 747c68e + e9f6eda commit 02bb1c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
```

Expand Down
2 changes: 1 addition & 1 deletion cache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
signing
}

version = "1.4.18-SNAPSHOT"
version = "1.4.19-SNAPSHOT"

java {
withJavadocJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,23 @@ internal fun decode(

val groups = hashMapOf<Int, Group>()
(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
))
}
Expand Down Expand Up @@ -206,7 +207,7 @@ internal fun decodeFiles(
groupId: Int
): Map<Int, File> {
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
Expand Down

0 comments on commit 02bb1c7

Please sign in to comment.