There's no need to save the civ uniques in *every* city unique usage differently, waste of RAM and CPU

This commit is contained in:
Yair Morgenstern 2023-08-31 15:26:29 +03:00
parent ad7397ecc9
commit 6f9d2ea6d5
2 changed files with 10 additions and 10 deletions

View File

@ -328,15 +328,15 @@ class LocalUniqueCache(val cache:Boolean = true) {
// City uniques are a combination of *global civ* uniques plus *city relevant* uniques (see City.getMatchingUniques())
// We can cache the civ uniques separately, so if we have several cities using the same cache,
// we can cache the list of *civ uniques* to reuse between cities.
// This is assuming that we're ignoring conditionals, because otherwise -
// the conditionals will render the the *filtered uniques* different anyway, so there's no reason to cache...
val unfilteredUniques = forCivGetMatchingUniques(city.civ, uniqueType, StateForConditionals.IgnoreConditionals) +
city.getLocalMatchingUniques(uniqueType, StateForConditionals.IgnoreConditionals)
return get(
val citySpecificUniques = get(
"city-${city.id}-${uniqueType.name}",
unfilteredUniques
city.getLocalMatchingUniques(uniqueType, StateForConditionals.IgnoreConditionals)
).filter { it.conditionalsApply(stateForConditionals) }
val civUniques = forCivGetMatchingUniques(city.civ, uniqueType, stateForConditionals)
return citySpecificUniques + civUniques
}
fun forCivGetMatchingUniques(

View File

@ -205,18 +205,18 @@ class ImprovementPickerScreen(
regularImprovements.row()
}
var ownerTable = Table()
val ownerTable = Table()
if (tile.getOwner() == null) {
ownerTable.add("Unowned tile".tr().toLabel())
ownerTable.add("Unowned tile".toLabel())
} else if (tile.getOwner()!!.isCurrentPlayer()) {
val button = tile.getCity()!!.name.toTextButton(hideIcons = true)
button.onClick {
this.game.pushScreen(CityScreen(tile.getCity()!!,null,tile))
}
ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] (You)".tr().toLabel()).padLeft(10f)
ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] (You)".toLabel()).padLeft(10f)
ownerTable.add(button).padLeft(20f)
} else {
ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] - [${tile.getCity()!!.name}]".tr().toLabel()).padLeft(10f)
ownerTable.add("Tile owned by [${tile.getOwner()!!.civName}] - [${tile.getCity()!!.name}]".toLabel()).padLeft(10f)
}
topTable.add(ownerTable)