Skip to content

Commit

Permalink
don't allow negative time units
Browse files Browse the repository at this point in the history
or energy units, for that matter.
  • Loading branch information
Warboy1982 committed May 13, 2021
1 parent 45f80da commit eacdad0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Savegame/BattleUnit.cpp
Expand Up @@ -1412,7 +1412,7 @@ bool BattleUnit::spendEnergy(int tu)
*/
void BattleUnit::setTimeUnits(int tu)
{
_tu = tu;
_tu = std::max(0, tu);
}

/**
Expand Down Expand Up @@ -3146,9 +3146,7 @@ void BattleUnit::recoverTimeUnits()
}
// Each fatal wound to the body reduces the soldier's energy recovery by 10%.
ENRecovery -= (_energy * (_fatalWounds[BODYPART_TORSO] * 10))/100;
_energy += ENRecovery;
if (_energy > getBaseStats()->stamina)
_energy = getBaseStats()->stamina;
_energy = std::max(0, std::min(getBaseStats()->stamina, _energy + ENRecovery));
}
}

Expand Down

0 comments on commit eacdad0

Please sign in to comment.