mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Memory improvements, hoping to mitigate OutOfMemory errors
This commit is contained in:
parent
133b0d7abe
commit
78b9908479
@ -75,6 +75,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
if(gameInfo.civilizations.isEmpty())
|
if(gameInfo.civilizations.isEmpty())
|
||||||
return create()
|
return create()
|
||||||
|
|
||||||
|
if(::worldScreen.isInitialized) worldScreen.dispose() // I hope this will solve some of the many OuOfMemory exceptions...
|
||||||
worldScreen = WorldScreen()
|
worldScreen = WorldScreen()
|
||||||
setWorldScreen()
|
setWorldScreen()
|
||||||
}
|
}
|
||||||
|
@ -118,16 +118,22 @@ class CityConstructions {
|
|||||||
fun turnsToConstruction(constructionName: String): Int {
|
fun turnsToConstruction(constructionName: String): Int {
|
||||||
val workLeft = getRemainingWork(constructionName)
|
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
|
val currConstruction = currentConstruction
|
||||||
currentConstruction = constructionName
|
|
||||||
cityInfo.cityStats.update()
|
val cityStatsForConstruction: Stats
|
||||||
val cityStatsForConstruction = cityInfo.cityStats.currentCityStats
|
if (currentConstruction == constructionName) cityStatsForConstruction = cityInfo.cityStats.currentCityStats
|
||||||
// revert!
|
else {
|
||||||
currentConstruction = currConstruction
|
// The ol' Switcharoo - what would our stats be if that was our current construction?
|
||||||
cityInfo.cityStats.update()
|
// 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)
|
var production = Math.round(cityStatsForConstruction.production)
|
||||||
if (constructionName == Constants.settler) production += cityStatsForConstruction.food.toInt()
|
if (constructionName == Constants.settler) production += cityStatsForConstruction.food.toInt()
|
||||||
|
@ -37,7 +37,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||||||
|
|
||||||
private fun getTransportationUpkeep(): Int {
|
private fun getTransportationUpkeep(): Int {
|
||||||
var transportationUpkeep = 0
|
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) {
|
when(it.roadStatus) {
|
||||||
RoadStatus.Road -> transportationUpkeep += 1
|
RoadStatus.Road -> transportationUpkeep += 1
|
||||||
RoadStatus.Railroad -> transportationUpkeep += 2
|
RoadStatus.Railroad -> transportationUpkeep += 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user