diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index 1512ea1a54..730e8194cb 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.4.30" const val appName = "Unciv" - const val appCodeNumber = 572 - const val appVersion = "3.14.13" + const val appCodeNumber = 573 + const val appVersion = "3.14.13-patch1" const val gdxVersion = "1.10.0" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index ec14fad2cc..5256571d92 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -317,22 +317,31 @@ class Ruleset { lines += "${terrain.name} occurs on terrain $baseTerrain which does not exist!" } + val prereqsHashMap = HashMap>() for (tech in technologies.values) { for (prereq in tech.prerequisites) { if (!technologies.containsKey(prereq)) lines += "${tech.name} requires tech $prereq which does not exist!" - fun getPrereqTree(technologyName: String): Sequence { + fun getPrereqTree(technologyName: String): Set { + if (prereqsHashMap.containsKey(technologyName)) return prereqsHashMap[technologyName]!! val technology = technologies[technologyName] - if (technology == null) return sequenceOf() - return technology.prerequisites.asSequence() + technology.prerequisites.asSequence().flatMap { getPrereqTree(it) } + if (technology == null) return emptySet() + val techHashSet = HashSet() + techHashSet += technology.prerequisites + for (prereq in technology.prerequisites) + techHashSet += getPrereqTree(prereq) + prereqsHashMap[technologyName] = techHashSet + return techHashSet } - val allOtherPrereqs = tech.prerequisites.asSequence().filterNot { it == prereq }.flatMap { getPrereqTree(it) } - if (allOtherPrereqs.contains(prereq)) - lines += "No need to add $prereq as a prerequisite of ${tech.name} - it is already implicit from the other prerequisites!" + if (tech.prerequisites.asSequence().filterNot { it == prereq } + .any { getPrereqTree(it).contains(prereq) }) + println("No need to add $prereq as a prerequisite of ${tech.name} - it is already implicit from the other prerequisites!") } } + + return lines.joinToString("\n") } }