diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 12:35:22 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 12:35:22 +0200 |
commit | 07a5bf0984559d04fce1091b82b0952217ac64cc (patch) | |
tree | 0d1eee372a782213c9e2b84deaefe717b379a04b /src/Entities/Entity.cpp | |
parent | Skeletons (diff) | |
parent | Revert "Replace ItemCallbacks with lambdas (#3948)" (diff) | |
download | cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.gz cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.bz2 cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.lz cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.xz cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.tar.zst cuberite-07a5bf0984559d04fce1091b82b0952217ac64cc.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 956534856..5f6b81497 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -306,22 +306,38 @@ void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_R void cEntity::TakeDamage(eDamageType a_DamageType, UInt32 a_AttackerID, int a_RawDamage, double a_KnockbackAmount) { - m_World->DoWithEntityByID(a_AttackerID, [=](cEntity & a_Attacker) + class cFindEntity : public cEntityCallback + { + public: + + cEntity * m_Entity; + eDamageType m_DamageType; + int m_RawDamage; + double m_KnockbackAmount; + + virtual bool Item(cEntity * a_Attacker) override { cPawn * Attacker; - if (a_Attacker.IsPawn()) + if (a_Attacker->IsPawn()) { - Attacker = static_cast<cPawn*>(&a_Attacker); + Attacker = static_cast<cPawn*>(a_Attacker); } else { Attacker = nullptr; } - TakeDamage(a_DamageType, Attacker, a_RawDamage, a_KnockbackAmount); + + m_Entity->TakeDamage(m_DamageType, Attacker, m_RawDamage, m_KnockbackAmount); return true; } - ); + } Callback; + + Callback.m_Entity = this; + Callback.m_DamageType = a_DamageType; + Callback.m_RawDamage = a_RawDamage; + Callback.m_KnockbackAmount = a_KnockbackAmount; + m_World->DoWithEntityByID(a_AttackerID, Callback); } @@ -652,7 +668,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType) int cEntity::GetEnchantmentCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage) { - int TotalEPF = 0; + int TotalEPF = 0.0; const cItem ArmorItems[] = { GetEquippedHelmet(), GetEquippedChestplate(), GetEquippedLeggings(), GetEquippedBoots() }; for (size_t i = 0; i < ARRAYCOUNT(ArmorItems); i++) |