diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index bc74cc148..c29f9d9b9 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -6459,15 +6459,6 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) } } - // Remove the merc from the old group - if (GetMerc()) - { - if(GetMerc()->GetGroup()) - { - Merc::RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup()); - } - } - Group* group = entity_list.GetGroupByClient(inviter->CastToClient()); if(!group){ @@ -6539,8 +6530,9 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) // Add the merc back into the new group if (GetMerc()) { - if (GetMerc()->AddMercToGroup(GetMerc(), group)) { + if (Merc::AddMercToGroup(GetMerc(), group)) { database.SetGroupID(GetMerc()->GetName(), group->GetID(), inviter->CastToClient()->CharacterID(), true); + database.RefreshGroupFromDB(this); } } @@ -6667,8 +6659,6 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) Merc* memberMerc = memberToDisband->CastToClient()->GetMerc(); if(memberClient && memberMerc && group) { - Merc::RemoveMercFromGroup(memberMerc, group); - if(!memberMerc->IsGrouped() && !memberClient->IsGrouped()) { Group *g = new Group(memberClient); @@ -6713,13 +6703,18 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) return; } - if(GetMerc()->AddMercToGroup(GetMerc(), g)) { + if(Merc::AddMercToGroup(GetMerc(), g)) { database.SetGroupLeaderName(g->GetID(), this->GetName()); g->SaveGroupLeaderAA(); database.SetGroupID(this->GetName(), g->GetID(), this->CharacterID()); database.SetGroupID(GetMerc()->GetName(), g->GetID(), this->CharacterID(), true); database.RefreshGroupFromDB(this); } + else + { + if(GetMerc()) + GetMerc()->Depop(); + } } } } diff --git a/zone/merc.cpp b/zone/merc.cpp index a91593cbd..077b48cc7 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -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;