mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 08:49:22 +07:00
Resolved crash when mods make 2 techs require each other
This commit is contained in:
@ -751,9 +751,9 @@ class Ruleset {
|
||||
?: return emptySet()
|
||||
val techHashSet = HashSet<String>()
|
||||
techHashSet += technology.prerequisites
|
||||
prereqsHashMap[technologyName] = techHashSet
|
||||
for (prerequisite in technology.prerequisites)
|
||||
techHashSet += getPrereqTree(prerequisite)
|
||||
prereqsHashMap[technologyName] = techHashSet
|
||||
return techHashSet
|
||||
}
|
||||
|
||||
@ -762,6 +762,9 @@ class Ruleset {
|
||||
lines.add("No need to add $prereq as a prerequisite of ${tech.name} - it is already implicit from the other prerequisites!",
|
||||
RulesetErrorSeverity.Warning)
|
||||
}
|
||||
|
||||
if (getPrereqTree(prereq).contains(tech.name))
|
||||
lines += "Techs ${tech.name} and $prereq require each other!"
|
||||
}
|
||||
if (tech.era() !in eras)
|
||||
lines += "Unknown era ${tech.era()} referenced in column of tech ${tech.name}"
|
||||
|
@ -1724,6 +1724,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
|
||||
Applicable to: Conditional
|
||||
|
||||
??? example "<upon discovering [tech]>"
|
||||
Example: "<upon discovering [Agriculture]>"
|
||||
|
||||
Applicable to: Conditional
|
||||
|
||||
??? example "<after adopting [policy]>"
|
||||
Example: "<after adopting [Oligarchy]>"
|
||||
|
||||
|
26
tests/src/com/unciv/uniques/UniqueErrorTests.kt
Normal file
26
tests/src/com/unciv/uniques/UniqueErrorTests.kt
Normal file
@ -0,0 +1,26 @@
|
||||
package com.unciv.uniques
|
||||
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.testing.GdxTestRunner
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
|
||||
@RunWith(GdxTestRunner::class)
|
||||
class UniqueErrorTests {
|
||||
@Test
|
||||
fun testCodependantTechs() {
|
||||
RulesetCache.loadRulesets()
|
||||
val ruleset = RulesetCache.getVanillaRuleset()
|
||||
|
||||
// Create a prerequisite loop
|
||||
val techWithPrerequisites = ruleset.technologies.values.first { it.prerequisites.isNotEmpty() }
|
||||
val prereq = ruleset.technologies[techWithPrerequisites.prerequisites.first()]!!
|
||||
prereq.prerequisites.add(techWithPrerequisites.name)
|
||||
ruleset.modOptions.isBaseRuleset = true
|
||||
|
||||
// Check mod links and ensure we don't get a crash, instead we get errors
|
||||
val errors = ruleset.checkModLinks(false)
|
||||
assert(errors.isNotOK())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user