Made Merc::AddMercToGroup handle cleaning up old groups as opposed to doing it in each location before AddMercToGroup. This should fix cases where the Merc's owner is invalid and being referenced, which causes the crash located in:

http://www.eqemulator.org/forums/showthread.php?t=36670&page=2
This commit is contained in:
SecretsOTheP
2013-03-25 13:07:58 -04:00
parent 23820a369e
commit c7ff207017
2 changed files with 14 additions and 20 deletions
+6 -7
View File
@@ -5839,16 +5839,15 @@ bool Merc::AddMercToGroup(Merc* merc, Group* group) {
if(merc->HasGroup()) {
Merc::RemoveMercFromGroup(merc, merc->GetGroup());
}
// Add merc to this group
if(group->AddMember(merc)) {
merc->SetFollowID(merc->GetMercOwner()->GetID());
Result = true;
//Try and add the member, followed by checking if the merc owner exists.
if(group->AddMember(merc) && merc->GetMercOwner() != NULL) {
merc->SetFollowID(merc->GetMercOwner()->GetID());
Result = true;
}
else
{
else {
//Suspend it if the member is not added and the merc's owner is not valid.
merc->Suspend();
}
}
return Result;