1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

CPathfinder: move flying into options and add walk on sea

This commit is contained in:
ArseniyShestakov
2015-10-12 19:03:08 +03:00
parent 41c4323818
commit 9954dfb33a
2 changed files with 8 additions and 3 deletions

View File

@ -3417,7 +3417,6 @@ bool CPathfinder::checkDestinationTile()
void CPathfinder::calculatePaths() void CPathfinder::calculatePaths()
{ {
bool flying = hero->hasBonusOfType(Bonus::FLYING_MOVEMENT);
int maxMovePointsLand = hero->maxMovePoints(true); int maxMovePointsLand = hero->maxMovePoints(true);
int maxMovePointsWater = hero->maxMovePoints(false); int maxMovePointsWater = hero->maxMovePoints(false);
@ -3457,7 +3456,7 @@ void CPathfinder::calculatePaths()
if(!isMovementPossible()) if(!isMovementPossible())
continue; continue;
int cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, movement); int cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), movement);
int remains = movement - cost; int remains = movement - cost;
if(useEmbarkCost) if(useEmbarkCost)
{ {
@ -3471,7 +3470,7 @@ void CPathfinder::calculatePaths()
//occurs rarely, when hero with low movepoints tries to leave the road //occurs rarely, when hero with low movepoints tries to leave the road
turnAtNextTile++; turnAtNextTile++;
int moveAtNextTile = maxMovePoints(cp); int moveAtNextTile = maxMovePoints(cp);
cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, moveAtNextTile); //cost must be updated, movement points changed :( cost = gs->getMovementCost(hero, cp->coord, dp->coord, vstd::contains(options, EOptions::FLYING), moveAtNextTile); //cost must be updated, movement points changed :(
remains = moveAtNextTile - cost; remains = moveAtNextTile - cost;
} }
@ -3612,6 +3611,10 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
initializeGraph(); initializeGraph();
if(hero->canFly())
options.insert(EOptions::FLYING);
else if(hero->canWalkOnSea())
options.insert(EOptions::WALKING_ON_SEA);
options.insert(EOptions::EMBARK_AND_DISEMBARK); options.insert(EOptions::EMBARK_AND_DISEMBARK);
options.insert(EOptions::TELEPORT_TWO_WAY); options.insert(EOptions::TELEPORT_TWO_WAY);
options.insert(EOptions::TELEPORT_ONE_WAY); options.insert(EOptions::TELEPORT_ONE_WAY);

View File

@ -281,6 +281,8 @@ class CPathfinder : private CGameInfoCallback
private: private:
enum class EOptions enum class EOptions
{ {
FLYING,
WALKING_ON_SEA,
EMBARK_AND_DISEMBARK, EMBARK_AND_DISEMBARK,
TELEPORT_TWO_WAY, // Two-way monoliths and Subterranean Gate TELEPORT_TWO_WAY, // Two-way monoliths and Subterranean Gate
TELEPORT_ONE_WAY, // One-way monoliths with one known exit only TELEPORT_ONE_WAY, // One-way monoliths with one known exit only