More hatelist fixes. Trying to nail the crash :S

This commit is contained in:
SecretsOTheP 2014-04-22 13:24:07 -04:00
parent dffee38dc6
commit dd1f5f6a11
6 changed files with 9 additions and 11 deletions

View File

@ -223,6 +223,7 @@ Bot::~Bot() {
GetPet()->Depop();
entity_list.RemoveBot(GetID());
entity_list.RemoveFromTargets(GetID(), true);
}
void Bot::SetBotID(uint32 botID) {

View File

@ -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();
}

View File

@ -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) {

View File

@ -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);

View File

@ -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();
}

View File

@ -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();
}