mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 08:49:22 +07:00
Resolved #8766 - gifting cities no longer causes crash
This commit is contained in:
@ -133,6 +133,12 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentTrade.ourOffers.isEmpty()){ // Must evaluate before moving, or else cities have already moved and we get an exception
|
||||||
|
val goldValueOfTrade = TradeEvaluation().getTradeAcceptability(currentTrade, ourCivilization, otherCivilization)
|
||||||
|
val diplomaticValueOfTrade = CityStateFunctions(ourCivilization).influenceGainedByGift(otherCivilization, goldValueOfTrade) / 10
|
||||||
|
ourCivilization.getDiplomacyManager(otherCivilization).addModifier(DiplomaticModifiers.GaveUsGifts, diplomaticValueOfTrade.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
// Transfer of cities needs to happen before peace treaty, to avoid our units teleporting out of areas that soon will be ours
|
// Transfer of cities needs to happen before peace treaty, to avoid our units teleporting out of areas that soon will be ours
|
||||||
for (offer in currentTrade.theirOffers.filterNot { it.type == TradeType.Treaty })
|
for (offer in currentTrade.theirOffers.filterNot { it.type == TradeType.Treaty })
|
||||||
transferTrade(otherCivilization, ourCivilization, offer)
|
transferTrade(otherCivilization, ourCivilization, offer)
|
||||||
@ -144,12 +150,6 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
|
|||||||
for (offer in currentTrade.ourOffers.filter { it.type == TradeType.Treaty })
|
for (offer in currentTrade.ourOffers.filter { it.type == TradeType.Treaty })
|
||||||
transferTrade(ourCivilization, otherCivilization, offer)
|
transferTrade(ourCivilization, otherCivilization, offer)
|
||||||
|
|
||||||
if (currentTrade.ourOffers.isEmpty()){
|
|
||||||
val goldValueOfTrade = TradeEvaluation().getTradeAcceptability(currentTrade, ourCivilization, otherCivilization)
|
|
||||||
val diplomaticValueOfTrade = CityStateFunctions(ourCivilization).influenceGainedByGift(otherCivilization, goldValueOfTrade) / 10
|
|
||||||
ourCivilization.getDiplomacyManager(otherCivilization).addModifier(DiplomaticModifiers.GaveUsGifts, diplomaticValueOfTrade.toFloat())
|
|
||||||
}
|
|
||||||
|
|
||||||
ourCivilization.cache.updateCivResources()
|
ourCivilization.cache.updateCivResources()
|
||||||
ourCivilization.updateStatsForNextTurn()
|
ourCivilization.updateStatsForNextTurn()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user