Bazaar developer reference

CvArmyAI::GetFurthestUnitDistance(CvPlot *)

Defined in
CvArmyAI.cpp, line 316
Class
CvArmyAI
Hook name
CivHooks::CvArmyAI_GetFurthestUnitDistance

Hooks

static bool BeforeCvArmyAI_GetFurthestUnitDistance(CvArmyAI* self, CvPlot* pPlot, int& result);static void AfterCvArmyAI_GetFurthestUnitDistance(CvArmyAI* self, CvPlot* pPlot, int& result);static int ReplaceCvArmyAI_GetFurthestUnitDistance(int (*original)(CvArmyAI*, CvPlot*), CvArmyAI* self, CvPlot* pPlot);CivRegisterBefore<CivHooks::CvArmyAI_GetFurthestUnitDistance>(host, &BeforeCvArmyAI_GetFurthestUnitDistance);CivRegisterAfter<CivHooks::CvArmyAI_GetFurthestUnitDistance>(host, &AfterCvArmyAI_GetFurthestUnitDistance);CivRegisterReplace<CivHooks::CvArmyAI_GetFurthestUnitDistance>(host, &ReplaceCvArmyAI_GetFurthestUnitDistance);

Code

315/// Return distance from this plot of unit in army farthest away316int CvArmyAI::GetFurthestUnitDistance(CvPlot* pPlot)317{318	int iLargestDistance = 0;319	UnitHandle pUnit;320	int iNewDistance;321322	pUnit = GetFirstUnit();323	while(pUnit)324	{325		iNewDistance = plotDistance(pUnit->getX(), pUnit->getY(), pPlot->getX(), pPlot->getY());326		if(iNewDistance > iLargestDistance)327		{328			iLargestDistance = iNewDistance;329		}330		pUnit = GetNextUnit();331	}332	return iLargestDistance;333}

Calls

Called by