Bazaar developer reference

CvDllGameContext::TEMPCalculatePathFinderUpdates(ICvUnit1 *, int, int)

Defined in
CvDllContext.cpp, line 1297
Class
CvDllGameContext
Hook name
CivHooks::CvDllGameContext_TEMPCalculatePathFinderUpdates

Hooks

static bool BeforeCvDllGameContext_TEMPCalculatePathFinderUpdates(CvDllGameContext* self, ICvUnit1* pHeadSelectedUnit, int iMouseMapX, int iMouseMapY, ICvEnumerator*& result);static void AfterCvDllGameContext_TEMPCalculatePathFinderUpdates(CvDllGameContext* self, ICvUnit1* pHeadSelectedUnit, int iMouseMapX, int iMouseMapY, ICvEnumerator*& result);static ICvEnumerator* ReplaceCvDllGameContext_TEMPCalculatePathFinderUpdates(ICvEnumerator* (*original)(CvDllGameContext*, ICvUnit1*, int, int), CvDllGameContext* self, ICvUnit1* pHeadSelectedUnit, int iMouseMapX, int iMouseMapY);// CivHooks.h gives this hook point no types, so nothing checks these hooks' parameters.host->RegisterHook(host->pluginIndex, CivHooks::CvDllGameContext_TEMPCalculatePathFinderUpdates::ID, CIV_HOOK_BEFORE, (void*)&BeforeCvDllGameContext_TEMPCalculatePathFinderUpdates);host->RegisterHook(host->pluginIndex, CivHooks::CvDllGameContext_TEMPCalculatePathFinderUpdates::ID, CIV_HOOK_AFTER, (void*)&AfterCvDllGameContext_TEMPCalculatePathFinderUpdates);host->RegisterHook(host->pluginIndex, CivHooks::CvDllGameContext_TEMPCalculatePathFinderUpdates::ID, CIV_HOOK_REPLACE, (void*)&ReplaceCvDllGameContext_TEMPCalculatePathFinderUpdates);

Code

1297ICvEnumerator* CvDllGameContext::TEMPCalculatePathFinderUpdates(ICvUnit1* pHeadSelectedUnit, int iMouseMapX, int iMouseMapY)1298{1299	CvUnit* pkUnit = GC.UnwrapUnitPointer(pHeadSelectedUnit);1300	CvTwoLayerPathFinder& thePathfinder = GC.getInterfacePathFinder();13011302	thePathfinder.SetData(pkUnit);1303	if(thePathfinder.GeneratePath(pkUnit->getX(), pkUnit->getY(), iMouseMapX, iMouseMapY, MOVE_DECLARE_WAR, false))1304	{1305		// seed the pathfinder with a unit1306		thePathfinder.SetData(pkUnit);13071308		//get the number of waypoints on the path1309		CvAStarNode* lastNode = thePathfinder.GetLastNode();1310		CvAStarNode* pathNode = lastNode;13111312		pathNode = lastNode;1313		int size = 0;1314		while(pathNode != NULL)1315		{1316			size++;1317			pathNode = pathNode->m_pParent;1318		}131913201321		std::vector<CvDllPathFinderUpdateListData> pUpdateData;13221323		pUpdateData.reserve(size);13241325		// now fill out the event array in reverse order1326		pathNode = lastNode;1327		int index = 0;1328		while(pathNode != NULL)1329		{1330			CvDllPathFinderUpdateListData update;1331			update.iX = pathNode->m_iX;1332			update.iY = pathNode->m_iY;1333			update.iTurnNumber = pathNode->m_iData2;13341335			pUpdateData.push_back(update);13361337			index++;1338			pathNode = pathNode->m_pParent;1339		}13401341		std::reverse(pUpdateData.begin(), pUpdateData.end());1342		return new CvDllPathFinderUpdateList(pUpdateData);1343	}13441345	return NULL;1346}

Calls