Bazaar developer reference

CvPlot::getNearestLandPlotInternal(int) const

Defined in
CvPlot.cpp, line 1378
Class
CvPlot
Hook name
CivHooks::CvPlot_getNearestLandPlotInternal

Hooks

static bool BeforeCvPlot_getNearestLandPlotInternal(const CvPlot* self, int iDistance, CvPlot*& result);static void AfterCvPlot_getNearestLandPlotInternal(const CvPlot* self, int iDistance, CvPlot*& result);static CvPlot* ReplaceCvPlot_getNearestLandPlotInternal(CvPlot* (*original)(const CvPlot*, int), const CvPlot* self, int iDistance);CivRegisterBefore<CivHooks::CvPlot_getNearestLandPlotInternal>(host, &BeforeCvPlot_getNearestLandPlotInternal);CivRegisterAfter<CivHooks::CvPlot_getNearestLandPlotInternal>(host, &AfterCvPlot_getNearestLandPlotInternal);CivRegisterReplace<CivHooks::CvPlot_getNearestLandPlotInternal>(host, &ReplaceCvPlot_getNearestLandPlotInternal);

Code

1378CvPlot* CvPlot::getNearestLandPlotInternal(int iDistance) const1379{1380	if(iDistance > GC.getMap().getGridHeight() && iDistance > GC.getMap().getGridWidth())1381	{1382		return NULL;1383	}13841385	for(int iDX = -iDistance; iDX <= iDistance; iDX++)1386	{1387		for(int iDY = -iDistance; iDY <= iDistance; iDY++)1388		{1389			// bkw - revisit this, it works but is inefficient1390			CvPlot* pPlot = plotXY(getX(), getY(), iDX, iDY);1391			if(pPlot != NULL && !pPlot->isWater() && plotDistance(getX(), getY(), pPlot->getX(), pPlot->getY()) == iDistance)1392			{1393				return pPlot;1394			}1395		}1396	}1397	return getNearestLandPlotInternal(iDistance + 1);1398}

Calls

Called by