Memory improvements, hoping to mitigate OutOfMemory errors
This commit is contained in:
parent
133b0d7abe
commit
78b9908479
3 changed files with 17 additions and 10 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue