Fix disappearing terrain when switching between mods (#7257)

This commit is contained in:
OptimizedForDensity 2022-06-22 02:08:38 -04:00 committed by GitHub
parent 83926eac7c
commit 7de3fdf452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -32,7 +32,7 @@ object TileSetCache : HashMap<String, TileSetConfig>() {
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()
}
}
}

View File

@ -12,7 +12,18 @@ class TileSetConfig {
var tileScale: Float = 1f
var ruleVariants: HashMap<String, Array<String>> = 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