mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 15:27:27 +07:00
Rewrote 'check unneeded tech prerequisites' that was causing ANRs and lowered time from 714ms to 1ms on my computer (!) for RekMOD check.
Also removed it from being blocking, since some important older mods (e.g. DeCiv) are unplayable because of this.
This commit is contained in:
parent
efe369ad19
commit
a70bb43dae
@ -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"
|
||||
|
@ -317,22 +317,31 @@ class Ruleset {
|
||||
lines += "${terrain.name} occurs on terrain $baseTerrain which does not exist!"
|
||||
}
|
||||
|
||||
val prereqsHashMap = HashMap<String,HashSet<String>>()
|
||||
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<String> {
|
||||
fun getPrereqTree(technologyName: String): Set<String> {
|
||||
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<String>()
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user