From 08bfa381a1c8f3fa026356c5e7626591803f9eb1 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sun, 7 Apr 2024 00:07:00 +0300 Subject: [PATCH] Added exception to catch the situation causing #11404 --- .../com/unciv/models/ruleset/validation/UniqueValidator.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt index e7ec5bb2ee..db63394997 100644 --- a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt @@ -201,12 +201,17 @@ class UniqueValidator(val ruleset: Ruleset) { } /** Maps uncompliant parameters to their required types */ - private fun getComplianceErrors( + private fun getComplianceErrors( unique: Unique, ): List { if (unique.type == null) return emptyList() val errorList = ArrayList() for ((index, param) in unique.params.withIndex()) { + // Trying to catch the error at #11404 + if (unique.type.parameterTypeMap.size != unique.params.size) { + throw Exception("Unique ${unique.text} has ${unique.params.size} parameters, " + + "but its type ${unique.type} only ${unique.type.parameterTypeMap.size} parameters?!") + } val acceptableParamTypes = unique.type.parameterTypeMap[index] val errorTypesForAcceptableParameters = acceptableParamTypes.map { getParamTypeErrorSeverityCached(it, param) }