diff --git a/zone/bot.cpp b/zone/bot.cpp index 1526beddc..ae793cd47 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -223,6 +223,7 @@ Bot::~Bot() { GetPet()->Depop(); entity_list.RemoveBot(GetID()); + entity_list.RemoveFromTargets(GetID(), true); } void Bot::SetBotID(uint32 botID) { diff --git a/zone/client.cpp b/zone/client.cpp index 7aa7bd748..b2b9ff023 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -426,7 +426,8 @@ Client::~Client() { //let the stream factory know were done with this stream eqs->Close(); eqs->ReleaseFromUse(); - + //Moved this from ~Mob, because it could cause a crash in some cases where a hate list was still used and that mob was the only one on the hate list. + entity_list.RemoveFromTargets(GetID(), true); UninitializeBuffSlots(); } diff --git a/zone/entity.cpp b/zone/entity.cpp index 3f6130745..c09348384 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2107,9 +2107,6 @@ bool EntityList::RemoveMob(uint16 delete_id) if (delete_id == 0) return true; - //Moved this from ~Mob, because it could cause a crash in some cases where a hate list was still used and that mob was the only one on the hate list. - entity_list.RemoveFromTargets(delete_id, true); - auto it = mob_list.find(delete_id); if (it != mob_list.end()) { if (npc_list.count(delete_id)) @@ -2131,9 +2128,6 @@ bool EntityList::RemoveMob(Mob *delete_mob) if (delete_mob == 0) return true; - //Moved this from ~Mob, because it could cause a crash in some cases where a hate list was still used and that mob was the only one on the hate list. - entity_list.RemoveFromTargets(delete_mob, true); - auto it = mob_list.begin(); while (it != mob_list.end()) { if (it->second == delete_mob) { diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index abc33866e..d7cc9a9e5 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -205,9 +205,6 @@ void HateList::Add(Mob *ent, int32 in_hate, int32 in_dam, bool bFrenzy, bool iAd bool HateList::RemoveEnt(Mob *ent) { - if (!ent) - return NULL; - bool found = false; auto iterator = list.begin(); @@ -215,10 +212,12 @@ bool HateList::RemoveEnt(Mob *ent) { if((*iterator)->ent == ent) { + if(ent) parse->EventNPC(EVENT_HATE_LIST, owner->CastToNPC(), ent, "0", 0); found = true; - if(ent->IsClient()) + + if(ent && ent->IsClient()) ent->CastToClient()->DecrementAggroCount(); delete (*iterator); diff --git a/zone/merc.cpp b/zone/merc.cpp index c8c8da6fa..05cdbb65c 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -76,6 +76,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) Merc::~Merc() { AI_Stop(); entity_list.RemoveMerc(this->GetID()); + entity_list.RemoveFromTargets(GetID(), true); UninitializeBuffSlots(); } diff --git a/zone/npc.cpp b/zone/npc.cpp index 2611300d8..13c60965a 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -392,6 +392,8 @@ NPC::~NPC() safe_delete(reface_timer); safe_delete(swarmInfoPtr); safe_delete(qGlobals); + //Moved this from ~Mob, because it could cause a crash in some cases where a hate list was still used and that mob was the only one on the hate list. + entity_list.RemoveFromTargets(GetID(), true); UninitializeBuffSlots(); }