aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShocker <none@none>2010-09-05 00:38:19 +0300
committerShocker <none@none>2010-09-05 00:38:19 +0300
commitd4763852cf403f8ab33319c02e43237554631a84 (patch)
tree9e1e9162b0f6812f92c05a52b30ae459f9361ff6 /src
parent481c1fedd366490bfbcf9c90030579658731f110 (diff)
Core/Unit: Fix some health-related calculations by adjusting maximum size to 64 bit integers, closes issue 3778
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index ed66354336b..4060628e3b3 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1213,10 +1213,10 @@ class Unit : public WorldObject
uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); }
inline bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
- inline bool HealthBelowPct(int32 pct) const { return GetHealth() * 100 < GetMaxHealth() * pct; }
- inline bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * 100 < GetMaxHealth() * pct; }
- inline bool HealthAbovePct(int32 pct) const { return GetHealth() * 100 > GetMaxHealth() * pct; }
- inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
+ inline bool HealthBelowPct(uint32 pct) const { return GetHealth() * (uint64)100 < GetMaxHealth() * (uint64)pct; }
+ inline bool HealthBelowPctDamaged(uint32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * (int64)100 < GetMaxHealth() * (int64)pct; }
+ inline bool HealthAbovePct(uint32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)pct; }
+ inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
inline uint32 CountPctFromMaxHealth(int32 pct) const { return uint32(float(pct) * GetMaxHealth() / 100.0f); }
void SetHealth(uint32 val);