Explorar o código

CPathfinder: move flying into options and add walk on sea

ArseniyShestakov %!s(int64=10) %!d(string=hai) anos
pai
achega
9954dfb33a
Modificáronse 2 ficheiros con 8 adicións e 3 borrados
  1. 6 3
      lib/CGameState.cpp
  2. 2 0
      lib/CGameState.h

+ 6 - 3
lib/CGameState.cpp

@@ -3417,7 +3417,6 @@ bool CPathfinder::checkDestinationTile()
 
 void CPathfinder::calculatePaths()
 {
-	bool flying = hero->hasBonusOfType(Bonus::FLYING_MOVEMENT);
 	int maxMovePointsLand = hero->maxMovePoints(true);
 	int maxMovePointsWater = hero->maxMovePoints(false);
 
@@ -3457,7 +3456,7 @@ void CPathfinder::calculatePaths()
 			if(!isMovementPossible())
 				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;
 			if(useEmbarkCost)
 			{
@@ -3471,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, 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;
 			}
 
@@ -3612,6 +3611,10 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
 
 	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::TELEPORT_TWO_WAY);
 	options.insert(EOptions::TELEPORT_ONE_WAY);

+ 2 - 0
lib/CGameState.h

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