Bazaar developer reference

CvGameTrade::GetNumTimesDestinationCity(CvCity *, bool)

Defined in
CvTradeClasses.cpp, line 829
Class
CvGameTrade
Hook name
CivHooks::CvGameTrade_GetNumTimesDestinationCity

Hooks

static bool BeforeCvGameTrade_GetNumTimesDestinationCity(CvGameTrade* self, CvCity* pCity, bool bOnlyInternational, int& result);static void AfterCvGameTrade_GetNumTimesDestinationCity(CvGameTrade* self, CvCity* pCity, bool bOnlyInternational, int& result);static int ReplaceCvGameTrade_GetNumTimesDestinationCity(int (*original)(CvGameTrade*, CvCity*, bool), CvGameTrade* self, CvCity* pCity, bool bOnlyInternational);CivRegisterBefore<CivHooks::CvGameTrade_GetNumTimesDestinationCity>(host, &BeforeCvGameTrade_GetNumTimesDestinationCity);CivRegisterAfter<CivHooks::CvGameTrade_GetNumTimesDestinationCity>(host, &AfterCvGameTrade_GetNumTimesDestinationCity);CivRegisterReplace<CivHooks::CvGameTrade_GetNumTimesDestinationCity>(host, &ReplaceCvGameTrade_GetNumTimesDestinationCity);

Code

829int CvGameTrade::GetNumTimesDestinationCity (CvCity* pCity, bool bOnlyInternational)830{831	int iCount = 0;832	int iCityX = pCity->getX();833	int iCityY = pCity->getY();834835	for (uint ui = 0; ui < m_aTradeConnections.size(); ui++)836	{837		TradeConnection* pConnection = &(m_aTradeConnections[ui]);838839		if (IsTradeRouteIndexEmpty(ui))840		{841			continue;842		}843844		if (pConnection->m_iDestX == iCityX && pConnection->m_iDestY == iCityY)845		{846			if (bOnlyInternational)847			{848				if (pConnection->m_eConnectionType == TRADE_CONNECTION_INTERNATIONAL)849				{850					iCount++;851				}852			}853			else854			{855				iCount++;856			}857		}858	}859860	return iCount;	861}

Calls

Called by