Bazaar developer reference

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

Defined in
CvAStar.cpp, line 2974
Class
CvStepPathFinder
Hook name
CivHooks::CvStepPathFinder_GetLastOwnedPlot

Hooks

static bool BeforeCvStepPathFinder_GetLastOwnedPlot(const CvStepPathFinder* self, PlayerTypes ePlayer, PlayerTypes eEnemy, CvPlot* pStartPlot, CvPlot* pEndPlot, CvPlot*& result);static void AfterCvStepPathFinder_GetLastOwnedPlot(const CvStepPathFinder* self, PlayerTypes ePlayer, PlayerTypes eEnemy, CvPlot* pStartPlot, CvPlot* pEndPlot, CvPlot*& result);static CvPlot* ReplaceCvStepPathFinder_GetLastOwnedPlot(CvPlot* (*original)(const CvStepPathFinder*, PlayerTypes, PlayerTypes, CvPlot*, CvPlot*), const CvStepPathFinder* self, PlayerTypes ePlayer, PlayerTypes eEnemy, CvPlot* pStartPlot, CvPlot* pEndPlot);CivRegisterBefore<CivHooks::CvStepPathFinder_GetLastOwnedPlot>(host, &BeforeCvStepPathFinder_GetLastOwnedPlot);CivRegisterAfter<CivHooks::CvStepPathFinder_GetLastOwnedPlot>(host, &AfterCvStepPathFinder_GetLastOwnedPlot);CivRegisterReplace<CivHooks::CvStepPathFinder_GetLastOwnedPlot>(host, &ReplaceCvStepPathFinder_GetLastOwnedPlot);

Code

2973/// Returns the last plot along the step path owned by a specific player2974CvPlot* CvStepPathFinder::GetLastOwnedPlot(PlayerTypes ePlayer, PlayerTypes eEnemy, CvPlot* pStartPlot, CvPlot* pEndPlot) const2975{2976	CvAStarNode* pNode;2977	int iNumSteps;29782979	// Generate step path2980	iNumSteps = GC.getStepFinder().GetStepDistanceBetweenPoints(ePlayer, eEnemy, pStartPlot, pEndPlot);2981	if(iNumSteps != -1)2982	{2983		pNode = GC.getStepFinder().GetLastNode();29842985		// Starting at the end, loop until we find a plot from this owner2986		CvMap& kMap = GC.getMap();2987		while(pNode != NULL)2988		{2989			CvPlot* currentPlot;2990			currentPlot = kMap.plotUnchecked(pNode->m_iX, pNode->m_iY);29912992			// Check and see if this plot has the right owner2993			if(currentPlot->getOwner() == ePlayer)2994			{2995				return currentPlot;2996			}29972998			// Move to the previous plot on the path2999			pNode = pNode->m_pParent;3000		}3001	}30023003	return NULL;3004}

Calls

Called by