Bazaar developer reference

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

Defined in
CvUnit.cpp, line 10803
Class
CvUnit
Hook name
CivHooks::CvUnit_canLead

Hooks

static bool BeforeCvUnit_canLead(const CvUnit* self, const CvPlot* pPlot, int iUnitId, int& result);static void AfterCvUnit_canLead(const CvUnit* self, const CvPlot* pPlot, int iUnitId, int& result);static int ReplaceCvUnit_canLead(int (*original)(const CvUnit*, const CvPlot*, int), const CvUnit* self, const CvPlot* pPlot, int iUnitId);CivRegisterBefore<CivHooks::CvUnit_canLead>(host, &BeforeCvUnit_canLead);CivRegisterAfter<CivHooks::CvUnit_canLead>(host, &AfterCvUnit_canLead);CivRegisterReplace<CivHooks::CvUnit_canLead>(host, &ReplaceCvUnit_canLead);

Code

10803int CvUnit::canLead(const CvPlot* pPlot, int iUnitId) const10804{10805	VALIDATE_OBJECT10806	if(isDelayedDeath())10807	{10808		return 0;10809	}1081010811	if(NO_UNIT == getUnitType())10812	{10813		return 0;10814	}1081510816	int iNumUnits = 0;10817	CvUnitEntry& kUnitInfo = getUnitInfo();1081810819	if(-1 == iUnitId)10820	{10821		const IDInfo* pUnitNode = pPlot->headUnitNode();10822		while(pUnitNode != NULL)10823		{10824			const CvUnit* pUnit = ::getUnit(*pUnitNode);10825			pUnitNode = pPlot->nextUnitNode(pUnitNode);1082610827			if(pUnit && pUnit != this && pUnit->getOwner() == getOwner() && pUnit->canPromote((PromotionTypes)kUnitInfo.GetLeaderPromotion(), GetID()))10828			{10829				++iNumUnits;10830			}10831		}10832	}10833	else10834	{10835		const UnitHandle pUnit = GET_PLAYER(getOwner()).getUnit(iUnitId);10836		if(pUnit && pUnit != this && pUnit->canPromote((PromotionTypes)kUnitInfo.GetLeaderPromotion(), GetID()))10837		{10838			iNumUnits = 1;10839		}10840	}10841	return iNumUnits;10842}

Calls

Called by