mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Slight refactoring of CGHeroInstance::movementPointsAfterEmbark()
This commit is contained in:
parent
aae9e70771
commit
a0cd69e944
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user