mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-24 18:06:04 +07:00
Fix: Potential crash on new game after deleting a base ruleset mod (#11508)
* Fix: Potential crash on new game after deleting a base ruleset mod * Review
This commit is contained in:
parent
5c6d9171c4
commit
f6e432691d
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
|
import com.unciv.models.metadata.BaseRuleset
|
||||||
import com.unciv.models.metadata.GameParameters
|
import com.unciv.models.metadata.GameParameters
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
@ -79,12 +80,15 @@ class ModCheckboxTable(
|
|||||||
deselectIncompatibleMods(null)
|
deselectIncompatibleMods(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setBaseRuleset(newBaseRuleset: String) {
|
fun setBaseRuleset(newBaseRulesetName: String) {
|
||||||
baseRulesetName = newBaseRuleset
|
val newBaseRuleset = RulesetCache[newBaseRulesetName]
|
||||||
|
// We're calling this from init, baseRuleset is lateinit, and the mod may have been deleted: Must make sure baseRuleset is initialized
|
||||||
|
?: return setBaseRuleset(BaseRuleset.Civ_V_GnK.fullName)
|
||||||
|
baseRulesetName = newBaseRulesetName
|
||||||
|
baseRuleset = newBaseRuleset
|
||||||
savedModcheckResult = null
|
savedModcheckResult = null
|
||||||
clear()
|
clear()
|
||||||
mods.clear() // We'll regenerate this from checked widgets
|
mods.clear() // We'll regenerate this from checked widgets
|
||||||
baseRuleset = RulesetCache[newBaseRuleset] ?: return
|
|
||||||
|
|
||||||
val compatibleMods = modWidgets
|
val compatibleMods = modWidgets
|
||||||
.filter { ModCompatibility.meetsBaseRequirements(it.mod, baseRuleset) }
|
.filter { ModCompatibility.meetsBaseRequirements(it.mod, baseRuleset) }
|
||||||
|
Loading…
Reference in New Issue
Block a user