Bazaar developer reference

CvUnit::IsGarrisoned() const

Defined in
CvUnit.cpp, line 17507
Class
CvUnit
Hook name
CivHooks::CvUnit_IsGarrisoned

Hooks

static bool BeforeCvUnit_IsGarrisoned(const CvUnit* self, bool& result);static void AfterCvUnit_IsGarrisoned(const CvUnit* self, bool& result);static bool ReplaceCvUnit_IsGarrisoned(bool (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_IsGarrisoned>(host, &BeforeCvUnit_IsGarrisoned);CivRegisterAfter<CivHooks::CvUnit_IsGarrisoned>(host, &AfterCvUnit_IsGarrisoned);CivRegisterReplace<CivHooks::CvUnit_IsGarrisoned>(host, &ReplaceCvUnit_IsGarrisoned);

Code

17507bool CvUnit::IsGarrisoned(void) const17508{17509	VALIDATE_OBJECT1751017511	if (m_iMapLayer != DEFAULT_UNIT_MAP_LAYER)		// Only units on the main layer can be garrisoned.17512		return false;1751317514	CvPlot* pPlot = plot();17515	if(pPlot)17516	{17517		CvCity* pCity = pPlot->getPlotCity();17518		if(pCity)17519		{17520			if(pPlot->getOwner() == getOwner())17521			{17522				UnitHandle bestDefender = pPlot->getBestDefender(getOwner());17523				if(bestDefender && bestDefender->GetID() == GetID())17524				{17525					return true;17526				}17527			}17528		}17529	}17530	return false;17531}

Calls

Called by