Procházet zdrojové kódy

Fix pathfinding issues when hero has expert navigation

Andrii Danylchenko před 4 roky
rodič
revize
11e6e0d6f7
1 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 7 5
      lib/CPathfinder.cpp

+ 7 - 5
lib/CPathfinder.cpp

@@ -209,15 +209,17 @@ void MovementCostRule::process(
 	int moveAtNextTile = destination.movementLeft;
 	int moveAtNextTile = destination.movementLeft;
 	int cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile);
 	int cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile);
 	int remains = moveAtNextTile - cost;
 	int remains = moveAtNextTile - cost;
-	int maxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
+	int sourceLayerMaxMovePoints = pathfinderHelper->getMaxMovePoints(source.node->layer);
+
 	if(remains < 0)
 	if(remains < 0)
 	{
 	{
 		//occurs rarely, when hero with low movepoints tries to leave the road
 		//occurs rarely, when hero with low movepoints tries to leave the road
-		costAtNextTile += static_cast<float>(moveAtNextTile) / maxMovePoints;//we spent all points of current turn
+		costAtNextTile += static_cast<float>(moveAtNextTile) / sourceLayerMaxMovePoints;//we spent all points of current turn
 		pathfinderHelper->updateTurnInfo(++turnAtNextTile);
 		pathfinderHelper->updateTurnInfo(++turnAtNextTile);
 
 
-		maxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
-		moveAtNextTile = maxMovePoints;
+		int destinationLayerMaxMovePoints = pathfinderHelper->getMaxMovePoints(destination.node->layer);
+
+		moveAtNextTile = destinationLayerMaxMovePoints;
 
 
 		cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile); //cost must be updated, movement points changed :(
 		cost = pathfinderHelper->getMovementCost(source, destination, moveAtNextTile); //cost must be updated, movement points changed :(
 		remains = moveAtNextTile - cost;
 		remains = moveAtNextTile - cost;
@@ -231,7 +233,7 @@ void MovementCostRule::process(
 		cost = moveAtNextTile - remains;
 		cost = moveAtNextTile - remains;
 	}
 	}
 
 
-	costAtNextTile += static_cast<float>(cost) / maxMovePoints;
+	costAtNextTile += static_cast<float>(cost) / sourceLayerMaxMovePoints;
 
 
 	destination.cost = costAtNextTile;
 	destination.cost = costAtNextTile;
 	destination.turn = turnAtNextTile;
 	destination.turn = turnAtNextTile;