Fixed crash where deleting mods meant you could never start a game again

If the last game you created used a mod that you later removed from the the device it could never be removed from the new game parameters
Caught exceptions from quickstart failing
This commit is contained in:
yairm210 2021-09-05 14:57:21 +03:00
parent 5f0afffe5a
commit 5170a27e07
3 changed files with 12 additions and 3 deletions

View File

@ -657,7 +657,8 @@ Main menu =
Resume =
Cannot resume game! =
Not enough memory on phone to load game! =
Quickstart =
Quickstart =
Cannot start game with the default new game parameters! =
Victory status =
Social policies =
Community =

View File

@ -236,8 +236,12 @@ class MainMenuScreen: CameraStageBaseScreen() {
}
private fun quickstartNewGame() {
val newGame = GameStarter.startNewGame(GameSetupInfo.fromSettings("Chieftain"))
game.loadGame(newGame)
try {
val newGame = GameStarter.startNewGame(GameSetupInfo.fromSettings("Chieftain"))
game.loadGame(newGame)
} catch (ex: Exception) {
ToastPopup("Cannot start game with the default new game parameters!", this)
}
}
override fun resize(width: Int, height: Int) {

View File

@ -32,6 +32,10 @@ object GameStarter {
val gameInfo = GameInfo()
lateinit var tileMap: TileMap
// In the case where we used to have a mod, and now we don't, we cannot "unselect" it in the UI.
// We need to remove the dead mods so there aren't problems later.
gameSetupInfo.gameParameters.mods.removeAll{ !RulesetCache.containsKey(it) }
gameInfo.gameParameters = gameSetupInfo.gameParameters
val ruleset = RulesetCache.getComplexRuleset(gameInfo.gameParameters.mods)