From fa18991917e3a9ac0c5a2116133981503c60bbc9 Mon Sep 17 00:00:00 2001 From: SecretsOTheP Date: Sat, 23 Mar 2013 10:04:49 -0400 Subject: [PATCH] Added a few checks to resolve dangling pointers involving Mercs. Similar to the AIYellForHelp crash fixed years ago by Rogean. --- zone/client_process.cpp | 3 ++- zone/entity.cpp | 2 ++ zone/merc.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 146c65e3d..f8dd10240 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -188,13 +188,14 @@ bool Client::Process() { if(linkdead_timer.Check()){ Save(); - LeaveGroup(); if (GetMerc()) { GetMerc()->Save(); + if(GetMerc()->GetGroup != NULL) GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup()); GetMerc()->Depop(); } + LeaveGroup(); Raid *myraid = entity_list.GetRaidByClient(this); if (myraid) { diff --git a/zone/entity.cpp b/zone/entity.cpp index dc162312b..660db5d7d 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -2760,6 +2760,8 @@ void EntityList::RemoveEntity(uint16 id) return; else if(entity_list.RemoveTrap(id)) return; + else if(entity_list.RemoveMerc(id)) + return; #ifdef BOTS // This block of code is necessary to clean up bot objects diff --git a/zone/merc.cpp b/zone/merc.cpp index 26eebc1a9..d39b670c1 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -4915,9 +4915,10 @@ void Merc::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_sk if(entity_list.GetCorpseByID(GetID())) entity_list.GetCorpseByID(GetID())->Depop(); + entity_list.RemoveMerc(GetID()); + if(Suspend()) { - //todo: perl event? } }