From a9660bba44df3830cdbc34f67d0595044c9a41a9 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 24 Oct 2020 22:04:06 +0300 Subject: [PATCH] Player is informed if Unstable mods are added to a game - and it no longer crashes --- .../unciv/ui/newgamescreen/GameOptionsTable.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt index 3ccff35a3d..9396480a56 100644 --- a/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/GameOptionsTable.kt @@ -196,10 +196,19 @@ class GameOptionsTable(val previousScreen: IPreviousScreen, val updatePlayerPick for (oldBaseRuleset in gameParameters.mods) if (modRulesets.firstOrNull { it.name == oldBaseRuleset }?.modOptions?.isBaseRuleset == true) gameParameters.mods.remove(oldBaseRuleset) - gameParameters.mods.add(mod.name) + try { + gameParameters.mods.add(mod.name) + reloadRuleset() // This can FAIL at updateBuildingCosts if the mod is incorrectly defined! So we need to popup! + } catch (ex:Exception){ + ToastPopup("The mod you selected is incorrectly defined!", previousScreen as CameraStageBaseScreen) + gameParameters.mods.remove(mod.name) + reloadRuleset() + } } - else gameParameters.mods.remove(mod.name) - reloadRuleset() + else { + gameParameters.mods.remove(mod.name) + reloadRuleset() + } update() var desiredCiv = "" if (checkBox.isChecked) {