From 2c43930db298791c06c5358269f701812e378cbb Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 May 2021 22:31:53 +0100 Subject: [PATCH] Move Js5Archive and Js5ConfigGroup to cache-550 Signed-off-by: Graham --- archive/build.gradle.kts | 2 +- .../src/main/kotlin/org/openrs2/cache/Js5Archive.kt | 2 +- .../src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt | 0 cache/src/main/kotlin/org/openrs2/cache/Cache.kt | 6 +++--- cache/src/main/kotlin/org/openrs2/cache/CacheArchive.kt | 2 +- cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt | 4 ++-- cache/src/main/kotlin/org/openrs2/cache/Store.kt | 5 +++++ game/build.gradle.kts | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) rename {cache => cache-550}/src/main/kotlin/org/openrs2/cache/Js5Archive.kt (95%) rename {cache => cache-550}/src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt (100%) diff --git a/archive/build.gradle.kts b/archive/build.gradle.kts index 5addd3e0..c20d045e 100644 --- a/archive/build.gradle.kts +++ b/archive/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { api(libs.clikt) implementation(projects.buffer) - implementation(projects.cache) + implementation(projects.cache550) implementation(projects.cli) implementation(projects.db) implementation(projects.http) diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5Archive.kt b/cache-550/src/main/kotlin/org/openrs2/cache/Js5Archive.kt similarity index 95% rename from cache/src/main/kotlin/org/openrs2/cache/Js5Archive.kt rename to cache-550/src/main/kotlin/org/openrs2/cache/Js5Archive.kt index 1a8fa553..a9cc559a 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Js5Archive.kt +++ b/cache-550/src/main/kotlin/org/openrs2/cache/Js5Archive.kt @@ -30,5 +30,5 @@ public object Js5Archive { public const val MATERIALS: Int = 26 public const val CONFIG_PARTICLE: Int = 27 public const val DEFAULTS: Int = 28 - public const val ARCHIVESET: Int = 255 + public const val ARCHIVESET: Int = Store.ARCHIVESET } diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt b/cache-550/src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt similarity index 100% rename from cache/src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt rename to cache-550/src/main/kotlin/org/openrs2/cache/Js5ConfigGroup.kt diff --git a/cache/src/main/kotlin/org/openrs2/cache/Cache.kt b/cache/src/main/kotlin/org/openrs2/cache/Cache.kt index 55b58606..c2d29db4 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Cache.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Cache.kt @@ -23,8 +23,8 @@ public class Cache private constructor( private val unpackedCache = UnpackedCache(unpackedCacheSize) private fun init() { - for (archive in store.list(Js5Archive.ARCHIVESET)) { - val index = store.read(Js5Archive.ARCHIVESET, archive).use { compressed -> + for (archive in store.list(Store.ARCHIVESET)) { + val index = store.read(Store.ARCHIVESET, archive).use { compressed -> Js5Compression.uncompress(compressed).use { buf -> Js5Index.read(buf) } @@ -178,7 +178,7 @@ public class Cache private constructor( unpackedCache.remove(archive) store.remove(archive) - store.remove(Js5Archive.ARCHIVESET, archive) + store.remove(Store.ARCHIVESET, archive) } public fun remove(archive: Int, group: Int) { diff --git a/cache/src/main/kotlin/org/openrs2/cache/CacheArchive.kt b/cache/src/main/kotlin/org/openrs2/cache/CacheArchive.kt index 1eeddb99..13fb8e0a 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/CacheArchive.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/CacheArchive.kt @@ -26,7 +26,7 @@ public class CacheArchive internal constructor( } override fun writePackedIndex(buf: ByteBuf) { - store.write(Js5Archive.ARCHIVESET, archive, buf) + store.write(Store.ARCHIVESET, archive, buf) } override fun removePacked(group: Int) { diff --git a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt b/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt index 33944273..da5838f6 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Js5MasterIndex.kt @@ -121,9 +121,9 @@ public data class Js5MasterIndex( val masterIndex = Js5MasterIndex(MasterIndexFormat.ORIGINAL) var nextArchive = 0 - for (archive in store.list(Js5Archive.ARCHIVESET)) { + for (archive in store.list(Store.ARCHIVESET)) { val entry = try { - store.read(Js5Archive.ARCHIVESET, archive).use { buf -> + store.read(Store.ARCHIVESET, archive).use { buf -> val checksum = buf.crc32() val digest = buf.whirlpool() diff --git a/cache/src/main/kotlin/org/openrs2/cache/Store.kt b/cache/src/main/kotlin/org/openrs2/cache/Store.kt index 463cd277..9724eeb6 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Store.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Store.kt @@ -122,6 +122,11 @@ public interface Store : Flushable, Closeable { */ public const val MAX_GROUP_SIZE: Int = (1 shl 24) - 1 + /** + * The ID of the ARCHIVESET archive. + */ + public const val ARCHIVESET: Int = 255 + /** * Opens a [Store], automatically detecting the type based on the * presence or absence of the `main_file_cache.dat2` file. diff --git a/game/build.gradle.kts b/game/build.gradle.kts index f3439337..2d83a977 100644 --- a/game/build.gradle.kts +++ b/game/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { api(libs.clikt) implementation(projects.buffer) - implementation(projects.cache) + implementation(projects.cache550) implementation(projects.conf) implementation(projects.inject) implementation(projects.net)