getComplexRuleset now accepts list of mods and not gameParameters

This commit is contained in:
Yair Morgenstern 2021-02-12 10:47:12 +02:00
parent c1a259ea7d
commit 9db073ff25
7 changed files with 7 additions and 9 deletions

View File

@ -258,7 +258,7 @@ class GameInfo {
// will be done here, and not in CivInfo.setTransients or CityInfo // will be done here, and not in CivInfo.setTransients or CityInfo
fun setTransients() { fun setTransients() {
tileMap.gameInfo = this tileMap.gameInfo = this
ruleSet = RulesetCache.getComplexRuleset(gameParameters) ruleSet = RulesetCache.getComplexRuleset(gameParameters.mods)
// any mod the saved game lists that is currently not installed causes null pointer // any mod the saved game lists that is currently not installed causes null pointer
// exceptions in this routine unless it contained no new objects or was very simple. // exceptions in this routine unless it contained no new objects or was very simple.
// Player's fault, so better complain early: // Player's fault, so better complain early:

View File

@ -20,7 +20,7 @@ object GameStarter {
val gameInfo = GameInfo() val gameInfo = GameInfo()
gameInfo.gameParameters = gameSetupInfo.gameParameters gameInfo.gameParameters = gameSetupInfo.gameParameters
val ruleset = RulesetCache.getComplexRuleset(gameInfo.gameParameters) val ruleset = RulesetCache.getComplexRuleset(gameInfo.gameParameters.mods)
if (gameSetupInfo.mapParameters.name != "") { if (gameSetupInfo.mapParameters.name != "") {
gameInfo.tileMap = MapSaver.loadMap(gameSetupInfo.mapFile!!) gameInfo.tileMap = MapSaver.loadMap(gameSetupInfo.mapFile!!)

View File

@ -371,8 +371,6 @@ object RulesetCache :HashMap<String,Ruleset>() {
return newRuleset return newRuleset
} }
fun getComplexRuleset(gameParameters: GameParameters): Ruleset =
getComplexRuleset(gameParameters.mods)
} }
class Specialist: NamedStats() { class Specialist: NamedStats() {

View File

@ -17,7 +17,7 @@ import com.unciv.ui.utils.*
*/ */
class GameParametersScreen(var mapEditorScreen: MapEditorScreen): IPreviousScreen, PickerScreen() { class GameParametersScreen(var mapEditorScreen: MapEditorScreen): IPreviousScreen, PickerScreen() {
override var gameSetupInfo = mapEditorScreen.gameSetupInfo.clone() override var gameSetupInfo = mapEditorScreen.gameSetupInfo.clone()
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters) override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods)
var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters) var playerPickerTable = PlayerPickerTable(this, gameSetupInfo.gameParameters)
var gameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } var gameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }

View File

@ -164,7 +164,7 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick
fun reloadRuleset() { fun reloadRuleset() {
ruleset.clear() ruleset.clear()
val newRuleset = RulesetCache.getComplexRuleset(gameParameters) val newRuleset = RulesetCache.getComplexRuleset(gameParameters.mods)
ruleset.add(newRuleset) ruleset.add(newRuleset)
ruleset.mods += gameParameters.mods ruleset.mods += gameParameters.mods
ruleset.modOptions = newRuleset.modOptions ruleset.modOptions = newRuleset.modOptions

View File

@ -41,7 +41,7 @@ class ModCheckboxTable(val gameParameters: GameParameters, val screen: CameraSta
var isCompatibleWithCurrentRuleset = true var isCompatibleWithCurrentRuleset = true
var complexModLinkErrors = "" var complexModLinkErrors = ""
try { try {
val newRuleset = RulesetCache.getComplexRuleset(gameParameters) val newRuleset = RulesetCache.getComplexRuleset(gameParameters.mods)
newRuleset.modOptions.isBaseRuleset = true // This is so the checkModLinks finds all connections newRuleset.modOptions.isBaseRuleset = true // This is so the checkModLinks finds all connections
complexModLinkErrors = newRuleset.checkModLinks() complexModLinkErrors = newRuleset.checkModLinks()
if (complexModLinkErrors != "") isCompatibleWithCurrentRuleset = false if (complexModLinkErrors != "") isCompatibleWithCurrentRuleset = false

View File

@ -37,7 +37,7 @@ class GameSetupInfo(var gameId:String, var gameParameters: GameParameters, var m
class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() { class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSetupInfo?=null): IPreviousScreen, PickerScreen() {
override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo() override val gameSetupInfo = _gameSetupInfo ?: GameSetupInfo()
override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters) // needs to be set because the gameoptionstable etc. depend on this override var ruleset = RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods) // needs to be set because the gameoptionstable etc. depend on this
var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) } var newGameOptionsTable = GameOptionsTable(this) { desiredCiv: String -> playerPickerTable.update(desiredCiv) }
// Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init // Has to be defined before the mapOptionsTable, since the mapOptionsTable refers to it on init
@ -145,7 +145,7 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
fun updateRuleset() { fun updateRuleset() {
ruleset.clear() ruleset.clear()
ruleset.add(RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters)) ruleset.add(RulesetCache.getComplexRuleset(gameSetupInfo.gameParameters.mods))
} }
fun lockTables() { fun lockTables() {