#9876 fix - Lock known city states before gaining influence to avoid altering the sequence we're iterating on

This commit is contained in:
Yair Morgenstern 2023-08-04 09:29:34 +03:00
parent d9ceb9290d
commit af49e8297f

View File

@ -293,7 +293,9 @@ object NextTurnAutomation {
}
private fun useGoldForCityStates(civ: Civilization) {
val knownCityStates = civ.getKnownCivs().filter { it.isCityState() }
// RARE EDGE CASE: If you ally with a city-state, you may reveal more map that includes ANOTHER civ!
// So if we don't lock this list, we may later discover that there are more known civs, concurrent modification exception!
val knownCityStates = civ.getKnownCivs().filter { it.isCityState() }.toList()
// canBeMarriedBy checks actual cost, but it can't be below 500*speedmodifier, and the later check is expensive
if (civ.gold >= 330 && civ.getHappiness() > 0 && civ.hasUnique(UniqueType.CityStateCanBeBoughtForGold)) {