Fix gcc warnings.
Fix Assert and DebugPrint macros.
This commit is contained in:
parent
9c7004c8cc
commit
e82dd1e975
2 changed files with 28 additions and 23 deletions
src
|
@ -279,6 +279,30 @@ static void HandleBuffsEachCycle(CUnit &unit)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Modify unit's health according to burn and poison
|
||||
**
|
||||
** @param unit the unit to operate on
|
||||
*/
|
||||
static bool HandleBurnAndPoison(CUnit &unit)
|
||||
{
|
||||
if (unit.Removed || unit.Destroyed || unit.Variable[HP_INDEX].Max == 0
|
||||
|| unit.CurrentAction() == UnitActionBuilt
|
||||
|| unit.CurrentAction() == UnitActionDie) {
|
||||
return false;
|
||||
}
|
||||
// Burn & poison
|
||||
const int hpPercent = (100 * unit.Variable[HP_INDEX].Value) / unit.Variable[HP_INDEX].Max;
|
||||
if (hpPercent <= unit.Type->BurnPercent && unit.Type->BurnDamageRate) {
|
||||
HitUnit(NoUnitP, unit, unit.Type->BurnDamageRate);
|
||||
return true;
|
||||
}
|
||||
if (unit.Variable[POISON_INDEX].Value && unit.Type->PoisonDrain) {
|
||||
HitUnit(NoUnitP, unit, unit.Type->PoisonDrain);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
** Handle things about the unit that decay over time each second
|
||||
|
@ -295,26 +319,8 @@ static void HandleBuffsEachSecond(CUnit &unit)
|
|||
|| i == INVISIBLE_INDEX || i == UNHOLYARMOR_INDEX || i == POISON_INDEX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == HP_INDEX) {
|
||||
bool burn = false, poison = false;
|
||||
|
||||
// Burn & poison
|
||||
// Health doesn't regenerate while burning or poisoned.
|
||||
if (!unit.Removed && !unit.Destroyed && unit.Variable[HP_INDEX].Max
|
||||
&& unit.CurrentAction() != UnitActionBuilt
|
||||
&& unit.CurrentAction() != UnitActionDie) {
|
||||
if (((100 * unit.Variable[HP_INDEX].Value) / unit.Variable[HP_INDEX].Max) <= unit.Type->BurnPercent
|
||||
&& unit.Type->BurnDamageRate) {
|
||||
HitUnit(NoUnitP, unit, unit.Type->BurnDamageRate);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unit.Variable[POISON_INDEX].Value && unit.Type->PoisonDrain) {
|
||||
HitUnit(NoUnitP, unit, unit.Type->PoisonDrain);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (i == HP_INDEX && HandleBurnAndPoison(unit)) {
|
||||
continue;
|
||||
}
|
||||
if (unit.Variable[i].Enable && unit.Variable[i].Increase) {
|
||||
IncreaseVariable(unit, i);
|
||||
|
@ -322,7 +328,6 @@ static void HandleBuffsEachSecond(CUnit &unit)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Handle the action of a unit.
|
||||
**
|
||||
|
|
|
@ -113,13 +113,13 @@ extern void PrintOnStdOut(const char *format, ...);
|
|||
** Assert a condition. If cond is not true abort with file,line.
|
||||
*/
|
||||
#define Assert(cond) \
|
||||
if (EnableAssert) do { if (!(cond)) { AbortAt(__FILE__, __LINE__, __func__, #cond); }} while (0)
|
||||
do { if (EnableAssert && !(cond)) { AbortAt(__FILE__, __LINE__, __func__, #cond); }} while (0)
|
||||
|
||||
/**
|
||||
** Print debug information with function name.
|
||||
*/
|
||||
#define DebugPrint(args) \
|
||||
if (EnableDebugPrint) do { PrintFunction(); PrintOnStdOut(args); } while (0)
|
||||
do { if (EnableDebugPrint) { PrintFunction(); PrintOnStdOut(args); } } while (0)
|
||||
|
||||
/*============================================================================
|
||||
== Definitions
|
||||
|
|
Loading…
Add table
Reference in a new issue