Bazaar developer reference

CvMap::findNearestStartPlot(int, int, PlayerTypes &)

Defined in
CvMap.cpp, line 956
Class
CvMap
Hook name
CivHooks::CvMap_findNearestStartPlot

Hooks

static bool BeforeCvMap_findNearestStartPlot(CvMap* self, int iX, int iY, PlayerTypes& eOwner, CvPlot*& result);static void AfterCvMap_findNearestStartPlot(CvMap* self, int iX, int iY, PlayerTypes& eOwner, CvPlot*& result);static CvPlot* ReplaceCvMap_findNearestStartPlot(CvPlot* (*original)(CvMap*, int, int, PlayerTypes&), CvMap* self, int iX, int iY, PlayerTypes& eOwner);CivRegisterBefore<CivHooks::CvMap_findNearestStartPlot>(host, &BeforeCvMap_findNearestStartPlot);CivRegisterAfter<CivHooks::CvMap_findNearestStartPlot>(host, &AfterCvMap_findNearestStartPlot);CivRegisterReplace<CivHooks::CvMap_findNearestStartPlot>(host, &ReplaceCvMap_findNearestStartPlot);

Code

956CvPlot* CvMap::findNearestStartPlot(int iX, int iY, PlayerTypes& eOwner)957{958	eOwner = NO_PLAYER;959	int iValue;960	int iBestValue;961	int iI;962	CvPlot* pBestStartPlot = 0;963964	iBestValue = INT_MAX;965966	for(iI = 0; iI < MAX_PLAYERS; iI++)967	{968		CvPlayer& thisPlayer = GET_PLAYER((PlayerTypes)iI);969		if(thisPlayer.isEverAlive())970		{971			CvPlot* pStartPlot = thisPlayer.getStartingPlot();972			if (pStartPlot)973			{974				iValue = plotDistance(iX, iY, pStartPlot->getX(), pStartPlot->getY());975				if(iValue < iBestValue)976				{977					iBestValue = iValue;978					pBestStartPlot = pStartPlot;979					eOwner = static_cast<PlayerTypes>(iI);980				}981			}982		}983	}984	return pBestStartPlot;985}

Calls

Called by