From c65cc2ff59f8b4c1d8b0f334a419202b0067d00c Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 25 Sep 2023 10:14:07 +0100 Subject: [PATCH] Allow server_version from jav_config to override build number Signed-off-by: Graham --- .../org/openrs2/archive/cache/CacheDownloader.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt index dbda80c7a0..2aca9e12da 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt @@ -24,7 +24,7 @@ public class CacheDownloader @Inject constructor( val game = gameDatabase.getGame(gameName, environment, language) ?: throw Exception("Game not found") val url = game.url ?: throw Exception("URL not set") - val buildMajor = game.buildMajor ?: throw Exception("Current major build not set") + var buildMajor = game.buildMajor ?: throw Exception("Current major build not set") val config = JavConfig.download(client, url) @@ -56,7 +56,13 @@ public class CacheDownloader @Inject constructor( } "runescape" -> { - val buildMinor = game.buildMinor ?: throw Exception("Current minor build not set") + var buildMinor = game.buildMinor ?: throw Exception("Current minor build not set") + + val serverVersion = config.config[SERVER_VERSION] + if (serverVersion != null) { + buildMajor = serverVersion.toInt() + buildMinor = 1 + } val tokens = config.params.values.filter { TOKEN_REGEX.matches(it) } val token = tokens.singleOrNull() ?: throw Exception("Multiple candidate tokens: $tokens") @@ -101,6 +107,7 @@ public class CacheDownloader @Inject constructor( private companion object { private const val CODEBASE = "codebase" + private const val SERVER_VERSION = "server_version" private const val NXT_LIVE_HOSTNAME = "content.runescape.com" private const val NXT_BETA_HOSTNAME = "content.beta.runescape.com" private const val PORT = 443