From ef945e6e9991ea7d782235697cdd27628052e739 Mon Sep 17 00:00:00 2001 From: zimp-wow <66187107+zimp-wow@users.noreply.github.com> Date: Wed, 19 Mar 2025 16:26:54 -0500 Subject: [PATCH] [Fix] Fix zone crash when attempting to add a disappearing client to hate list. (#4782) --- zone/attack.cpp | 6 ++++++ zone/mob.cpp | 5 ++++- zone/mob.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index e32941fec..6ed5d568d 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3041,9 +3041,15 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo if (!other) return; + if (other->IsDestroying()) + return; + if (other == this) return; + if (other->IsClient() && (other->CastToClient()->IsZoning() || other->CastToClient()->Connected() == false)) + return; + if (other->IsTrap()) return; diff --git a/zone/mob.cpp b/zone/mob.cpp index f721071e6..30f9c8690 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -131,7 +131,8 @@ Mob::Mob( m_scan_close_mobs_timer(6000), m_see_close_mobs_timer(1000), m_mob_check_moving_timer(1000), - bot_attack_flag_timer(10000) + bot_attack_flag_timer(10000), + m_destroying(false) { mMovementManager = &MobMovementManager::Get(); mMovementManager->AddMob(this); @@ -531,6 +532,8 @@ Mob::Mob( Mob::~Mob() { + m_destroying = true; + entity_list.RemoveMobFromCloseLists(this); m_close_mobs.clear(); diff --git a/zone/mob.h b/zone/mob.h index 55d248733..37a6ecf37 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1510,6 +1510,7 @@ public: void ClearDataBucketCache(); bool IsGuildmaster() const; + bool IsDestroying() const { return m_destroying; } protected: void CommonDamage(Mob* other, int64 &damage, const uint16 spell_id, const EQ::skills::SkillType attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic, eSpecialAttacks specal = eSpecialAttacks::None); @@ -1932,6 +1933,7 @@ private: EQ::InventoryProfile m_inv; std::shared_ptr m_target_of_heal_rotation; bool m_manual_follow; + bool m_destroying; void SetHeroicStrBonuses(StatBonuses* n); void SetHeroicStaBonuses(StatBonuses* n);