Skip to content

Commit 0f26671

Browse files
committed
Resolved #1835 - game no longer crashes when losing alliance with a city-state due to it being captured
1 parent 24c3bdc commit 0f26671

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

core/src/com/unciv/logic/civilization/CivilizationInfo.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,15 +542,19 @@ class CivilizationInfo {
542542
val oldAllyName = allyCivName
543543
allyCivName = newAllyName
544544

545+
// If the city-state is captured by a civ, it stops being the ally of the civ it was previously an ally of.
546+
// This means that it will NOT HAVE a capital at that time, so if we run getCapital we'll get a crash!
547+
val capitalLocation = if(cities.isNotEmpty()) getCapital().location else null
548+
545549
if (newAllyName != "") {
546550
val newAllyCiv = gameInfo.getCivilization(newAllyName)
547-
newAllyCiv.addNotification("We have allied with [${civName}].", getCapital().location, Color.GREEN)
551+
newAllyCiv.addNotification("We have allied with [${civName}].", capitalLocation, Color.GREEN)
548552
newAllyCiv.updateViewableTiles()
549553
newAllyCiv.updateDetailedCivResources()
550554
}
551555
if (oldAllyName != "") {
552556
val oldAllyCiv = gameInfo.getCivilization(oldAllyName)
553-
oldAllyCiv.addNotification("We have lost alliance with [${civName}].", getCapital().location, Color.RED)
557+
oldAllyCiv.addNotification("We have lost alliance with [${civName}].", capitalLocation, Color.RED)
554558
oldAllyCiv.updateViewableTiles()
555559
oldAllyCiv.updateDetailedCivResources()
556560
}

core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ class DiplomacyManager() {
226226
* This includes friendly and allied city-states and the open border treaties.
227227
*/
228228
fun isConsideredAllyTerritory(): Boolean {
229-
return (hasOpenBorders)
230-
|| (civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
229+
if(civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
230+
return true
231+
return hasOpenBorders
231232
}
232233
//endregion
233234

0 commit comments

Comments
 (0)