From 9f251787fa69803f0d1f9009f8f7f19d247dde9f Mon Sep 17 00:00:00 2001 From: Timo T Date: Fri, 22 Jul 2022 15:04:30 +0200 Subject: [PATCH] Fix games not being loadable (#7508) * Fix wrong caching key * Refactor: Change caching keys to unique name --- core/src/com/unciv/logic/map/TileInfo.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index e85fb96605..db88c2f7d3 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -536,7 +536,7 @@ open class TileInfo : IsPartOfGameInfoSerialization { // therefore if we want the cache to be useful it needs to hold the pre-filtered uniques, // and then for each improvement we'll filter the uniques locally. // This is still a MASSIVE save of RAM! - val tileUniques = cityUniqueCache.get("StatsFromTiles", + val tileUniques = cityUniqueCache.get(UniqueType.StatsFromTiles.name, city.getMatchingUniques(UniqueType.StatsFromTiles, StateForConditionals.IgnoreConditionals) .filter { city.matchesFilter(it.params[2]) }) // These are the uniques for all improvements for this city, .filter { it.conditionalsApply(conditionalState) } // ...and this is those with applicable conditions @@ -555,7 +555,7 @@ open class TileInfo : IsPartOfGameInfoSerialization { fun statsFromObject() { // Same as above - cache holds unfiltered uniques for the city, while we use only the filtered ones - val uniques = cityUniqueCache.get("statsFromObjects", + val uniques = cityUniqueCache.get(UniqueType.StatsFromObject.name, city.getMatchingUniques(UniqueType.StatsFromObject, StateForConditionals.IgnoreConditionals)) .filter { it.conditionalsApply(conditionalState) } for (unique in uniques) { @@ -585,7 +585,7 @@ open class TileInfo : IsPartOfGameInfoSerialization { if (city != null) { // As above, since the conditional is tile-dependant, // we save uniques in the cache without conditional filtering, and use only filtered ones - val allStatPercentUniques = cityUniqueCache.get("allSatPercentFromObject", + val allStatPercentUniques = cityUniqueCache.get(UniqueType.AllStatsPercentFromObject.name, city.getMatchingUniques(UniqueType.AllStatsPercentFromObject, StateForConditionals.IgnoreConditionals)) .filter { it.conditionalsApply(conditionalState) } for (unique in allStatPercentUniques) { @@ -596,7 +596,7 @@ open class TileInfo : IsPartOfGameInfoSerialization { } // Same trick different unique - not sure if worth generalizing this 'late apply' of conditions? - val statPercentUniques = cityUniqueCache.get("allSatPercentFromObject", + val statPercentUniques = cityUniqueCache.get(UniqueType.StatPercentFromObject.name, city.getMatchingUniques(UniqueType.StatPercentFromObject, StateForConditionals.IgnoreConditionals)) .filter { it.conditionalsApply(conditionalState) }