Preserve mod order in ruleset and game parameters

This commit is contained in:
Yair Morgenstern 2020-04-13 11:08:59 +03:00
parent 6fa22a92a1
commit efc131c863
3 changed files with 49 additions and 50 deletions

View file

@ -21,7 +21,7 @@ class GameParameters { // Default values are the default new game
var startingEra = TechEra.Ancient
var isOnlineMultiplayer = false
var mods = HashSet<String>()
var mods = LinkedHashSet<String>()
fun clone(): GameParameters {
val parameters = GameParameters()
@ -34,7 +34,7 @@ class GameParameters { // Default values are the default new game
parameters.victoryTypes = ArrayList(victoryTypes)
parameters.startingEra = startingEra
parameters.isOnlineMultiplayer = isOnlineMultiplayer
parameters.mods= HashSet(mods)
parameters.mods = LinkedHashSet(mods)
return parameters
}
}

View file

@ -29,7 +29,7 @@ class Ruleset() {
val nations = LinkedHashMap<String, Nation>()
val policyBranches = LinkedHashMap<String, PolicyBranch>()
val difficulties = LinkedHashMap<String, Difficulty>()
val mods = HashSet<String>()
val mods = LinkedHashSet<String>()
fun clone(): Ruleset {
val newRuleset = Ruleset()
@ -158,8 +158,7 @@ object RulesetCache :HashMap<String,Ruleset>(){
modRuleset.name = modFolder.name()
this[modRuleset.name] = modRuleset
println("Mod loaded successfully: " + modRuleset.name)
}
catch (ex:Exception){
} catch (ex: Exception) {
println("Exception loading mod '${modFolder.name()}':")
println(" ${ex.localizedMessage}")
println(" (Source file ${ex.stackTrace[0].fileName} line ${ex.stackTrace[0].lineNumber})")