diff --git a/core/src/com/unciv/models/tilesets/TileSetCache.kt b/core/src/com/unciv/models/tilesets/TileSetCache.kt index cd42b9a6b6..1eb502f974 100644 --- a/core/src/com/unciv/models/tilesets/TileSetCache.kt +++ b/core/src/com/unciv/models/tilesets/TileSetCache.kt @@ -16,19 +16,21 @@ object TileSetCache : HashMap() { * 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? = null) { - val mods = mutableSetOf("") + fun assembleTileSetConfigs(ruleSetMods: Set) { + // 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() { } } - assembleTileSetConfigs() + assembleTileSetConfigs(hashSetOf()) // no game is loaded, this is just the initial game setup } } diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 33c73401d4..9b4f2af895 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -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")) } diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt index 237bb7cb52..38490cb773 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/OptionsPopup.kt @@ -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() } }