Hooks
static bool BeforeCvDealAI_DoRemoveGoldFromThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void AfterCvDealAI_DoRemoveGoldFromThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void ReplaceCvDealAI_DoRemoveGoldFromThem(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, int&, int&, int&, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoRemoveGoldFromThem>(host, &BeforeCvDealAI_DoRemoveGoldFromThem);CivRegisterAfter<CivHooks::CvDealAI_DoRemoveGoldFromThem>(host, &AfterCvDealAI_DoRemoveGoldFromThem);CivRegisterReplace<CivHooks::CvDealAI_DoRemoveGoldFromThem>(host, &ReplaceCvDealAI_DoRemoveGoldFromThem);
Code
3163/// See if removing Gold from their side of the deal helps even out pDeal3164void CvDealAI::DoRemoveGoldFromThem(CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue)3165{3166 CvAssert(eThem >= 0);3167 CvAssert(eThem < MAX_MAJOR_CIVS);3168 CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to remove Gold from Them, but them is us. Please show Jon");31693170// if (!bDontChangeTheirExistingItems)3171 {3172 if(iTotalValue > 0)3173 {3174 int iNumGoldInThisDeal = pDeal->GetGoldTrade(eThem);3175 if(iNumGoldInThisDeal > 0)3176 {3177 // Found some Gold to remove3178 int iNumGoldToRemove = min(iNumGoldInThisDeal, GetGoldForForValueExchange(iTotalValue, /*bNumGoldFromValue*/ true, /*bFromMe*/ false, eThem, bUseEvenValue, /*bRoundUp*/ true));3179 iNumGoldInThisDeal -= iNumGoldToRemove;31803181 // Removing ALL Gold, so just erase the item from the deal3182 if(iNumGoldInThisDeal == 0)3183 {3184 pDeal->RemoveByType(TRADE_ITEM_GOLD);3185 iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);3186 }3187 // Remove some of the Gold from the deal3188 else3189 {3190 if(!pDeal->ChangeGoldTrade(eThem, iNumGoldInThisDeal))3191 {3192 CvAssertMsg(false, "DEAL_AI: DealAI is trying to remove Gold from a deal but couldn't find the item for some reason. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");3193 }31943195 iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);3196 }3197 }3198 }3199 }3200}