Browse Source

movementPointsAfterEmbark: get max move points from TurnInfo

Missed that when originally implemented TurnInfo.
Not pretties code, but boost performance a lot.
ArseniyShestakov 10 years ago
parent
commit
a375c86ea2
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/mapObjects/CGHeroInstance.cpp

+ 3 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -1169,8 +1169,10 @@ int CGHeroInstance::movementPointsAfterEmbark(int MPsBefore, int basicCost, bool
 	if(!ti)
 		ti = new TurnInfo(this);
 
+	int mp1 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::LAND : EPathfindingLayer::SAIL);
+	int mp2 = ti->getMaxMovePoints(disembark ? EPathfindingLayer::SAIL : EPathfindingLayer::LAND);
 	if(ti->hasBonusOfType(Bonus::FREE_SHIP_BOARDING))
-		return (MPsBefore - basicCost) * static_cast<double>(maxMovePoints(disembark)) / maxMovePoints(!disembark);
+		return (MPsBefore - basicCost) * static_cast<double>(mp1) / mp2;
 
 	return 0; //take all MPs otherwise
 }