mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Rename forOptionsPopup -> tryFixUnknownUniques
This commit is contained in:
parent
08ba5736d0
commit
ad8c4a1e97
@ -402,14 +402,14 @@ class Ruleset {
|
|||||||
uniqueContainer: IHasUniques,
|
uniqueContainer: IHasUniques,
|
||||||
lines: RulesetErrorList,
|
lines: RulesetErrorList,
|
||||||
severityToReport: UniqueType.UniqueComplianceErrorSeverity,
|
severityToReport: UniqueType.UniqueComplianceErrorSeverity,
|
||||||
forOptionsPopup: Boolean
|
tryFixUnknownUniques: Boolean
|
||||||
) {
|
) {
|
||||||
val name = if (uniqueContainer is INamed) uniqueContainer.name else ""
|
val name = if (uniqueContainer is INamed) uniqueContainer.name else ""
|
||||||
|
|
||||||
for (unique in uniqueContainer.uniqueObjects) {
|
for (unique in uniqueContainer.uniqueObjects) {
|
||||||
val errors = checkUnique(
|
val errors = checkUnique(
|
||||||
unique,
|
unique,
|
||||||
forOptionsPopup,
|
tryFixUnknownUniques,
|
||||||
name,
|
name,
|
||||||
severityToReport,
|
severityToReport,
|
||||||
uniqueContainer.getUniqueTarget()
|
uniqueContainer.getUniqueTarget()
|
||||||
@ -420,13 +420,13 @@ class Ruleset {
|
|||||||
|
|
||||||
fun checkUnique(
|
fun checkUnique(
|
||||||
unique: Unique,
|
unique: Unique,
|
||||||
forOptionsPopup: Boolean,
|
tryFixUnknownUniques: Boolean,
|
||||||
name: String,
|
name: String,
|
||||||
severityToReport: UniqueType.UniqueComplianceErrorSeverity,
|
severityToReport: UniqueType.UniqueComplianceErrorSeverity,
|
||||||
uniqueTarget: UniqueTarget
|
uniqueTarget: UniqueTarget
|
||||||
): List<RulesetError> {
|
): List<RulesetError> {
|
||||||
if (unique.type == null) {
|
if (unique.type == null) {
|
||||||
if (!forOptionsPopup) return emptyList()
|
if (!tryFixUnknownUniques) return emptyList()
|
||||||
val similarUniques = UniqueType.values().filter {
|
val similarUniques = UniqueType.values().filter {
|
||||||
getRelativeTextDistance(
|
getRelativeTextDistance(
|
||||||
it.placeholderText,
|
it.placeholderText,
|
||||||
@ -564,7 +564,7 @@ class Ruleset {
|
|||||||
.joinToString("\n") { it.errorSeverityToReport.name + ": " + it.text }
|
.joinToString("\n") { it.errorSeverityToReport.name + ": " + it.text }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkModLinks(forOptionsPopup: Boolean = false): RulesetErrorList {
|
fun checkModLinks(tryFixUnknownUniques: Boolean = false): RulesetErrorList {
|
||||||
val lines = RulesetErrorList()
|
val lines = RulesetErrorList()
|
||||||
|
|
||||||
// Checks for all mods - only those that can succeed without loading a base ruleset
|
// Checks for all mods - only those that can succeed without loading a base ruleset
|
||||||
@ -581,7 +581,7 @@ class Ruleset {
|
|||||||
if (unit.isRanged() && unit.rangedStrength == 0 && !unit.hasUnique(UniqueType.CannotAttack))
|
if (unit.isRanged() && unit.rangedStrength == 0 && !unit.hasUnique(UniqueType.CannotAttack))
|
||||||
lines += "${unit.name} is a ranged unit but has no assigned rangedStrength!"
|
lines += "${unit.name} is a ranged unit but has no assigned rangedStrength!"
|
||||||
|
|
||||||
checkUniques(unit, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(unit, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tech in technologies.values) {
|
for (tech in technologies.values) {
|
||||||
@ -590,14 +590,14 @@ class Ruleset {
|
|||||||
lines += "${tech.name} is in the same row as ${otherTech.name}!"
|
lines += "${tech.name} is in the same row as ${otherTech.name}!"
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUniques(tech, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(tech, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (building in buildings.values) {
|
for (building in buildings.values) {
|
||||||
if (building.requiredTech == null && building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable))
|
if (building.requiredTech == null && building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable))
|
||||||
lines += "${building.name} is buildable and therefore must either have an explicit cost or reference an existing tech!"
|
lines += "${building.name} is buildable and therefore must either have an explicit cost or reference an existing tech!"
|
||||||
|
|
||||||
checkUniques(building, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(building, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,15 +606,15 @@ class Ruleset {
|
|||||||
lines += "${nation.name} can settle cities, but has no city names!"
|
lines += "${nation.name} can settle cities, but has no city names!"
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUniques(nation, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(nation, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (promotion in unitPromotions.values) {
|
for (promotion in unitPromotions.values) {
|
||||||
checkUniques(promotion, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(promotion, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (resource in tileResources.values) {
|
for (resource in tileResources.values) {
|
||||||
checkUniques(resource, lines, rulesetInvariant, forOptionsPopup)
|
checkUniques(resource, lines, rulesetInvariant, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quit here when no base ruleset is loaded - references cannot be checked
|
// Quit here when no base ruleset is loaded - references cannot be checked
|
||||||
@ -654,7 +654,7 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUniques(unit, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(unit, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (building in buildings.values) {
|
for (building in buildings.values) {
|
||||||
@ -674,7 +674,7 @@ class Ruleset {
|
|||||||
if (building.requiredBuildingInAllCities != null)
|
if (building.requiredBuildingInAllCities != null)
|
||||||
lines.add("${building.name} contains 'requiredBuildingInAllCities' - please convert to a \"" +
|
lines.add("${building.name} contains 'requiredBuildingInAllCities' - please convert to a \"" +
|
||||||
UniqueType.RequiresBuildingInAllCities.text.fillPlaceholders(building.requiredBuildingInAllCities!!)+"\" unique", RulesetErrorSeverity.Warning)
|
UniqueType.RequiresBuildingInAllCities.text.fillPlaceholders(building.requiredBuildingInAllCities!!)+"\" unique", RulesetErrorSeverity.Warning)
|
||||||
checkUniques(building, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(building, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (resource in tileResources.values) {
|
for (resource in tileResources.values) {
|
||||||
@ -688,7 +688,7 @@ class Ruleset {
|
|||||||
for (terrain in resource.terrainsCanBeFoundOn)
|
for (terrain in resource.terrainsCanBeFoundOn)
|
||||||
if (!terrains.containsKey(terrain))
|
if (!terrains.containsKey(terrain))
|
||||||
lines += "${resource.name} can be found on terrain $terrain which does not exist!"
|
lines += "${resource.name} can be found on terrain $terrain which does not exist!"
|
||||||
checkUniques(resource, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(resource, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (improvement in tileImprovements.values) {
|
for (improvement in tileImprovements.values) {
|
||||||
@ -727,7 +727,7 @@ class Ruleset {
|
|||||||
RulesetErrorSeverity.Warning
|
RulesetErrorSeverity.Warning
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
checkUniques(improvement, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(improvement, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrains.values.none { it.type == TerrainType.Land && !it.impassable })
|
if (terrains.values.none { it.type == TerrainType.Land && !it.impassable })
|
||||||
@ -736,7 +736,7 @@ class Ruleset {
|
|||||||
for (baseTerrain in terrain.occursOn)
|
for (baseTerrain in terrain.occursOn)
|
||||||
if (!terrains.containsKey(baseTerrain))
|
if (!terrains.containsKey(baseTerrain))
|
||||||
lines += "${terrain.name} occurs on terrain $baseTerrain which does not exist!"
|
lines += "${terrain.name} occurs on terrain $baseTerrain which does not exist!"
|
||||||
checkUniques(terrain, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(terrain, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
val prereqsHashMap = HashMap<String,HashSet<String>>()
|
val prereqsHashMap = HashMap<String,HashSet<String>>()
|
||||||
@ -765,7 +765,7 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
if (tech.era() !in eras)
|
if (tech.era() !in eras)
|
||||||
lines += "Unknown era ${tech.era()} referenced in column of tech ${tech.name}"
|
lines += "Unknown era ${tech.era()} referenced in column of tech ${tech.name}"
|
||||||
checkUniques(tech, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(tech, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eras.isEmpty()) {
|
if (eras.isEmpty()) {
|
||||||
@ -806,7 +806,7 @@ class Ruleset {
|
|||||||
lines.add("No friend bonus defined for era ${era.name}", RulesetErrorSeverity.Warning)
|
lines.add("No friend bonus defined for era ${era.name}", RulesetErrorSeverity.Warning)
|
||||||
|
|
||||||
|
|
||||||
checkUniques(era, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(era, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (speed in speeds.values) {
|
for (speed in speeds.values) {
|
||||||
@ -817,11 +817,11 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (belief in beliefs.values) {
|
for (belief in beliefs.values) {
|
||||||
checkUniques(belief, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(belief, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nation in nations.values) {
|
for (nation in nations.values) {
|
||||||
checkUniques(nation, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(nation, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
if (nation.favoredReligion != null && nation.favoredReligion !in religions)
|
if (nation.favoredReligion != null && nation.favoredReligion !in religions)
|
||||||
lines += "${nation.name} has ${nation.favoredReligion} as their favored religion, which does not exist!"
|
lines += "${nation.name} has ${nation.favoredReligion} as their favored religion, which does not exist!"
|
||||||
}
|
}
|
||||||
@ -831,7 +831,7 @@ class Ruleset {
|
|||||||
for (prereq in policy.requires!!)
|
for (prereq in policy.requires!!)
|
||||||
if (!policies.containsKey(prereq))
|
if (!policies.containsKey(prereq))
|
||||||
lines += "${policy.name} requires policy $prereq which does not exist!"
|
lines += "${policy.name} requires policy $prereq which does not exist!"
|
||||||
checkUniques(policy, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(policy, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (branch in policyBranches.values)
|
for (branch in policyBranches.values)
|
||||||
@ -847,7 +847,7 @@ class Ruleset {
|
|||||||
for (difficulty in reward.excludedDifficulties)
|
for (difficulty in reward.excludedDifficulties)
|
||||||
if (!difficulties.containsKey(difficulty))
|
if (!difficulties.containsKey(difficulty))
|
||||||
lines += "${reward.name} references difficulty ${difficulty}, which does not exist!"
|
lines += "${reward.name} references difficulty ${difficulty}, which does not exist!"
|
||||||
checkUniques(reward, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(reward, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (promotion in unitPromotions.values) {
|
for (promotion in unitPromotions.values) {
|
||||||
@ -858,11 +858,11 @@ class Ruleset {
|
|||||||
for (unitType in promotion.unitTypes)
|
for (unitType in promotion.unitTypes)
|
||||||
if (!unitTypes.containsKey(unitType) && (unitTypes.isNotEmpty() || !vanillaRuleset.unitTypes.containsKey(unitType)))
|
if (!unitTypes.containsKey(unitType) && (unitTypes.isNotEmpty() || !vanillaRuleset.unitTypes.containsKey(unitType)))
|
||||||
lines.add("${promotion.name} references unit type $unitType, which does not exist!", RulesetErrorSeverity.Warning)
|
lines.add("${promotion.name} references unit type $unitType, which does not exist!", RulesetErrorSeverity.Warning)
|
||||||
checkUniques(promotion, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(promotion, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unitType in unitTypes.values) {
|
for (unitType in unitTypes.values) {
|
||||||
checkUniques(unitType, lines, rulesetSpecific, forOptionsPopup)
|
checkUniques(unitType, lines, rulesetSpecific, tryFixUnknownUniques)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (victoryType in victories.values) {
|
for (victoryType in victories.values) {
|
||||||
@ -1029,12 +1029,12 @@ object RulesetCache : HashMap<String,Ruleset>() {
|
|||||||
fun checkCombinedModLinks(
|
fun checkCombinedModLinks(
|
||||||
mods: LinkedHashSet<String>,
|
mods: LinkedHashSet<String>,
|
||||||
baseRuleset: String? = null,
|
baseRuleset: String? = null,
|
||||||
forOptionsPopup: Boolean = false
|
tryFixUnknownUniques: Boolean = false
|
||||||
): Ruleset.RulesetErrorList {
|
): Ruleset.RulesetErrorList {
|
||||||
return try {
|
return try {
|
||||||
val newRuleset = getComplexRuleset(mods, baseRuleset)
|
val newRuleset = getComplexRuleset(mods, baseRuleset)
|
||||||
newRuleset.modOptions.isBaseRuleset = true // This is so the checkModLinks finds all connections
|
newRuleset.modOptions.isBaseRuleset = true // This is so the checkModLinks finds all connections
|
||||||
newRuleset.checkModLinks(forOptionsPopup)
|
newRuleset.checkModLinks(tryFixUnknownUniques)
|
||||||
} catch (ex: UncivShowableException) {
|
} catch (ex: UncivShowableException) {
|
||||||
// This happens if a building is dependent on a tech not in the base ruleset
|
// This happens if a building is dependent on a tech not in the base ruleset
|
||||||
// because newRuleset.updateBuildingCosts() in getComplexRuleset() throws an error
|
// because newRuleset.updateBuildingCosts() in getComplexRuleset() throws an error
|
||||||
|
@ -95,8 +95,8 @@ class ModCheckTab(
|
|||||||
if (base != MOD_CHECK_WITHOUT_BASE && mod.modOptions.isBaseRuleset) continue
|
if (base != MOD_CHECK_WITHOUT_BASE && mod.modOptions.isBaseRuleset) continue
|
||||||
|
|
||||||
val modLinks =
|
val modLinks =
|
||||||
if (base == MOD_CHECK_WITHOUT_BASE) mod.checkModLinks(forOptionsPopup = true)
|
if (base == MOD_CHECK_WITHOUT_BASE) mod.checkModLinks(tryFixUnknownUniques = true)
|
||||||
else RulesetCache.checkCombinedModLinks(linkedSetOf(mod.name), base, forOptionsPopup = true)
|
else RulesetCache.checkCombinedModLinks(linkedSetOf(mod.name), base, tryFixUnknownUniques = true)
|
||||||
modLinks.sortByDescending { it.errorSeverityToReport }
|
modLinks.sortByDescending { it.errorSeverityToReport }
|
||||||
val noProblem = !modLinks.isNotOK()
|
val noProblem = !modLinks.isNotOK()
|
||||||
if (modLinks.isNotEmpty()) modLinks += Ruleset.RulesetError("", Ruleset.RulesetErrorSeverity.OK)
|
if (modLinks.isNotEmpty()) modLinks += Ruleset.RulesetError("", Ruleset.RulesetErrorSeverity.OK)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user