modcheck: Handle case where a deprecated unique used a parameter type that no longer exists

This commit is contained in:
yairm210 2025-06-05 16:28:17 +03:00
parent 41eceeb834
commit 454b86cdc1
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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"