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 5d7526d481..32b0ad62d5 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 b121b836a5..4c82aa2b75 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 080bb25bdd..55b9288508 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 @@
+ 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. +