Skip to content

Commit

Permalink
Move hook to protect against NULL being passed causing crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Niam5 committed Nov 23, 2023
1 parent 1f7c5ba commit c5eb05a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,15 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn

if (killer)
{
#ifdef BUILD_ELUNA
if (Creature* killerCre = killer->ToCreature())
{
// used by eluna
if (Player* killed = victim->ToPlayer())
sEluna->OnPlayerKilledByCreature(killerCre, killed);
}
#endif

// Call KilledUnit for creatures
if (UnitAI* ai = killer->AI())
ai->KilledUnit(victim);
Expand Down Expand Up @@ -1239,15 +1248,6 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn
else // Killed creature
JustKilledCreature(killer, static_cast<Creature*>(victim), responsiblePlayer);

#ifdef BUILD_ELUNA
if (Creature* killerCre = killer->ToCreature())
{
// used by eluna
if (Player* killed = victim->ToPlayer())
sEluna->OnPlayerKilledByCreature(killerCre, killed);
}
#endif

// stop combat
DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageAttackStop");
victim->CombatStop();
Expand Down

0 comments on commit c5eb05a

Please sign in to comment.