Hooks
static bool BeforeCvUnitMovement_MovementCost(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining, int& result);static void AfterCvUnitMovement_MovementCost(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining, int& result);static int ReplaceCvUnitMovement_MovementCost(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_MovementCost>(host, &BeforeCvUnitMovement_MovementCost);CivRegisterAfter<CivHooks::CvUnitMovement_MovementCost>(host, &AfterCvUnitMovement_MovementCost);CivRegisterReplace<CivHooks::CvUnitMovement_MovementCost>(host, &ReplaceCvUnitMovement_MovementCost);
Code
132int CvUnitMovement::MovementCost(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining /*= 0*/)133{134 int iRegularCost;135 int iRouteCost;136 int iRouteFlatCost;137138 CvAssertMsg(pToPlot->getTerrainType() != NO_TERRAIN, "TerrainType is not assigned a valid value");139140 if(ConsumesAllMoves(pUnit, pFromPlot, pToPlot))141 {142 if (iMovesRemaining > 0)143 return iMovesRemaining;144 else145 return iMaxMoves;146 }147 else if(CostsOnlyOne(pUnit, pFromPlot, pToPlot))148 {149 return GC.getMOVE_DENOMINATOR();150 }151 else if(IsSlowedByZOC(pUnit, pFromPlot, pToPlot))152 {153 if (iMovesRemaining > 0)154 return iMovesRemaining;155 else156 return iMaxMoves;157 }158159 GetCostsForMove(pUnit, pFromPlot, pToPlot, iBaseMoves, iRegularCost, iRouteCost, iRouteFlatCost);160161 return std::max(1, std::min(iRegularCost, std::min(iRouteCost, iRouteFlatCost)));162}