Bazaar developer reference

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

Defined in
CvDealAI.cpp, line 2969
Class
CvDealAI
Hook name
CivHooks::CvDealAI_DoAddGoldToUs

Hooks

static bool BeforeCvDealAI_DoAddGoldToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void AfterCvDealAI_DoAddGoldToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddGoldToUs(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddGoldToUs>(host, &BeforeCvDealAI_DoAddGoldToUs);CivRegisterAfter<CivHooks::CvDealAI_DoAddGoldToUs>(host, &AfterCvDealAI_DoAddGoldToUs);CivRegisterReplace<CivHooks::CvDealAI_DoAddGoldToUs>(host, &ReplaceCvDealAI_DoAddGoldToUs);

Code

2968/// See if adding Gold to our side of the deal helps even out pDeal2969void CvDealAI::DoAddGoldToUs(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, bool bUseEvenValue)2970{2971	CvAssert(eThem >= 0);2972	CvAssert(eThem < MAX_MAJOR_CIVS);2973	CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add Gold to Us, but them is us.  Please show Jon");29742975	if(!bDontChangeMyExistingItems)2976	{2977		if(iTotalValue > 0)2978		{2979			// Can't already be Gold from the other player in the Deal2980			if(pDeal->GetGoldTrade(eThem) == 0)2981			{2982				PlayerTypes eMyPlayer = GetPlayer()->GetID();29832984				int iNumGold = GetGoldForForValueExchange(iTotalValue, /*bNumGoldFromValue*/ true, /*bFromMe*/ true, eThem, bUseEvenValue, /*bRoundUp*/ false);2985				int iNumGoldAlreadyInTrade = pDeal->GetGoldTrade(eMyPlayer);2986				iNumGold += iNumGoldAlreadyInTrade;2987				iNumGold = min(iNumGold, pDeal->GetGoldAvailable(eMyPlayer, TRADE_ITEM_GOLD));2988				//iNumGold = min(iNumGold, GET_PLAYER(eMyPlayer).GetTreasury()->GetGold());29892990				if(iNumGold != iNumGoldAlreadyInTrade && !pDeal->ChangeGoldTrade(eMyPlayer, iNumGold))2991				{2992					pDeal->AddGoldTrade(eMyPlayer, iNumGold);2993				}29942995				iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);2996			}2997		}2998	}2999}

Calls

Called by