Fixed scenarios crashing

This commit is contained in:
Yair Morgenstern 2023-12-30 21:13:59 +02:00
parent 16fce2bb1d
commit ab133027cd
5 changed files with 180 additions and 167 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 KiB

After

Width:  |  Height:  |  Size: 904 KiB

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.utils.GdxRuntimeException
import com.badlogic.gdx.utils.JsonReader
import com.badlogic.gdx.utils.SerializationException
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.json.fromJsonFile
import com.unciv.json.json
@ -327,6 +328,8 @@ class UncivFiles(
fun loadScenario(gameFile: FileHandle): GameInfo {
val game = loadGameFromFile(gameFile)
game.civilizations.removeAll { it.isSpectator() }
for (civ in game.civilizations)
civ.diplomacy.remove(Constants.spectator)
if (game.civilizations.none { it.isHuman() })
game.civilizations.first { it.isMajorCiv() }.playerType = PlayerType.Human

View File

@ -25,7 +25,7 @@ class ScenarioScreen: PickerScreen() {
scenarioToLoad = file
rightSideButton.setText(file.name())
rightSideButton.enable()
})
}).row()
}
} catch (ex: Exception) { } // invalid, couldn't even load preview, probably invalid json
}

View File

@ -1204,6 +1204,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Can hurry technology research"
Applicable to: Unit
??? example "Can generate a large amount of culture"
Applicable to: Unit
??? example "Can undertake a trade mission with City-State, giving a large sum of gold and [amount] Influence"
Example: "Can undertake a trade mission with City-State, giving a large sum of gold and [3] Influence"