Browse Source

CPathfinder: move embark special case code down

It's not affect cost calculations any way so let it's be in same order as it's used in condition under it.
ArseniyShestakov 10 years ago
parent
commit
cd7c5acbc4
1 changed files with 4 additions and 4 deletions
  1. 4 4
      lib/CGameState.cpp

+ 4 - 4
lib/CGameState.cpp

@@ -3417,10 +3417,6 @@ void CPathfinder::calculatePaths()
 			if(!isMovementPossible())
 			if(!isMovementPossible())
 				continue;
 				continue;
 
 
-			//special case -> hero embarked a boat standing on a guarded tile -> we must allow to move away from that tile
-			if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableId() == Obj::BOAT)
-				guardedSource = false;
-
 			int cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, movement);
 			int cost = gs->getMovementCost(hero, cp->coord, dp->coord, flying, movement);
 			int remains = movement - cost;
 			int remains = movement - cost;
 			if(useEmbarkCost)
 			if(useEmbarkCost)
@@ -3439,6 +3435,10 @@ void CPathfinder::calculatePaths()
 				remains = moveAtNextTile - cost;
 				remains = moveAtNextTile - cost;
 			}
 			}
 
 
+			//special case -> hero embarked a boat standing on a guarded tile -> we must allow to move away from that tile
+			if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableId() == Obj::BOAT)
+				guardedSource = false;
+
 			if((dp->turns==0xff		//we haven't been here before
 			if((dp->turns==0xff		//we haven't been here before
 				|| dp->turns > turnAtNextTile
 				|| dp->turns > turnAtNextTile
 				|| (dp->turns >= turnAtNextTile  &&  dp->moveRemains < remains)) //this route is faster
 				|| (dp->turns >= turnAtNextTile  &&  dp->moveRemains < remains)) //this route is faster