From 454b86cdc1dc6ec0dec2b97b9a62feda7ab715d2 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Thu, 5 Jun 2025 16:28:17 +0300 Subject: [PATCH] modcheck: Handle case where a deprecated unique used a parameter type that no longer exists --- .../com/unciv/models/ruleset/validation/UniqueValidator.kt | 5 ++++- docs/Modders/uniques.md | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt index f5e49603d1..e5a9160bd0 100644 --- a/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt +++ b/core/src/com/unciv/models/ruleset/validation/UniqueValidator.kt @@ -312,6 +312,8 @@ class UniqueValidator(val ruleset: Ruleset) { "but its type ${unique.type} only ${unique.type.parameterTypeMap.size} parameters?!") } val acceptableParamTypes = unique.type.parameterTypeMap[index] + if (acceptableParamTypes.size == 0) continue // This is a deprecated parameter type, don't bother checking it + val errorTypesForAcceptableParameters = acceptableParamTypes.map { getParamTypeErrorSeverityCached(it, param) } if (errorTypesForAcceptableParameters.any { it == null }) continue // This matches one of the types! @@ -320,7 +322,8 @@ class UniqueValidator(val ruleset: Ruleset) { continue // This is a filtering param, and the unique it's filtering for actually exists, no problem here! val leastSevereWarning = errorTypesForAcceptableParameters.minByOrNull { it!!.ordinal } - if (leastSevereWarning == null) throw Exception("Unique ${unique.text} from mod ${ruleset.name} is acting strangely - please open a bug report") + if (leastSevereWarning == null) + throw Exception("Unique ${unique.text} from mod ${ruleset.name} is acting strangely - please open a bug report") errorList += UniqueComplianceError(param, acceptableParamTypes, leastSevereWarning) } return errorList diff --git a/docs/Modders/uniques.md b/docs/Modders/uniques.md index d2f784fc2e..003e1003f1 100644 --- a/docs/Modders/uniques.md +++ b/docs/Modders/uniques.md @@ -1575,7 +1575,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl ??? example "Doubles Gold given to enemy if city is captured" Applicable to: Building -??? example "Remove extra unhappiness from annexed cities" +??? example "Removes extra unhappiness from annexed cities" Applicable to: Building ??? example "Connects trade routes over water"