Hooks
static bool BeforeCvDeal_AddThirdPartyEmbargo(CvDeal* self, PlayerTypes eFrom, PlayerTypes eThirdParty, int iDuration);static void AfterCvDeal_AddThirdPartyEmbargo(CvDeal* self, PlayerTypes eFrom, PlayerTypes eThirdParty, int iDuration);static void ReplaceCvDeal_AddThirdPartyEmbargo(void (*original)(CvDeal*, PlayerTypes, PlayerTypes, int), CvDeal* self, PlayerTypes eFrom, PlayerTypes eThirdParty, int iDuration);CivRegisterBefore<CivHooks::CvDeal_AddThirdPartyEmbargo>(host, &BeforeCvDeal_AddThirdPartyEmbargo);CivRegisterAfter<CivHooks::CvDeal_AddThirdPartyEmbargo>(host, &AfterCvDeal_AddThirdPartyEmbargo);CivRegisterReplace<CivHooks::CvDeal_AddThirdPartyEmbargo>(host, &ReplaceCvDeal_AddThirdPartyEmbargo);
Code
1299/// Insert starting an embargo on a third party1300void CvDeal::AddThirdPartyEmbargo(PlayerTypes eFrom, PlayerTypes eThirdParty, int iDuration)1301{1302 CvAssertMsg(iDuration >= 0, "DEAL: Trying to add a negative duration to a TradeItem. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");1303 CvAssertMsg(iDuration < GC.getGame().getEstimateEndTurn() * 2, "DEAL: Trade item has a crazy long duration (probably invalid). Please send Jon this with your last 5 autosaves and what changelist # you're playing.");1304 CvAssertMsg(eFrom == m_eFromPlayer || eFrom == m_eToPlayer, "DEAL: Adding deal item for a player that's not actually in this deal! Please send Jon this with your last 5 autosaves and what changelist # you're playing.");13051306 if(IsPossibleToTradeItem(eFrom, GetOtherPlayer(eFrom), TRADE_ITEM_THIRD_PARTY_EMBARGO, eThirdParty, iDuration))1307 {1308 CvTradedItem item;1309 item.m_eItemType = TRADE_ITEM_THIRD_PARTY_EMBARGO;1310 item.m_iDuration = iDuration;1311 //item.m_iFinalTurn = iDuration + GC.getGame().getGameTurn();1312 item.m_iFinalTurn = -1;1313 item.m_iData1 = eThirdParty;1314 item.m_eFromPlayer = eFrom;1315 m_TradedItems.push_back(item);1316 }1317 else1318 {1319 CvAssertMsg(false, "DEAL: Trying to add an invalid Third Party Embargo item to a deal");1320 }1321}