From e3c9567904d0f7d14b45eb7fe9505f47ed37d21a Mon Sep 17 00:00:00 2001 From: Duan Tao Date: Mon, 24 Dec 2018 20:01:32 +0800 Subject: [PATCH] Avoid crash from giving ai free techs. --- core/src/com/unciv/GameStarter.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/GameStarter.kt b/core/src/com/unciv/GameStarter.kt index ca49dc4d5f..fa1b1073b5 100644 --- a/core/src/com/unciv/GameStarter.kt +++ b/core/src/com/unciv/GameStarter.kt @@ -31,8 +31,6 @@ class GameStarter{ for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled() .take(newGameParameters.numberOfEnemies)) { val civ = CivilizationInfo(nationName) - for (tech in gameInfo.getDifficulty().aiFreeTechs) - civ.tech.addTechnology(tech) gameInfo.civilizations.add(civ) } @@ -41,6 +39,11 @@ class GameStarter{ gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set + for (civInfo in gameInfo.civilizations.filter {!it.isBarbarianCivilization() && !it.isPlayerCivilization()}) { + for (tech in gameInfo.getDifficulty().aiFreeTechs) + civInfo.tech.addTechnology(tech) + } + // and only now do we add units for everyone, because otherwise both the gameInfo.setTransients() and the placeUnit will both add the unit to the civ's unit list! for (civ in gameInfo.civilizations.filter { !it.isBarbarianCivilization() }) {