mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
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:
parent
23820a369e
commit
c7ff207017
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user