From 692ca203440d1ad542c654ea8da1c356f1cd8360 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 11 Feb 2021 23:29:21 +0000 Subject: [PATCH] Add processGroup method to Js5ChanneHandler This is consistent with processMasterIndex and processIndex, particularly now that the processGroup logic is slightly more complicated. Signed-off-by: Graham --- .../archive/cache/Js5ChannelHandler.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt index fcbe5ded5a..7c7d2835d7 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt @@ -129,21 +129,7 @@ public class Js5ChannelHandler( } else if (response.archive == Js5Archive.ARCHIVESET) { processIndex(response.group, response.data) } else { - val entry = indexes[response.archive]!![response.group]!! - - if (response.data.crc32() != entry.checksum) { - throw Exception("Group checksum invalid") - } - - val uncompressed = Js5Compression.uncompressUnlessEncrypted(response.data.slice()) - groups += CacheImporter.Group( - response.archive, - response.group, - response.data.retain(), - uncompressed, - entry.version, - versionTruncated = false - ) + processGroup(response.archive, response.group, response.data) } val complete = pendingRequests.isEmpty() && inFlightRequests.isEmpty() @@ -224,6 +210,24 @@ public class Js5ChannelHandler( } } + private fun processGroup(archive: Int, group: Int, buf: ByteBuf) { + val entry = indexes[archive]!![group]!! + + if (buf.crc32() != entry.checksum) { + throw Exception("Group checksum invalid") + } + + val uncompressed = Js5Compression.uncompressUnlessEncrypted(buf.slice()) + groups += CacheImporter.Group( + archive, + group, + buf.retain(), + uncompressed, + entry.version, + versionTruncated = false + ) + } + private fun request(archive: Int, group: Int) { pendingRequests += Js5Request.Group(false, archive, group) }