From 7de3fdf4520fddc2b90a54f1c98714163d5b502a Mon Sep 17 00:00:00 2001 From: OptimizedForDensity <105244635+OptimizedForDensity@users.noreply.github.com> Date: Wed, 22 Jun 2022 02:08:38 -0400 Subject: [PATCH] Fix disappearing terrain when switching between mods (#7257) --- core/src/com/unciv/models/tilesets/TileSetCache.kt | 2 +- core/src/com/unciv/models/tilesets/TileSetConfig.kt | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/models/tilesets/TileSetCache.kt b/core/src/com/unciv/models/tilesets/TileSetCache.kt index 20f88afb58..b22030ad86 100644 --- a/core/src/com/unciv/models/tilesets/TileSetCache.kt +++ b/core/src/com/unciv/models/tilesets/TileSetCache.kt @@ -32,7 +32,7 @@ object TileSetCache : HashMap() { for (entry in allConfigs.entries.filter { it.key.mod == mod } ) { // Built-in tilesets all have empty strings as their `.mod`, so loop through all of them. val tileSet = entry.key.tileSet if (tileSet in this) this[tileSet]!!.updateConfig(entry.value) - else this[tileSet] = entry.value + else this[tileSet] = entry.value.clone() } } } diff --git a/core/src/com/unciv/models/tilesets/TileSetConfig.kt b/core/src/com/unciv/models/tilesets/TileSetConfig.kt index 2ef68a73ba..bb74af726a 100644 --- a/core/src/com/unciv/models/tilesets/TileSetConfig.kt +++ b/core/src/com/unciv/models/tilesets/TileSetConfig.kt @@ -12,7 +12,18 @@ class TileSetConfig { var tileScale: Float = 1f var ruleVariants: HashMap> = HashMap() - fun updateConfig(other: TileSetConfig){ + fun clone(): TileSetConfig { + val toReturn = TileSetConfig() + toReturn.useColorAsBaseTerrain = useColorAsBaseTerrain + toReturn.unexploredTileColor = unexploredTileColor + toReturn.fogOfWarColor = fogOfWarColor + toReturn.fallbackTileSet = fallbackTileSet + toReturn.tileScale = tileScale + toReturn.ruleVariants.putAll(ruleVariants.map { Pair(it.key, it.value.clone()) }) + return toReturn + } + + fun updateConfig(other: TileSetConfig) { useColorAsBaseTerrain = other.useColorAsBaseTerrain unexploredTileColor = other.unexploredTileColor fogOfWarColor = other.fogOfWarColor