diff --git a/core/src/com/unciv/UnCivGame.kt b/core/src/com/unciv/UnCivGame.kt index a84c9f87ec..c4a4040bf9 100644 --- a/core/src/com/unciv/UnCivGame.kt +++ b/core/src/com/unciv/UnCivGame.kt @@ -75,6 +75,7 @@ class UnCivGame(val version: String) : Game() { if(gameInfo.civilizations.isEmpty()) return create() + if(::worldScreen.isInitialized) worldScreen.dispose() // I hope this will solve some of the many OuOfMemory exceptions... worldScreen = WorldScreen() setWorldScreen() } diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index a6d9bb148b..5c7b12d093 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -118,16 +118,22 @@ class CityConstructions { fun turnsToConstruction(constructionName: String): Int { val workLeft = getRemainingWork(constructionName) - // The ol' Switcharoo - what would our stats be if that was our current construction? - // Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient - // and recalculating the entire city stats + val currConstruction = currentConstruction - currentConstruction = constructionName - cityInfo.cityStats.update() - val cityStatsForConstruction = cityInfo.cityStats.currentCityStats - // revert! - currentConstruction = currConstruction - cityInfo.cityStats.update() + + val cityStatsForConstruction: Stats + if (currentConstruction == constructionName) cityStatsForConstruction = cityInfo.cityStats.currentCityStats + else { + // The ol' Switcharoo - what would our stats be if that was our current construction? + // Since this is only ever used for UI purposes, I feel fine with having it be a bit inefficient + // and recalculating the entire city stats + currentConstruction = constructionName + cityInfo.cityStats.update() + cityStatsForConstruction = cityInfo.cityStats.currentCityStats + // revert! + currentConstruction = currConstruction + cityInfo.cityStats.update() + } var production = Math.round(cityStatsForConstruction.production) if (constructionName == Constants.settler) production += cityStatsForConstruction.food.toInt() diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 2d6fa031a2..2eb8d9d9cc 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -37,7 +37,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){ private fun getTransportationUpkeep(): Int { var transportationUpkeep = 0 - for (it in civInfo.gameInfo.tileMap.values.filter { it.getOwner()==civInfo }.filterNot { it.isCityCenter() }) { + for (it in civInfo.cities.flatMap { it.getTiles() }.filter{ !it.isCityCenter() }) { when(it.roadStatus) { RoadStatus.Road -> transportationUpkeep += 1 RoadStatus.Railroad -> transportationUpkeep += 2