Resolved #1835 - game no longer crashes when losing alliance with a city-state due to it being captured

This commit is contained in:
Yair Morgenstern 2020-02-03 16:24:10 +02:00
parent 24c3bdc564
commit 0f26671bcf
2 changed files with 9 additions and 4 deletions

View File

@ -542,15 +542,19 @@ class CivilizationInfo {
val oldAllyName = allyCivName
allyCivName = newAllyName
// If the city-state is captured by a civ, it stops being the ally of the civ it was previously an ally of.
// This means that it will NOT HAVE a capital at that time, so if we run getCapital we'll get a crash!
val capitalLocation = if(cities.isNotEmpty()) getCapital().location else null
if (newAllyName != "") {
val newAllyCiv = gameInfo.getCivilization(newAllyName)
newAllyCiv.addNotification("We have allied with [${civName}].", getCapital().location, Color.GREEN)
newAllyCiv.addNotification("We have allied with [${civName}].", capitalLocation, Color.GREEN)
newAllyCiv.updateViewableTiles()
newAllyCiv.updateDetailedCivResources()
}
if (oldAllyName != "") {
val oldAllyCiv = gameInfo.getCivilization(oldAllyName)
oldAllyCiv.addNotification("We have lost alliance with [${civName}].", getCapital().location, Color.RED)
oldAllyCiv.addNotification("We have lost alliance with [${civName}].", capitalLocation, Color.RED)
oldAllyCiv.updateViewableTiles()
oldAllyCiv.updateDetailedCivResources()
}

View File

@ -226,8 +226,9 @@ class DiplomacyManager() {
* This includes friendly and allied city-states and the open border treaties.
*/
fun isConsideredAllyTerritory(): Boolean {
return (hasOpenBorders)
|| (civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
if(civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
return true
return hasOpenBorders
}
//endregion