Avoid crash in mod checker for mods with undefined tech requirements (#10744)

This commit is contained in:
SeventhM 2023-12-15 01:13:23 -08:00 committed by GitHub
parent c60700193f
commit 297aa3e082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,15 +62,15 @@ interface IHasUniques : INamed {
fun requiredTechs(): Sequence<String> = legacyRequiredTechs() + techsRequiredByUniques()
fun requiredTechnologies(ruleset: Ruleset): Sequence<Technology> =
requiredTechs().map{ ruleset.technologies[it]!! }
fun requiredTechnologies(ruleset: Ruleset): Sequence<Technology?> =
requiredTechs().map{ ruleset.technologies[it] }
fun era(ruleset: Ruleset): Era? =
requiredTechnologies(ruleset).map{ it.era() }.map{ ruleset.eras[it]!! }.maxByOrNull{ it.eraNumber }
// This will return null only if requiredTechnologies() is empty.
requiredTechnologies(ruleset).map{ it?.era() }.map{ ruleset.eras[it] }.maxByOrNull{ it?.eraNumber ?: 0 }
// This will return null only if requiredTechnologies() is empty or all required techs have no eraNumber
fun techColumn(ruleset: Ruleset): TechColumn? =
requiredTechnologies(ruleset).map{ it.column }.filterNotNull().maxByOrNull{ it.columnNumber }
requiredTechnologies(ruleset).map{ it?.column }.filterNotNull().maxByOrNull{ it.columnNumber }
// This will return null only if *all* required techs have null TechColumn.
fun availableInEra(ruleset: Ruleset, requestedEra: String): Boolean {