Merge pull request #373 from ninjatao/fix_new_game_crash

Avoid crash from giving ai free techs.
This commit is contained in:
yairm210
2018-12-24 16:08:13 +02:00
committed by GitHub

View File

@ -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() }) {