Bazaar developer reference

CvGameTrade::CopyPathIntoTradeConnection(CvAStarNode *, TradeConnection *)

Defined in
CvTradeClasses.cpp, line 636
Class
CvGameTrade
Hook name
CivHooks::CvGameTrade_CopyPathIntoTradeConnection

Hooks

static bool BeforeCvGameTrade_CopyPathIntoTradeConnection(CvGameTrade* self, CvAStarNode* pNode, TradeConnection* pTradeConnection);static void AfterCvGameTrade_CopyPathIntoTradeConnection(CvGameTrade* self, CvAStarNode* pNode, TradeConnection* pTradeConnection);static void ReplaceCvGameTrade_CopyPathIntoTradeConnection(void (*original)(CvGameTrade*, CvAStarNode*, TradeConnection*), CvGameTrade* self, CvAStarNode* pNode, TradeConnection* pTradeConnection);CivRegisterBefore<CivHooks::CvGameTrade_CopyPathIntoTradeConnection>(host, &BeforeCvGameTrade_CopyPathIntoTradeConnection);CivRegisterAfter<CivHooks::CvGameTrade_CopyPathIntoTradeConnection>(host, &AfterCvGameTrade_CopyPathIntoTradeConnection);CivRegisterReplace<CivHooks::CvGameTrade_CopyPathIntoTradeConnection>(host, &ReplaceCvGameTrade_CopyPathIntoTradeConnection);

Code

636void CvGameTrade::CopyPathIntoTradeConnection (CvAStarNode* pNode, TradeConnection* pTradeConnection)637{638	// beyond the origin player's trade range639	int iPathSteps = 0;640	CvAStarNode* pWalkingPath = pNode;641	while (pWalkingPath)642	{643		iPathSteps++;644		pWalkingPath = pWalkingPath->m_pParent;645	}646647	pTradeConnection->m_aPlotList.clear();648	for (int i = 0; i < iPathSteps; i++)649	{650		TradeConnectionPlot kTradeConnectionPlot;651		pTradeConnection->m_aPlotList.push_back(kTradeConnectionPlot);652	}653654	int iIndex = iPathSteps - 1;655	while (pNode != NULL)656	{657		pTradeConnection->m_aPlotList[iIndex].m_iX = pNode->m_iX;658		pTradeConnection->m_aPlotList[iIndex].m_iY = pNode->m_iY;659		pNode = pNode->m_pParent;660		iIndex--;661	}662}

Calls

Called by