mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 21:30:20 +07:00
Fix "ask for help" crash (#11712)
* Solved combat resource conditionals vs cities being checked against the target's resources * Crash fix - Don't attempt to ask civs you don't know for help
This commit is contained in:
@ -337,7 +337,9 @@ object DiplomacyAutomation {
|
||||
|
||||
for (enemyCiv in civInfo.getCivsAtWarWith().sortedByDescending { it.getStatForRanking(RankingType.Force) }) {
|
||||
val potentialAllies = enemyCiv.threatManager.getNeighboringCivilizations()
|
||||
.filter { !it.isAtWarWith(enemyCiv) && civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Friend)
|
||||
.filter {
|
||||
civInfo.knows(it) && !it.isAtWarWith(enemyCiv)
|
||||
&& civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Friend)
|
||||
&& !it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclinedJoinWarOffer) }
|
||||
.sortedByDescending { it.getStatForRanking(RankingType.Force) }
|
||||
val civToAsk = potentialAllies.firstOrNull {
|
||||
|
@ -54,8 +54,16 @@ data class StateForConditionals(
|
||||
}
|
||||
|
||||
val relevantCity by lazy {
|
||||
city
|
||||
?: relevantTile?.getCity()
|
||||
if (city != null) return@lazy city
|
||||
// Edge case: If we attack a city, the "relevant tile" becomes the attacked tile -
|
||||
// but we DO NOT want that city to become the relevant city because then *our* conditionals get checked against
|
||||
// the *other civ's* cities, leading to e.g. resource amounts being defined as the *other civ's* resource amounts
|
||||
val relevantTileForCity = tile ?: relevantUnit?.run { if (hasTile()) getTile() else null }
|
||||
val cityForRelevantTile = relevantTileForCity?.getCity()
|
||||
if (cityForRelevantTile != null &&
|
||||
// ...and we can't use the relevantCiv here either, because that'll cause a loop
|
||||
(cityForRelevantTile.civ == civInfo || cityForRelevantTile.civ == relevantUnit?.civ)) return@lazy cityForRelevantTile
|
||||
else return@lazy null
|
||||
}
|
||||
|
||||
val relevantCiv by lazy {
|
||||
|
Reference in New Issue
Block a user