|
|
@@ -1106,22 +1106,19 @@ CBonusSystemNode & CGHeroInstance::whereShouldBeAttached(CGameState * gs)
|
|
|
|
|
|
int CGHeroInstance::movementPointsAfterEmbark(int MPsBefore, int basicCost, bool disembark, const TurnInfo * ti) const
|
|
|
{
|
|
|
- int ret = 0; //take all MPs by default
|
|
|
- bool localTi = false;
|
|
|
+ std::unique_ptr<TurnInfo> turnInfoLocal;
|
|
|
if(!ti)
|
|
|
{
|
|
|
- localTi = true;
|
|
|
- ti = new TurnInfo(this);
|
|
|
+ turnInfoLocal = std::make_unique<TurnInfo>(this);
|
|
|
+ ti = turnInfoLocal.get();
|
|
|
}
|
|
|
|
|
|
+ if(!ti->hasBonusOfType(Bonus::FREE_SHIP_BOARDING))
|
|
|
+ return 0; // take all MPs by default
|
|
|
+
|
|
|
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))
|
|
|
- ret = static_cast<int>((MPsBefore - basicCost) * static_cast<double>(mp1) / mp2);
|
|
|
-
|
|
|
- if(localTi)
|
|
|
- delete ti;
|
|
|
-
|
|
|
+ int ret = static_cast<int>((MPsBefore - basicCost) * static_cast<double>(mp1) / mp2);
|
|
|
return ret;
|
|
|
}
|
|
|
|