mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
We now check compatibility of newly selected mods to the existing mod ruleset
This commit is contained in:
parent
03193e4f61
commit
3176cd147a
@ -228,7 +228,7 @@ class Ruleset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(building in buildings.values) {
|
for (building in buildings.values) {
|
||||||
if (building.requiredTech == null && building.cost == 0)
|
if (building.requiredTech == null && building.cost == 0)
|
||||||
lines += "${building.name} must either have an explicit cost or reference an existing tech!"
|
lines += "${building.name} must either have an explicit cost or reference an existing tech!"
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ object RulesetCache :HashMap<String,Ruleset>() {
|
|||||||
for (mod in loadedMods.sortedByDescending { it.modOptions.isBaseRuleset }) {
|
for (mod in loadedMods.sortedByDescending { it.modOptions.isBaseRuleset }) {
|
||||||
newRuleset.add(mod)
|
newRuleset.add(mod)
|
||||||
newRuleset.mods += mod.name
|
newRuleset.mods += mod.name
|
||||||
if(mod.modOptions.isBaseRuleset){
|
if (mod.modOptions.isBaseRuleset) {
|
||||||
newRuleset.modOptions = mod.modOptions
|
newRuleset.modOptions = mod.modOptions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,12 +199,35 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
|
|||||||
return@onChange
|
return@onChange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val previousMods = gameParameters.mods.toList()
|
||||||
|
|
||||||
if (mod.modOptions.isBaseRuleset)
|
if (mod.modOptions.isBaseRuleset)
|
||||||
for (oldBaseRuleset in gameParameters.mods.toList()) // so we don't get concurrent modification excpetions
|
for (oldBaseRuleset in previousMods) // so we don't get concurrent modification excpetions
|
||||||
if (modRulesets.firstOrNull { it.name == oldBaseRuleset }?.modOptions?.isBaseRuleset == true)
|
if (modRulesets.firstOrNull { it.name == oldBaseRuleset }?.modOptions?.isBaseRuleset == true)
|
||||||
gameParameters.mods.remove(oldBaseRuleset)
|
gameParameters.mods.remove(oldBaseRuleset)
|
||||||
gameParameters.mods.add(mod.name)
|
gameParameters.mods.add(mod.name)
|
||||||
reloadRuleset() // This can FAIL at updateBuildingCosts if the mod is incorrectly defined! So we need to popup!
|
|
||||||
|
var isCompatibleWithCurrentRuleset = true
|
||||||
|
try {
|
||||||
|
val newRuleset = RulesetCache.getComplexRuleset(gameParameters)
|
||||||
|
newRuleset.modOptions.isBaseRuleset = true
|
||||||
|
val complexModLinkErrors = newRuleset.checkModLinks()
|
||||||
|
if (complexModLinkErrors != "") isCompatibleWithCurrentRuleset = false
|
||||||
|
} catch (x: Exception) {
|
||||||
|
// This happens if a building is dependent on a tech not in the base ruleset
|
||||||
|
// because newRuleset.updateBuildingCosts() in getComplexRulset() throws an error
|
||||||
|
isCompatibleWithCurrentRuleset = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCompatibleWithCurrentRuleset) {
|
||||||
|
ToastPopup("The mod you selected is incompatible with the defined ruleset!\n\n$modLinkErrors", previousScreen as CameraStageBaseScreen)
|
||||||
|
checkBox.isChecked = false
|
||||||
|
gameParameters.mods.clear()
|
||||||
|
gameParameters.mods.addAll(previousMods)
|
||||||
|
return@onChange
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadRuleset()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gameParameters.mods.remove(mod.name)
|
gameParameters.mods.remove(mod.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user