Bazaar developer reference

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

Defined in
CvDealAI.cpp, line 3037
Class
CvDealAI
Hook name
CivHooks::CvDealAI_DoAddGPTToUs

Hooks

static bool BeforeCvDealAI_DoAddGPTToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);static void AfterCvDealAI_DoAddGPTToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddGPTToUs(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, int, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddGPTToUs>(host, &BeforeCvDealAI_DoAddGPTToUs);CivRegisterAfter<CivHooks::CvDealAI_DoAddGPTToUs>(host, &AfterCvDealAI_DoAddGPTToUs);CivRegisterReplace<CivHooks::CvDealAI_DoAddGPTToUs>(host, &ReplaceCvDealAI_DoAddGPTToUs);

Code

3036/// See if adding Gold Per Turn to our side of the deal helps even out pDeal3037void CvDealAI::DoAddGPTToUs(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iDealDuration, bool bUseEvenValue)3038{3039	CvAssert(eThem >= 0);3040	CvAssert(eThem < MAX_MAJOR_CIVS);3041	CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add GPT to Us, but them is us.  Please show Jon");30423043	if(!bDontChangeMyExistingItems)3044	{3045		if(iTotalValue > 0)3046		{3047			PlayerTypes eMyPlayer = GetPlayer()->GetID();30483049			if(GET_PLAYER(eMyPlayer).calculateGoldRate() > 0)3050			{3051				// Can't already be GPT from the other player in the Deal3052				if(pDeal->GetGoldPerTurnTrade(eThem) == 0)3053				{3054					int iNumGPT = GetGPTforForValueExchange(iTotalValue, /*bNumGPTFromValue*/ true, iDealDuration, /*bFromMe*/ true, eThem, bUseEvenValue, /*bRoundUp*/ false);3055					int iNumGPTAlreadyInTrade = pDeal->GetGoldPerTurnTrade(eMyPlayer);3056					iNumGPT += iNumGPTAlreadyInTrade;3057					iNumGPT = min(iNumGPT, GET_PLAYER(eMyPlayer).calculateGoldRate());30583059					if(iNumGPT != iNumGPTAlreadyInTrade && !pDeal->ChangeGoldPerTurnTrade(eMyPlayer, iNumGPT, iDealDuration))3060					{3061						pDeal->AddGoldPerTurnTrade(eMyPlayer, iNumGPT, iDealDuration);3062					}30633064					iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);3065				}3066			}3067		}3068	}3069}

Calls

Called by