Bazaar developer reference

CvGameTrade::GetPlotAdjacentToWater(CvPlot *, CvPlot *)

Defined in
CvTradeClasses.cpp, line 534
Class
CvGameTrade
Hook name
CivHooks::CvGameTrade_GetPlotAdjacentToWater

Hooks

static bool BeforeCvGameTrade_GetPlotAdjacentToWater(CvGameTrade* self, CvPlot* pTargetLandPlot, CvPlot* pFromLandPlot, CvPlot*& result);static void AfterCvGameTrade_GetPlotAdjacentToWater(CvGameTrade* self, CvPlot* pTargetLandPlot, CvPlot* pFromLandPlot, CvPlot*& result);static CvPlot* ReplaceCvGameTrade_GetPlotAdjacentToWater(CvPlot* (*original)(CvGameTrade*, CvPlot*, CvPlot*), CvGameTrade* self, CvPlot* pTargetLandPlot, CvPlot* pFromLandPlot);CivRegisterBefore<CivHooks::CvGameTrade_GetPlotAdjacentToWater>(host, &BeforeCvGameTrade_GetPlotAdjacentToWater);CivRegisterAfter<CivHooks::CvGameTrade_GetPlotAdjacentToWater>(host, &AfterCvGameTrade_GetPlotAdjacentToWater);CivRegisterReplace<CivHooks::CvGameTrade_GetPlotAdjacentToWater>(host, &ReplaceCvGameTrade_GetPlotAdjacentToWater);

Code

534CvPlot* CvGameTrade::GetPlotAdjacentToWater (CvPlot* pTargetLandPlot, CvPlot* pFromLandPlot)535{536	CvPlot* pCoastalPlot = NULL;537	int iBestDistance = MAX_INT;538539	// Find a coastal water tile adjacent to enemy city540	for(int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; ++iDirectionLoop)541	{542		CvPlot* pAdjacentPlot = plotDirection(pFromLandPlot->getX(), pFromLandPlot->getY(), ((DirectionTypes)iDirectionLoop));543		if(pAdjacentPlot != NULL && pAdjacentPlot->isWater() && pAdjacentPlot->isShallowWater())544		{545			int iDistance = plotDistance(pAdjacentPlot->getX(), pAdjacentPlot->getY(), pTargetLandPlot->getX(), pTargetLandPlot->getY());546			if (iDistance < iBestDistance)547			{548				iBestDistance = iDistance;549				pCoastalPlot = pAdjacentPlot;550			}551		}552	}553554	return pCoastalPlot;555}

Calls