Removed double notifications and processing of treaties when traded (#10101)

* Removed double notifications and processing of treaties when traded

* Added comment to only processing one side of the trade
This commit is contained in:
Oskar Niesen 2023-09-13 02:28:07 -05:00 committed by GitHub
parent 8e3ebc7724
commit 16d716d794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,13 +124,17 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
to.popupAlerts.add(PopupAlert(AlertType.CityTraded, city.id))
}
TradeType.Treaty -> {
// Note: Treaties are not transfered from both sides due to notifications and double signing
if (offer.name == Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace()
if (offer.name == Constants.researchAgreement) {
to.addGold(-offer.amount)
from.addGold(-offer.amount)
to.getDiplomacyManager(from)
.setFlag(DiplomacyFlags.ResearchAgreement, offer.duration)
from.getDiplomacyManager(to)
.setFlag(DiplomacyFlags.ResearchAgreement, offer.duration)
}
if (offer.name == Constants.defensivePact) from.getDiplomacyManager(to).signDefensivePact(offer.duration);
if (offer.name == Constants.defensivePact) to.getDiplomacyManager(from).signDefensivePact(offer.duration);
}
TradeType.Introduction -> to.diplomacyFunctions.makeCivilizationsMeet(to.gameInfo.getCivilization(offer.name))
TradeType.WarDeclaration -> {
@ -153,10 +157,9 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
for (offer in currentTrade.ourOffers.filterNot { it.type == TradeType.Treaty })
transferTrade(ourCivilization, otherCivilization, offer)
// Transfter of treaties should only be done from one side to avoid double signing and notifying
for (offer in currentTrade.theirOffers.filter { it.type == TradeType.Treaty })
transferTrade(otherCivilization, ourCivilization, offer)
for (offer in currentTrade.ourOffers.filter { it.type == TradeType.Treaty })
transferTrade(ourCivilization, otherCivilization, offer)
ourCivilization.cache.updateCivResources()
ourCivilization.updateStatsForNextTurn()