Bazaar developer reference

CvDiplomacyAI::GetDealToRenew(int *)

Defined in
CvDiplomacyAI.cpp, line 25203
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_GetDealToRenew

Hooks

static bool BeforeCvDiplomacyAI_GetDealToRenew(CvDiplomacyAI* self, int* piDealType, CvDeal*& result);static void AfterCvDiplomacyAI_GetDealToRenew(CvDiplomacyAI* self, int* piDealType, CvDeal*& result);static CvDeal* ReplaceCvDiplomacyAI_GetDealToRenew(CvDeal* (*original)(CvDiplomacyAI*, int*), CvDiplomacyAI* self, int* piDealType);CivRegisterBefore<CivHooks::CvDiplomacyAI_GetDealToRenew>(host, &BeforeCvDiplomacyAI_GetDealToRenew);CivRegisterAfter<CivHooks::CvDiplomacyAI_GetDealToRenew>(host, &AfterCvDiplomacyAI_GetDealToRenew);CivRegisterReplace<CivHooks::CvDiplomacyAI_GetDealToRenew>(host, &ReplaceCvDiplomacyAI_GetDealToRenew);

Code

25202/// Deal to renew25203CvDeal* CvDiplomacyAI::GetDealToRenew(int* piDealType)25204{25205	CvDeal* pTargetDeal = NULL;25206	CvGameDeals* pGameDeals = GC.getGame().GetGameDeals();2520725208	if (piDealType)25209	{25210		*piDealType = -1;25211	}2521225213	for(int iDealTypes = 0; iDealTypes < 2; iDealTypes++)25214	{25215		int iNumDeals = 0;25216		if(iDealTypes == 0)25217		{25218			iNumDeals = pGameDeals->GetNumHistoricDeals(m_pPlayer->GetID());25219		}25220		else25221		{25222			iNumDeals = pGameDeals->GetNumCurrentDeals(m_pPlayer->GetID());25223		}2522425225		for(int iDeal = 0; iDeal < iNumDeals; iDeal++)25226		{25227			CvDeal* pCurrentDeal = NULL;25228			if(iDealTypes == 0)25229			{25230				pCurrentDeal = pGameDeals->GetHistoricDeal(m_pPlayer->GetID(), iDeal);25231			}25232			else25233			{25234				pCurrentDeal = pGameDeals->GetCurrentDeal(m_pPlayer->GetID(), iDeal);25235			}2523625237			if (pCurrentDeal->m_bConsideringForRenewal)25238			{25239				CvAssertMsg(pTargetDeal == NULL, "pTargetDeal should be null");25240				if (!pTargetDeal)25241				{25242					pTargetDeal = pCurrentDeal;25243					if (piDealType)25244					{25245						*piDealType = iDealTypes;25246					}25247				}25248			}25249		}25250	}2525125252	return pTargetDeal;25253}

Calls

Called by