diff options
author | Fabian <fenstein12@googlemail.com> | 2017-11-22 14:47:52 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-11-22 14:47:52 +0100 |
commit | 0dd172b80ffc949cf87119ad2003589d7eb82c46 (patch) | |
tree | a7af747aa95241297f07104c138cfc66cf7f6c97 /src/Entities | |
parent | cBlockRail: Fix assertion failure (#4075) (diff) | |
download | cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar.gz cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar.bz2 cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar.lz cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar.xz cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.tar.zst cuberite-0dd172b80ffc949cf87119ad2003589d7eb82c46.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 10 | ||||
-rw-r--r-- | src/Entities/Entity.h | 12 | ||||
-rw-r--r-- | src/Entities/Minecart.cpp | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 90aefd082..11405d2fd 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -528,9 +528,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) Player->GetStatManager().AddValue(statDamageDealt, static_cast<StatValue>(floor(a_TDI.FinalDamage * 10 + 0.5))); } - m_Health -= static_cast<short>(a_TDI.FinalDamage); + m_Health -= static_cast<float>(a_TDI.FinalDamage); - m_Health = std::max(m_Health, 0); + m_Health = std::max(m_Health, 0.0f); // Add knockback: if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != nullptr)) @@ -810,9 +810,9 @@ void cEntity::Heal(int a_HitPoints) -void cEntity::SetHealth(int a_Health) +void cEntity::SetHealth(float a_Health) { - m_Health = Clamp(a_Health, 0, m_MaxHealth); + m_Health = Clamp(a_Health, 0.0f, m_MaxHealth); } @@ -1782,7 +1782,7 @@ void cEntity::OnFinishedBurning(void) -void cEntity::SetMaxHealth(int a_MaxHealth) +void cEntity::SetMaxHealth(float a_MaxHealth) { m_MaxHealth = a_MaxHealth; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 4174160bf..fae296ab4 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -368,10 +368,10 @@ public: virtual void Heal(int a_HitPoints); /** Returns the health of this entity */ - int GetHealth(void) const { return m_Health; } + float GetHealth(void) const { return m_Health; } /** Sets the health of this entity; doesn't broadcast any hurt animation */ - void SetHealth(int a_Health); + void SetHealth(float a_Health); // tolua_end @@ -403,9 +403,9 @@ public: // tolua_begin /** Sets the maximum value for the health */ - void SetMaxHealth(int a_MaxHealth); + void SetMaxHealth(float a_MaxHealth); - int GetMaxHealth(void) const { return m_MaxHealth; } + float GetMaxHealth(void) const { return m_MaxHealth; } /** Sets whether the entity is fireproof */ void SetIsFireproof(bool a_IsFireproof); @@ -556,8 +556,8 @@ protected: Note that the UniqueID is not persisted through storage. */ UInt32 m_UniqueID; - int m_Health; - int m_MaxHealth; + float m_Health; + float m_MaxHealth; /** The entity to which this entity is attached (vehicle), nullptr if none */ cEntity * m_AttachedTo; diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 7c5ca49ce..4de53d716 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -1035,7 +1035,7 @@ bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI) if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && static_cast<cPlayer *>(TDI.Attacker)->IsGameModeCreative()) { Destroy(); - TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative + TDI.FinalDamage = static_cast<int>(GetMaxHealth()); // Instant hit for creative SetInvulnerableTicks(0); return super::DoTakeDamage(TDI); // No drops for creative } |