Fixed a crash in badly defined mods (#4598)

This commit is contained in:
Xander Lenstra 2021-07-21 23:37:54 +02:00 committed by GitHub
parent 2971e6bba3
commit 54df4ba0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -779,6 +779,8 @@ class CivilizationInfo {
val givingCityState = getKnownCivs().filter { it.isCityState() && it.getAllyCiv() == civName}.random()
var giftableUnits = gameInfo.ruleSet.units.values.filter { it.isGreatPerson() }
if (!gameInfo.hasReligionEnabled()) giftableUnits = giftableUnits.filterNot { it.uniques.contains("Great Person - [Faith]")}
if (giftableUnits.isEmpty()) // For badly defined mods that don't have great people but do have the policy that makes city states grant them
return
val giftedUnit = giftableUnits.random()
val cities = NextTurnAutomation.getClosestCities(this, givingCityState)
val placedUnit = placeUnitNearTile(cities.city1.location, giftedUnit.name)