1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

movementPointsAfterEmbark: get max move points from TurnInfo

Missed that when originally implemented TurnInfo.
Not pretties code, but boost performance a lot.
This commit is contained in:
ArseniyShestakov 2015-11-21 12:46:59 +03:00
parent 5ae6225ebc
commit a375c86ea2

View File

@ -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
}