Bazaar developer reference

CvUnitMovement::MovementCostNoZOC(const CvUnit *, const CvPlot *, const CvPlot *, int, int, int)

Defined in
CvUnitMovement.cpp, line 165
Class
CvUnitMovement
Hook name
CivHooks::CvUnitMovement_MovementCostNoZOC

Hooks

static bool BeforeCvUnitMovement_MovementCostNoZOC(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining, int& result);static void AfterCvUnitMovement_MovementCostNoZOC(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining, int& result);static int ReplaceCvUnitMovement_MovementCostNoZOC(int (*original)(const CvUnit*, const CvPlot*, const CvPlot*, int, int, int), const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining);CivRegisterBefore<CivHooks::CvUnitMovement_MovementCostNoZOC>(host, &BeforeCvUnitMovement_MovementCostNoZOC);CivRegisterAfter<CivHooks::CvUnitMovement_MovementCostNoZOC>(host, &AfterCvUnitMovement_MovementCostNoZOC);CivRegisterReplace<CivHooks::CvUnitMovement_MovementCostNoZOC>(host, &ReplaceCvUnitMovement_MovementCostNoZOC);

Code

165int CvUnitMovement::MovementCostNoZOC(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining /*= 0*/)166{167	int iRegularCost;168	int iRouteCost;169	int iRouteFlatCost;170171	CvAssertMsg(pToPlot->getTerrainType() != NO_TERRAIN, "TerrainType is not assigned a valid value");172173	if(ConsumesAllMoves(pUnit, pFromPlot, pToPlot))174	{175		if (iMovesRemaining > 0)176			return iMovesRemaining;177		else178			return iMaxMoves;179	}180	else if(CostsOnlyOne(pUnit, pFromPlot, pToPlot))181	{182		return GC.getMOVE_DENOMINATOR();183	}184185	GetCostsForMove(pUnit, pFromPlot, pToPlot, iBaseMoves, iRegularCost, iRouteCost, iRouteFlatCost);186187	return std::max(1, std::min(iRegularCost, std::min(iRouteCost, iRouteFlatCost)));188}

Calls

Called by