1
0

cWolf: Fixed targetting a nullptr.

This commit is contained in:
Mattes D 2016-11-20 18:10:54 +01:00 committed by Lukas Pioch
parent 59463be832
commit d17b21da55

View File

@ -38,11 +38,12 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn()) if ((a_TDI.Attacker != nullptr) && a_TDI.Attacker->IsPawn())
{ {
if (GetTarget()->IsPlayer()) auto currTarget = GetTarget();
if ((currTarget != nullptr) && currTarget->IsPlayer())
{ {
if (m_IsTame) if (m_IsTame)
{ {
if ((static_cast<cPlayer*>(GetTarget())->GetUUID() == m_OwnerUUID)) if ((static_cast<cPlayer*>(currTarget)->GetUUID() == m_OwnerUUID))
{ {
SetTarget(PreviousTarget); // Do not attack owner SetTarget(PreviousTarget); // Do not attack owner
} }
@ -64,7 +65,6 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
} }
} }
m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face m_World->BroadcastEntityMetadata(*this); // Broadcast health and possibly angry face
return true; return true;
} }