Bazaar developer reference

CvDealAI::DoRemoveGPTFromUs(CvDeal *, PlayerTypes, int &, int &, int &, int, bool)

Defined in
CvDealAI.cpp, line 3117
Class
CvDealAI
Hook name
CivHooks::CvDealAI_DoRemoveGPTFromUs

Hooks

static bool BeforeCvDealAI_DoRemoveGPTFromUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);static void AfterCvDealAI_DoRemoveGPTFromUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);static void ReplaceCvDealAI_DoRemoveGPTFromUs(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, int&, int&, int&, int, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoRemoveGPTFromUs>(host, &BeforeCvDealAI_DoRemoveGPTFromUs);CivRegisterAfter<CivHooks::CvDealAI_DoRemoveGPTFromUs>(host, &AfterCvDealAI_DoRemoveGPTFromUs);CivRegisterReplace<CivHooks::CvDealAI_DoRemoveGPTFromUs>(host, &ReplaceCvDealAI_DoRemoveGPTFromUs);

Code

3116/// See if removing Gold Per Turn from our side of the deal helps even out pDeal3117void CvDealAI::DoRemoveGPTFromUs(CvDeal* pDeal, PlayerTypes eThem, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue)3118{3119	CvAssert(eThem >= 0);3120	CvAssert(eThem < MAX_MAJOR_CIVS);3121	CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to remove GPT from Us, but them is us.  Please show Jon");31223123//	if (!bDontChangeMyExistingItems)3124	{3125		if(iTotalValue < 0)3126		{3127			// Try to remove a bit more than the actual value discrepancy, as this should get us closer to even in the long-run3128			int iValueToRemove = -iTotalValue * 150;3129			iValueToRemove /= 100;31303131			int iNumGoldPerTurnToRemove = GetGPTforForValueExchange(iValueToRemove, /*bNumGPTFromValue*/ true, iDealDuration, /*bFromMe*/ true, eThem, bUseEvenValue, /*bRoundUp*/ true);31323133			PlayerTypes eMyPlayer = GetPlayer()->GetID();31343135			int iNumGoldPerTurnInThisDeal = pDeal->GetGoldPerTurnTrade(eMyPlayer);3136			if(iNumGoldPerTurnInThisDeal > 0)3137			{3138				// Found some GoldPerTurn to remove3139				iNumGoldPerTurnToRemove = min(iNumGoldPerTurnToRemove, iNumGoldPerTurnInThisDeal);3140				iNumGoldPerTurnInThisDeal -= iNumGoldPerTurnToRemove;31413142				// Removing ALL GoldPerTurn, so just erase the item from the deal3143				if(iNumGoldPerTurnInThisDeal == 0)3144				{3145					pDeal->RemoveByType(TRADE_ITEM_GOLD_PER_TURN);3146					iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);3147				}3148				// Remove some of the GoldPerTurn from the deal3149				else3150				{3151					if(!pDeal->ChangeGoldPerTurnTrade(eMyPlayer, iNumGoldPerTurnInThisDeal, iDealDuration))3152					{3153						CvAssertMsg(false, "DEAL_AI: DealAI is trying to remove GoldPerTurn 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.");3154					}31553156					iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);3157				}3158			}3159		}3160	}3161}

Calls

Called by