summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-09-11 23:20:49 +0200
committerMattes D <github@xoft.cz>2017-09-11 23:20:49 +0200
commite225b7f8262df48ad4d7094bc295add3007b0649 (patch)
treea42e9afcc88cfe6e9d1258458e3ad42764083d0e /src/Entities/Entity.cpp
parentcBlockArea: change MakeIndex to return size_t (diff)
downloadcuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.gz
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.bz2
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.lz
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.xz
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.tar.zst
cuberite-e225b7f8262df48ad4d7094bc295add3007b0649.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ba75f0443..a57449122 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -302,38 +302,22 @@ 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)
{
- class cFindEntity : public cEntityCallback
- {
- public:
-
- cEntity * m_Entity;
- eDamageType m_DamageType;
- int m_RawDamage;
- double m_KnockbackAmount;
-
- virtual bool Item(cEntity * a_Attacker) override
+ m_World->DoWithEntityByID(a_AttackerID, [=](cEntity & a_Attacker)
{
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;
}
-
- m_Entity->TakeDamage(m_DamageType, Attacker, m_RawDamage, m_KnockbackAmount);
+ TakeDamage(a_DamageType, Attacker, a_RawDamage, a_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);
+ );
}
@@ -664,7 +648,7 @@ bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType)
int cEntity::GetEnchantmentCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage)
{
- int TotalEPF = 0.0;
+ int TotalEPF = 0;
const cItem ArmorItems[] = { GetEquippedHelmet(), GetEquippedChestplate(), GetEquippedLeggings(), GetEquippedBoots() };
for (size_t i = 0; i < ARRAYCOUNT(ArmorItems); i++)