From 6f9d2ea6d5e0b79a40cbfdf8050c279a3098268c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 31 Aug 2023 15:26:29 +0300 Subject: [PATCH] There's no need to save the civ uniques in *every* city unique usage differently, waste of RAM and CPU --- core/src/com/unciv/models/ruleset/unique/Unique.kt | 12 ++++++------ .../screens/pickerscreens/ImprovementPickerScreen.kt | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index bed8598c6a..ccb148ae94 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -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( diff --git a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt index 7264285a40..3b9d4b9327 100644 --- a/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/screens/pickerscreens/ImprovementPickerScreen.kt @@ -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)