Bazaar developer reference

CvUnitMovement::ConsumesAllMoves(const CvUnit *, const CvPlot *, const CvPlot *)

Defined in
CvUnitMovement.cpp, line 191
Class
CvUnitMovement
Hook name
CivHooks::CvUnitMovement_ConsumesAllMoves

Hooks

static bool BeforeCvUnitMovement_ConsumesAllMoves(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, bool& result);static void AfterCvUnitMovement_ConsumesAllMoves(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, bool& result);static bool ReplaceCvUnitMovement_ConsumesAllMoves(bool (*original)(const CvUnit*, const CvPlot*, const CvPlot*), const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot);CivRegisterBefore<CivHooks::CvUnitMovement_ConsumesAllMoves>(host, &BeforeCvUnitMovement_ConsumesAllMoves);CivRegisterAfter<CivHooks::CvUnitMovement_ConsumesAllMoves>(host, &AfterCvUnitMovement_ConsumesAllMoves);CivRegisterReplace<CivHooks::CvUnitMovement_ConsumesAllMoves>(host, &ReplaceCvUnitMovement_ConsumesAllMoves);

Code

191bool CvUnitMovement::ConsumesAllMoves(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot)192{193	if(!pToPlot->isRevealed(pUnit->getTeam()) && pUnit->isHuman())194	{195		return true;196	}197198	if (!pUnit->isEmbarked() && (pToPlot->IsAllowsWalkWater() || pFromPlot->IsAllowsWalkWater()))199	{200		return false;201	}202203	if(!pFromPlot->isValidDomainForLocation(*pUnit))204	{205		// If we are a land unit that can embark, then do further tests.206#if defined(MOD_PATHFINDER_DEEP_WATER_EMBARKATION)207		if(pUnit->getDomainType() != DOMAIN_LAND || pUnit->canMoveAllTerrain())208			return true;209			210		if(pUnit->IsHoveringUnit()) {211			if (!pUnit->IsEmbarkDeepWater()) {212				return true;213			}214		} else {215			if (!pUnit->CanEverEmbark()) {216				return true;217			}218		}219#else220		if(pUnit->getDomainType() != DOMAIN_LAND || pUnit->IsHoveringUnit() || pUnit->canMoveAllTerrain() || !pUnit->CanEverEmbark())221			return true;222#endif223	}224225	// if the unit can embark and we are transitioning from land to water or vice versa226#if defined(MOD_PATHFINDER_TERRAFIRMA)227	bool bFromWater = !pFromPlot->isTerraFirma(pUnit);228	bool bToWater = !pToPlot->isTerraFirma(pUnit);229	bool bCanEmbark = pUnit->CanEverEmbark();230#if defined(MOD_PATHFINDER_DEEP_WATER_EMBARKATION)231	if (pUnit->IsHoveringUnit() && pUnit->IsEmbarkDeepWater()) {232		bCanEmbark = true;233	}234#endif235	if(bToWater != bFromWater && bCanEmbark)236#else237	if(pToPlot->isWater() != pFromPlot->isWater() && pUnit->CanEverEmbark())238#endif239	{240		// Is the unit from a civ that can disembark for just 1 MP?241#if defined(MOD_PATHFINDER_TERRAFIRMA)242		if(!bToWater && bFromWater && pUnit->isEmbarked() && GET_PLAYER(pUnit->getOwner()).GetPlayerTraits()->IsEmbarkedToLandFlatCost())243#else244		if(!pToPlot->isWater() && pFromPlot->isWater() && pUnit->isEmbarked() && GET_PLAYER(pUnit->getOwner()).GetPlayerTraits()->IsEmbarkedToLandFlatCost())245#endif246		{247			return false;	// Then no, it does not.248		}249250		if(!pUnit->canMoveAllTerrain())251		{252			return true;253		}254	}255256	return false;257}

Calls

Called by