Avoid crash from giving ai free techs.

This commit is contained in:
Duan Tao 2018-12-24 20:01:32 +08:00
parent faf5803b1d
commit e3c9567904

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