Bazaar developer reference

CvIgnoreUnitsPathFinder::GetLastOwnedPlot(CvPlot *, CvPlot *, PlayerTypes) const

Defined in
CvAStar.cpp, line 3094
Class
CvIgnoreUnitsPathFinder
Hook name
CivHooks::CvIgnoreUnitsPathFinder_GetLastOwnedPlot

Hooks

static bool BeforeCvIgnoreUnitsPathFinder_GetLastOwnedPlot(const CvIgnoreUnitsPathFinder* self, CvPlot* pStartPlot, CvPlot* pEndPlot, PlayerTypes iOwner, CvPlot*& result);static void AfterCvIgnoreUnitsPathFinder_GetLastOwnedPlot(const CvIgnoreUnitsPathFinder* self, CvPlot* pStartPlot, CvPlot* pEndPlot, PlayerTypes iOwner, CvPlot*& result);static CvPlot* ReplaceCvIgnoreUnitsPathFinder_GetLastOwnedPlot(CvPlot* (*original)(const CvIgnoreUnitsPathFinder*, CvPlot*, CvPlot*, PlayerTypes), const CvIgnoreUnitsPathFinder* self, CvPlot* pStartPlot, CvPlot* pEndPlot, PlayerTypes iOwner);CivRegisterBefore<CivHooks::CvIgnoreUnitsPathFinder_GetLastOwnedPlot>(host, &BeforeCvIgnoreUnitsPathFinder_GetLastOwnedPlot);CivRegisterAfter<CivHooks::CvIgnoreUnitsPathFinder_GetLastOwnedPlot>(host, &AfterCvIgnoreUnitsPathFinder_GetLastOwnedPlot);CivRegisterReplace<CivHooks::CvIgnoreUnitsPathFinder_GetLastOwnedPlot>(host, &ReplaceCvIgnoreUnitsPathFinder_GetLastOwnedPlot);

Code

3093/// Returns the last plot along the step path owned by a specific player3094CvPlot* CvIgnoreUnitsPathFinder::GetLastOwnedPlot(CvPlot* pStartPlot, CvPlot* pEndPlot, PlayerTypes iOwner) const3095{3096	CvAStarNode* pNode;30973098	// Generate path3099	if(GC.getIgnoreUnitsPathFinder().GeneratePath(pStartPlot->getX(), pStartPlot->getX(), pEndPlot->getX(), pEndPlot->getX(), 0, false))3100	{3101		pNode = GC.getIgnoreUnitsPathFinder().GetLastNode();31023103		// Starting at the end, loop until we find a plot from this owner3104		CvMap& kMap = GC.getMap();3105		while(pNode != NULL)3106		{3107			CvPlot* currentPlot;3108			currentPlot = kMap.plotUnchecked(pNode->m_iX, pNode->m_iY);31093110			// Check and see if this plot has the right owner3111			if(currentPlot->getOwner() == iOwner)3112			{3113				return currentPlot;3114			}31153116			// Move to the previous plot on the path3117			pNode = pNode->m_pParent;3118		}3119	}31203121	return NULL;3122}

Calls