Fixed concurrent modification from triggers adding other triggers

This commit is contained in:
yairm210 2024-04-06 23:30:28 +03:00
parent 802a206c53
commit 5263140911

View File

@ -496,7 +496,7 @@ class Civilization : IsPartOfGameInfoSerialization {
fun getTriggeredUniques(
trigger: UniqueType,
stateForConditionals: StateForConditionals = StateForConditionals(this)
) : Sequence<Unique> = sequence {
) : Iterable<Unique> = sequence {
yieldAll(nation.uniqueMap.getTriggeredUniques(trigger, stateForConditionals))
yieldAll(cities.asSequence()
.flatMap { city -> city.cityConstructions.builtBuildingUniqueMap.getTriggeredUniques(trigger, stateForConditionals) }
@ -509,7 +509,7 @@ class Civilization : IsPartOfGameInfoSerialization {
yieldAll(tech.techUniques.getTriggeredUniques(trigger, stateForConditionals))
yieldAll(getEra().uniqueMap.getTriggeredUniques (trigger, stateForConditionals))
yieldAll(gameInfo.ruleset.globalUniques.uniqueMap.getTriggeredUniques(trigger, stateForConditionals))
}
}.toList() // Triggers can e.g. add buildings which contain triggers, causing concurrent modification errors
fun matchesFilter(filter: String): Boolean {
return MultiFilter.multiFilter(filter, ::matchesSingleFilter)