Bazaar developer reference

CvUnit::canChangeAdmiralPortAt(const CvPlot *, int, int) const

Defined in
CvUnit.cpp, line 6976
Class
CvUnit
Hook name
CivHooks::CvUnit_canChangeAdmiralPortAt

Hooks

static bool BeforeCvUnit_canChangeAdmiralPortAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static void AfterCvUnit_canChangeAdmiralPortAt(const CvUnit* self, const CvPlot* pPlot, int iX, int iY, bool& result);static bool ReplaceCvUnit_canChangeAdmiralPortAt(bool (*original)(const CvUnit*, const CvPlot*, int, int), const CvUnit* self, const CvPlot* pPlot, int iX, int iY);CivRegisterBefore<CivHooks::CvUnit_canChangeAdmiralPortAt>(host, &BeforeCvUnit_canChangeAdmiralPortAt);CivRegisterAfter<CivHooks::CvUnit_canChangeAdmiralPortAt>(host, &AfterCvUnit_canChangeAdmiralPortAt);CivRegisterReplace<CivHooks::CvUnit_canChangeAdmiralPortAt>(host, &ReplaceCvUnit_canChangeAdmiralPortAt);

Code

6976bool CvUnit::canChangeAdmiralPortAt(const CvPlot* pPlot, int iX, int iY) const6977{6978	if (!canChangeAdmiralPort(pPlot))6979	{6980		return false;6981	}69826983	if (pPlot == NULL)6984	{6985		return false;6986	}69876988	CvCity* pFromCity = pPlot->getPlotCity();6989	if (pFromCity == NULL)6990	{6991		return false;6992	}69936994	if (pFromCity->getOwner() != getOwner())6995	{6996		return false;6997	}69986999	CvPlot* pToPlot = GC.getMap().plot(iX, iY);70007001	// Null plot...7002	if(pToPlot == NULL)7003	{7004		return false;7005	}70067007	// Same plot...7008	if(pToPlot == pPlot)7009	{7010		return false;7011	}70127013	CvCity* pToCity = pToPlot->getPlotCity();7014	if (pToCity == NULL)7015	{7016		return false;7017	}70187019	// can't change cities with a city you don't own7020	if (pToCity->getOwner() != getOwner())7021	{7022		return false;7023	}70247025	if (!pToCity->isCoastal())7026	{7027		return false;7028	}70297030	return true;7031}

Calls

Called by