From c5eb05a0e04d6638121def394e5d1b7bf1641ac5 Mon Sep 17 00:00:00 2001 From: Niam5 Date: Wed, 22 Nov 2023 18:55:28 -0600 Subject: [PATCH] Move hook to protect against NULL being passed causing crash --- src/game/Entities/Unit.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 4e7f8a49bd..ee46c9eff1 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -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); @@ -1239,15 +1248,6 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn else // Killed creature JustKilledCreature(killer, static_cast(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();