Bazaar developer reference

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

Defined in
CvDealAI.cpp, line 2936
Class
CvDealAI
Hook name
CivHooks::CvDealAI_DoAddGoldToThem

Hooks

static bool BeforeCvDealAI_DoAddGoldToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void AfterCvDealAI_DoAddGoldToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddGoldToThem(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddGoldToThem>(host, &BeforeCvDealAI_DoAddGoldToThem);CivRegisterAfter<CivHooks::CvDealAI_DoAddGoldToThem>(host, &AfterCvDealAI_DoAddGoldToThem);CivRegisterReplace<CivHooks::CvDealAI_DoAddGoldToThem>(host, &ReplaceCvDealAI_DoAddGoldToThem);

Code

2935/// See if adding Gold to their side of the deal helps even out pDeal2936void CvDealAI::DoAddGoldToThem(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue)2937{2938	CvAssert(eThem >= 0);2939	CvAssert(eThem < MAX_MAJOR_CIVS);2940	CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add Gold to Them, but them is us.  Please show Jon");29412942	if(!bDontChangeTheirExistingItems)2943	{2944		if(iTotalValue < 0)2945		{2946			PlayerTypes eMyPlayer = GetPlayer()->GetID();29472948			// Can't already be Gold from the other player in the Deal2949			if(pDeal->GetGoldTrade(eMyPlayer) == 0)2950			{2951				int iNumGold = GetGoldForForValueExchange(-iTotalValue, /*bNumGoldFromValue*/ true, /*bFromMe*/ false, eThem, bUseEvenValue, /*bRoundUp*/ false);2952				int iNumGoldAlreadyInTrade = pDeal->GetGoldTrade(eThem);2953				iNumGold += iNumGoldAlreadyInTrade;2954				iNumGold = min(iNumGold, pDeal->GetGoldAvailable(eThem, TRADE_ITEM_GOLD));2955				//iNumGold = min(iNumGold, GET_PLAYER(eThem).GetTreasury()->GetGold());29562957				if(iNumGold != iNumGoldAlreadyInTrade && !pDeal->ChangeGoldTrade(eThem, iNumGold))2958				{2959					pDeal->AddGoldTrade(eThem, iNumGold);2960				}29612962				iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);2963			}2964		}2965	}2966}

Calls

Called by