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
|
* 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.
|
* progress, that game's mods are used instead.
|
||||||
*/
|
*/
|
||||||
fun assembleTileSetConfigs(ruleSetMods: HashSet<String>? = null) {
|
fun assembleTileSetConfigs(ruleSetMods: Set<String>) {
|
||||||
val mods = mutableSetOf("")
|
// 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()) {
|
if (UncivGame.isCurrentInitialized()) {
|
||||||
mods.addAll(UncivGame.Current.settings.visualMods)
|
mods.addAll(UncivGame.Current.settings.visualMods)
|
||||||
if (ruleSetMods != null)
|
mods.addAll(ruleSetMods)
|
||||||
mods.addAll(ruleSetMods)
|
|
||||||
else if (UncivGame.Current.isGameInfoInitialized())
|
|
||||||
mods.addAll(UncivGame.Current.gameInfo.ruleSet.mods)
|
|
||||||
}
|
}
|
||||||
clear()
|
clear()
|
||||||
allConfigs.filter { it.key.mod in mods }.forEach {
|
for (mod in mods.distinct()) {
|
||||||
if (it.key.tileSet in this) this[it.key.tileSet]!!.updateConfig(it.value)
|
val entry = allConfigs.entries.firstOrNull { it.key.mod == mod } ?: continue
|
||||||
else this[it.key.tileSet] = it.value
|
|
||||||
|
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(""))
|
loadModAtlases("", Gdx.files.internal(""))
|
||||||
|
|
||||||
// These are from the mods
|
// 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"))
|
loadModAtlases(mod, Gdx.files.local("mods/$mod"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,8 @@ class OptionsPopup(val previousScreen: CameraStageBaseScreen) : Popup(previousSc
|
|||||||
|
|
||||||
tileSetSelectBox.onChange {
|
tileSetSelectBox.onChange {
|
||||||
settings.tileSet = tileSetSelectBox.selected
|
settings.tileSet = tileSetSelectBox.selected
|
||||||
TileSetCache.assembleTileSetConfigs()
|
// ImageGetter ruleset should be correct no matter what screen we're on
|
||||||
|
TileSetCache.assembleTileSetConfigs(ImageGetter.ruleset.mods)
|
||||||
reloadWorldAndOptions()
|
reloadWorldAndOptions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user