Bazaar developer reference

CvUnit::IsEnemyCityAdjacent(const CvCity *) const

Defined in
CvUnit.cpp, line 14882
Class
CvUnit
Hook name
CivHooks::CvUnit_IsEnemyCityAdjacent_with_const_CvCity_const

Hooks

static bool BeforeCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const(const CvUnit* self, const CvCity* pSpecifyCity, bool& result);static void AfterCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const(const CvUnit* self, const CvCity* pSpecifyCity, bool& result);static bool ReplaceCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const(bool (*original)(const CvUnit*, const CvCity*), const CvUnit* self, const CvCity* pSpecifyCity);CivRegisterBefore<CivHooks::CvUnit_IsEnemyCityAdjacent_with_const_CvCity_const>(host, &BeforeCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const);CivRegisterAfter<CivHooks::CvUnit_IsEnemyCityAdjacent_with_const_CvCity_const>(host, &AfterCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const);CivRegisterReplace<CivHooks::CvUnit_IsEnemyCityAdjacent_with_const_CvCity_const>(host, &ReplaceCvUnit_IsEnemyCityAdjacent_with_const_CvCity_const);

Code

14881/// Is a particular enemy city next to us?14882bool CvUnit::IsEnemyCityAdjacent(const CvCity* pSpecifyCity) const14883{14884	CvAssertMsg(pSpecifyCity, "City is NULL when checking if it is adjacent to a unit");14885	if (!pSpecifyCity)14886	{14887		return false;14888	}1488914890	TeamTypes eMyTeam = getTeam();14891	CvPlot* pLoopPlot;14892	CvCity* pCity;1489314894	for(int iI = 0; iI < NUM_DIRECTION_TYPES; iI++)14895	{14896		pLoopPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));14897		if(!pLoopPlot)14898		{14899			continue;14900		}1490114902		pCity = pLoopPlot->getPlotCity();14903		if(!pCity)14904		{14905			continue;14906		}1490714908		if (pCity->getX() == pSpecifyCity->getX() && pCity->getY() == pSpecifyCity->getY())14909		{14910			if(GET_TEAM(eMyTeam).isAtWar(pCity->getTeam()))14911			{14912				return true;14913			}14914		}14915	}1491614917	return false;14918}

Calls

Called by