// --------------------------------------------------------------------------- int CvUnitMovement::MovementCost(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iBaseMoves, int iMaxMoves, int iMovesRemaining /*= 0*/) { int iRegularCost; int iRouteCost; int iRouteFlatCost; CvAssertMsg(pToPlot->getTerrainType() != NO_TERRAIN, "TerrainType is not assigned a valid value"); if(ConsumesAllMoves(pUnit, pFromPlot, pToPlot)) { if (iMovesRemaining > 0) return iMovesRemaining; else return iMaxMoves; } else if(CostsOnlyOne(pUnit, pFromPlot, pToPlot)) { return GC.getMOVE_DENOMINATOR(); } else if(IsSlowedByZOC(pUnit, pFromPlot, pToPlot)) { if (iMovesRemaining > 0) return iMovesRemaining; else return iMaxMoves; } GetCostsForMove(pUnit, pFromPlot, pToPlot, iBaseMoves, iRegularCost, iRouteCost, iRouteFlatCost); return std::max(1, std::min(iRegularCost, std::min(iRouteCost, iRouteFlatCost))); }
// --------------------------------------------------------------------------- int CvUnitMovement::MovementCostNoZOC(const CvUnit* pUnit, const CvPlot* pFromPlot, const CvPlot* pToPlot, int iMovesRemaining, int iMaxMoves) { int iCost = GetCostsForMove(pUnit, pFromPlot, pToPlot); //now, if there was a domain change, our base moves might change //make sure that the movement cost is always so high that we never end up with more than the base moves for the new domain int iLeftOverMoves = iMovesRemaining-iCost; if ( iLeftOverMoves > iMaxMoves ) iCost += (iLeftOverMoves-iMaxMoves); return std::min( iCost, iMovesRemaining ); }