Bazaar developer reference

CvUnit::canEmbarkOnto(const CvPlot &, const CvPlot &, bool, bool) const

Defined in
CvUnit.cpp, line 4977
Class
CvUnit
Hook name
CivHooks::CvUnit_canEmbarkOnto

Hooks

static bool BeforeCvUnit_canEmbarkOnto(const CvUnit* self, const CvPlot& originPlot, const CvPlot& targetPlot, bool bOverrideEmbarkedCheck, bool bIsDestination, bool& result);static void AfterCvUnit_canEmbarkOnto(const CvUnit* self, const CvPlot& originPlot, const CvPlot& targetPlot, bool bOverrideEmbarkedCheck, bool bIsDestination, bool& result);static bool ReplaceCvUnit_canEmbarkOnto(bool (*original)(const CvUnit*, const CvPlot&, const CvPlot&, bool, bool), const CvUnit* self, const CvPlot& originPlot, const CvPlot& targetPlot, bool bOverrideEmbarkedCheck, bool bIsDestination);CivRegisterBefore<CivHooks::CvUnit_canEmbarkOnto>(host, &BeforeCvUnit_canEmbarkOnto);CivRegisterAfter<CivHooks::CvUnit_canEmbarkOnto>(host, &AfterCvUnit_canEmbarkOnto);CivRegisterReplace<CivHooks::CvUnit_canEmbarkOnto>(host, &ReplaceCvUnit_canEmbarkOnto);

Code

4977bool CvUnit::canEmbarkOnto(const CvPlot& originPlot, const CvPlot& targetPlot, bool bOverrideEmbarkedCheck /* = false */, bool bIsDestination /* = false */) const4978{4979	VALIDATE_OBJECT4980	if(isEmbarked() && !bOverrideEmbarkedCheck)4981	{4982		return false;4983	}49844985	if(!targetPlot.isWater())4986	{4987		return false;4988	}49894990	if (targetPlot.IsAllowsWalkWater())4991	{4992		return false;4993	}49944995#if defined(MOD_PATHFINDER_DEEP_WATER_EMBARKATION)4996	if(!IsHasEmbarkAbility() && !IsEmbarkDeepWater())4997#else4998#if defined(MOD_BUGFIX_EMBARKING_PATHFINDER)4999	// Not really a bug, but bloody irritating if you're searching for the getter!5000	if(!IsHasEmbarkAbility())5001#else5002	if(m_iEmbarkAbilityCount <= 0)5003#endif5004#endif5005	{5006		return false;5007	}50085009	if(!targetPlot.isRevealed(getTeam()))5010	{5011		return false;5012	}50135014	if(getDomainType() != DOMAIN_LAND)5015	{5016		return false;5017	}50185019#if defined(MOD_PATHFINDER_TERRAFIRMA)5020	// Can we embark from originPlot to targetPlot?5021	// Only if originPlot is land and the targetPlot is shallow water5022	bool bCanEmbark = originPlot.isAdjacentToShallowWater();5023#if defined(MOD_PATHFINDER_CROSS_ICE)5024	// ...  or the originPlot is ice and the targetPlot is any water5025	bCanEmbark = bCanEmbark || (canCrossIce() && originPlot.isIce() && targetPlot.isWater());5026#endif5027#if defined(MOD_PATHFINDER_DEEP_WATER_EMBARKATION)5028	// ...  or the originPlot is shallow water and the targetPlot is ocean5029	bCanEmbark = bCanEmbark || (IsHoveringUnit() && originPlot.isShallowWater() && targetPlot.isWater());5030#endif5031	if(!bCanEmbark)5032#else5033	if(!originPlot.isAdjacentToShallowWater())5034#endif5035	{5036		return false;5037	}50385039	return canMoveInto(targetPlot, MOVEFLAG_PRETEND_EMBARKED | ((bIsDestination)?MOVEFLAG_DESTINATION:0));5040}

Calls

Called by