diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt index 5d7526d4..32b0ad62 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt @@ -15,30 +15,40 @@ public class KeyExporter @Inject constructor( val allKeys: Long, val validKeys: Long, val encryptedGroups: Long, - val validGroups: Long + val validGroups: Long, + val emptyGroups: Long ) { val validKeysFraction: Double = if (allKeys == 0L) { 1.0 } else { validKeys.toDouble() / allKeys } + val validGroupsFraction: Double = if (encryptedGroups == 0L) { 1.0 } else { validGroups.toDouble() / encryptedGroups } + + val emptyGroupsFraction: Double = if (encryptedGroups == 0L) { + 1.0 + } else { + emptyGroups.toDouble() / encryptedGroups + } } public suspend fun count(): Stats { return database.execute { connection -> val encryptedGroups: Long val validGroups: Long + val emptyGroups: Long connection.prepareStatement( """ SELECT COUNT(*), - COUNT(*) FILTER (WHERE c.key_id IS NOT NULL) + COUNT(*) FILTER (WHERE c.key_id IS NOT NULL), + COUNT(*) FILTER (WHERE c.key_id IS NULL AND c.empty_loc) FROM containers c WHERE c.encrypted """.trimIndent() @@ -48,6 +58,7 @@ public class KeyExporter @Inject constructor( encryptedGroups = rows.getLong(1) validGroups = rows.getLong(2) + emptyGroups = rows.getLong(3) } } @@ -65,7 +76,7 @@ public class KeyExporter @Inject constructor( val allKeys = rows.getLong(1) val validKeys = rows.getLong(2) - Stats(allKeys, validKeys, encryptedGroups, validGroups) + Stats(allKeys, validKeys, encryptedGroups, validGroups, emptyGroups) } } } diff --git a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql index b121b836..4c82aa2b 100644 --- a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql +++ b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql @@ -238,7 +238,7 @@ LEFT JOIN ( i.master_index_id, COUNT(*) FILTER (WHERE c.id IS NOT NULL) AS valid_groups, COUNT(*) AS groups, - COUNT(*) FILTER (WHERE c.key_id IS NOT NULL) AS valid_keys, + COUNT(*) FILTER (WHERE c.encrypted AND (c.key_id IS NOT NULL OR c.empty_loc)) AS valid_keys, COUNT(*) FILTER (WHERE c.encrypted) AS keys, SUM(length(c.data)) FILTER (WHERE c.id IS NOT NULL) AS size FROM resolved_indexes i diff --git a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html index 080bb25b..55b92885 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html @@ -21,7 +21,7 @@ Source(s) Indexes Groups - Keys + Keys1 Links @@ -95,6 +95,18 @@ +

+ 1 Map squares in the middle of the + sea are unreachable by normal players, making it impossible to + obtain the keys for their loc groups. However, the loc groups + for these map squares are empty. As XTEA does not hide the + length of the compressed data, this service infers which + encrypted loc groups are empty and includes them in the number + of valid keys, regardless of whether the key is known or not. + After downloading a cache from this service, a cache editor may + be used to replace the empty encrypted loc groups with + unencrypted replacements. +

diff --git a/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html b/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html index ffa45d65..269889d4 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html @@ -59,7 +59,7 @@ - Keys + Keys1 Calculating... diff --git a/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html b/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html index c67d7cf5..19e0014e 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html @@ -27,7 +27,11 @@ 0 have a validated key. This is equal to the total number of - validated keys if and only if keys are not re-used. + validated keys if and only if keys are not re-used. A further + 0 + groups do not have a validated key, but are empty and can be + replaced with an unencrypted equivalent with a cache editor.

Download