From fc6f62e633f7868a5604832a9e3e9560f7ab85a5 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Mon, 19 Oct 2015 07:27:00 +0300 Subject: [PATCH] getMovementCost: get rid of useless flying parameter --- CCallback.cpp | 2 +- lib/CGameState.cpp | 10 +++++----- lib/CGameState.h | 2 +- server/CGameHandler.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CCallback.cpp b/CCallback.cpp index da280db1c..605dd2afa 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -292,7 +292,7 @@ bool CCallback::canMoveBetween(const int3 &a, const int3 &b) int CCallback::getMovementCost(const CGHeroInstance * hero, int3 dest) { - return gs->getMovementCost(hero, hero->visitablePos(), dest, hero->hasBonusOfType (Bonus::FLYING_MOVEMENT), hero->movement); + return gs->getMovementCost(hero, hero->visitablePos(), dest, hero->movement); } const CPathsInfo * CCallback::getPathsInfo(const CGHeroInstance *h) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index ea08657d6..c3c5936c8 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -2099,7 +2099,7 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vectorgetTileCost(d,s); - if(d.blocked && flying) + if(d.blocked && h->canFly()) { bool freeFlying = h->getBonusesCount(Selector::typeSubtype(Bonus::FLYING_MOVEMENT, 1)) > 0; @@ -2147,7 +2147,7 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const getNeighbours(d, dest, vec, s.terType != ETerrainType::WATER, true); for(auto & elem : vec) { - int fcost = getMovementCost(h,dest, elem, flying, left, false); + int fcost = getMovementCost(h, dest, elem, left, false); if(fcost <= left) { return ret; @@ -3456,7 +3456,7 @@ void CPathfinder::calculatePaths() if(!isMovementPossible()) continue; - int cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), movement); + int cost = gs->getMovementCost(hero, cp->coord, dp->coord, movement); int remains = movement - cost; if(useEmbarkCost) { @@ -3470,7 +3470,7 @@ void CPathfinder::calculatePaths() //occurs rarely, when hero with low movepoints tries to leave the road turnAtNextTile++; int moveAtNextTile = maxMovePoints(cp); - cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), moveAtNextTile); //cost must be updated, movement points changed :( + cost = gs->getMovementCost(hero, cp->coord, dp->coord, moveAtNextTile); //cost must be updated, movement points changed :( remains = moveAtNextTile - cost; } diff --git a/lib/CGameState.h b/lib/CGameState.h index ea119be9d..c5c646582 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -401,7 +401,7 @@ public: bool isVisible(const CGObjectInstance *obj, boost::optional player); void getNeighbours(const TerrainTile &srct, int3 tile, std::vector &vec, const boost::logic::tribool &onLand, bool limitCoastSailing); - int getMovementCost(const CGHeroInstance *h, const int3 &src, const int3 &dest, bool flying, int remainingMovePoints=-1, bool checkLast=true); + int getMovementCost(const CGHeroInstance *h, const int3 &src, const int3 &dest, int remainingMovePoints=-1, bool checkLast=true); int getDate(Date::EDateType mode=Date::DAY) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month // ----- getters, setters ----- diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 2a44fe769..a51021ba2 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1733,7 +1733,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, bo } const TerrainTile t = *gs->getTile(hmpos); - const int cost = gs->getMovementCost(h, h->getPosition(), hmpos, h->hasBonusOfType(Bonus::FLYING_MOVEMENT), h->movement); + const int cost = gs->getMovementCost(h, h->getPosition(), hmpos, h->movement); const int3 guardPos = gs->guardingCreaturePosition(hmpos); const bool embarking = !h->boat && !t.visitableObjects.empty() && t.visitableObjects.back()->ID == Obj::BOAT;