Skip to content

Commit

Permalink
Fix incorrect rounding 1% HP as 0 HP (indestructible features)
Browse files Browse the repository at this point in the history
Fixes ticket:3134
This fixes the problem where the map has features with 1% HP which
are incorrectly converted to 0 HP
  • Loading branch information
crab312 committed Feb 10, 2012
1 parent 2e03931 commit 2fc761a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/game.cpp
Expand Up @@ -4104,14 +4104,14 @@ static bool loadSaveDroidPointers(const QString &pFileName, DROID **ppsCurrentDr
static int healthValue(QSettings &ini, int defaultValue)
{
QString health = ini.value("health").toString();
if (health.isEmpty())
if (health.isEmpty() || defaultValue == 0)
{
return defaultValue;
}
else if (health.contains('%'))
{
int perc = health.remove('%').toInt();
return defaultValue * perc / 100;
return MAX(defaultValue * perc / 100, 1); //hp not supposed to be 0
}
else
{
Expand Down

0 comments on commit 2fc761a

Please sign in to comment.