mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 12:54:06 -04:00
Resolved #1835 - game no longer crashes when losing alliance with a city-state due to it being captured
This commit is contained in:
parent
24c3bdc564
commit
0f26671bcf
@ -542,15 +542,19 @@ class CivilizationInfo {
|
|||||||
val oldAllyName = allyCivName
|
val oldAllyName = allyCivName
|
||||||
allyCivName = newAllyName
|
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 != "") {
|
if (newAllyName != "") {
|
||||||
val newAllyCiv = gameInfo.getCivilization(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.updateViewableTiles()
|
||||||
newAllyCiv.updateDetailedCivResources()
|
newAllyCiv.updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
if (oldAllyName != "") {
|
if (oldAllyName != "") {
|
||||||
val oldAllyCiv = gameInfo.getCivilization(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.updateViewableTiles()
|
||||||
oldAllyCiv.updateDetailedCivResources()
|
oldAllyCiv.updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
|
@ -226,8 +226,9 @@ class DiplomacyManager() {
|
|||||||
* This includes friendly and allied city-states and the open border treaties.
|
* This includes friendly and allied city-states and the open border treaties.
|
||||||
*/
|
*/
|
||||||
fun isConsideredAllyTerritory(): Boolean {
|
fun isConsideredAllyTerritory(): Boolean {
|
||||||
return (hasOpenBorders)
|
if(civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
|
||||||
|| (civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
|
return true
|
||||||
|
return hasOpenBorders
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user