mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
Probably resolved #5555 - made tileset config overrides deterministic
This commit is contained in:
@ -16,19 +16,21 @@ object TileSetCache : HashMap<String, TileSetConfig>() {
|
||||
* Other active mods can be passed in parameter [ruleSetMods], if that is `null` and a game is in
|
||||
* progress, that game's mods are used instead.
|
||||
*/
|
||||
fun assembleTileSetConfigs(ruleSetMods: HashSet<String>? = null) {
|
||||
val mods = mutableSetOf("")
|
||||
fun assembleTileSetConfigs(ruleSetMods: Set<String>) {
|
||||
// Needs to be a list and not a set, so subsequent mods override the previous ones
|
||||
// Otherwise you rely on hash randomness to determine override order... not good
|
||||
val mods = mutableListOf("")
|
||||
if (UncivGame.isCurrentInitialized()) {
|
||||
mods.addAll(UncivGame.Current.settings.visualMods)
|
||||
if (ruleSetMods != null)
|
||||
mods.addAll(ruleSetMods)
|
||||
else if (UncivGame.Current.isGameInfoInitialized())
|
||||
mods.addAll(UncivGame.Current.gameInfo.ruleSet.mods)
|
||||
mods.addAll(ruleSetMods)
|
||||
}
|
||||
clear()
|
||||
allConfigs.filter { it.key.mod in mods }.forEach {
|
||||
if (it.key.tileSet in this) this[it.key.tileSet]!!.updateConfig(it.value)
|
||||
else this[it.key.tileSet] = it.value
|
||||
for (mod in mods.distinct()) {
|
||||
val entry = allConfigs.entries.firstOrNull { it.key.mod == mod } ?: continue
|
||||
|
||||
val tileSet = entry.key.tileSet
|
||||
if (tileSet in this) this[tileSet]!!.updateConfig(entry.value)
|
||||
else this[tileSet] = entry.value
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,6 +92,6 @@ object TileSetCache : HashMap<String, TileSetConfig>() {
|
||||
}
|
||||
}
|
||||
|
||||
assembleTileSetConfigs()
|
||||
assembleTileSetConfigs(hashSetOf()) // no game is loaded, this is just the initial game setup
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ object ImageGetter {
|
||||
loadModAtlases("", Gdx.files.internal(""))
|
||||
|
||||
// These are from the mods
|
||||
for (mod in UncivGame.Current.settings.visualMods + ruleset.mods) {
|
||||
val visualMods = UncivGame.Current.settings.visualMods + ruleset.mods
|
||||
for (mod in visualMods) {
|
||||
loadModAtlases(mod, Gdx.files.local("mods/$mod"))
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,8 @@ class OptionsPopup(val previousScreen: CameraStageBaseScreen) : Popup(previousSc
|
||||
|
||||
tileSetSelectBox.onChange {
|
||||
settings.tileSet = tileSetSelectBox.selected
|
||||
TileSetCache.assembleTileSetConfigs()
|
||||
// ImageGetter ruleset should be correct no matter what screen we're on
|
||||
TileSetCache.assembleTileSetConfigs(ImageGetter.ruleset.mods)
|
||||
reloadWorldAndOptions()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user