Fix for a crash issue related to groups that both PEQ and Armm reported on the forums.

This commit is contained in:
SecretsOTheP 2013-03-24 04:01:49 -04:00
parent a6f2c1be8a
commit e609ec1df6
3 changed files with 31 additions and 31 deletions

View File

@ -6461,7 +6461,12 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app)
// Remove the merc from the old group
if (GetMerc())
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
{
if(GetGroup())
{
Merc::RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
}
}
Group* group = entity_list.GetGroupByClient(inviter->CastToClient());
@ -6660,35 +6665,31 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app)
group->DelMember(memberToDisband,false);
Client* memberClient = memberToDisband->CastToClient();
Merc* memberMerc = memberToDisband->CastToClient()->GetMerc();
memberMerc->RemoveMercFromGroup(memberMerc, group);
if(memberClient && memberMerc && group)
{
Merc::RemoveMercFromGroup(memberMerc, group);
if(!memberMerc->IsGrouped() && !memberClient->IsGrouped()) {
Group *g = new Group(memberClient);
if(!memberMerc->IsGrouped() && !memberClient->IsGrouped()) {
Group *g = new Group(memberClient);
if(!g) {
delete g;
g = NULL;
return;
}
entity_list.AddGroup(g);
entity_list.AddGroup(g);
if(g->GetID() == 0) {
safe_delete(g);
return;
}
if(memberMerc->AddMercToGroup(memberMerc, g)) {
database.SetGroupLeaderName(g->GetID(), memberClient->GetName());
g->SaveGroupLeaderAA();
database.SetGroupID(memberClient->GetName(), g->GetID(), memberClient->CharacterID());
database.SetGroupID(memberMerc->GetName(), g->GetID(), memberClient->CharacterID(), true);
database.RefreshGroupFromDB(memberClient);
if(g->GetID() == 0) {
safe_delete(g);
return;
}
if(Merc::AddMercToGroup(memberMerc, g)) {
database.SetGroupLeaderName(g->GetID(), memberClient->GetName());
g->SaveGroupLeaderAA();
database.SetGroupID(memberClient->GetName(), g->GetID(), memberClient->CharacterID());
database.SetGroupID(memberMerc->GetName(), g->GetID(), memberClient->CharacterID(), true);
database.RefreshGroupFromDB(memberClient);
}
}
}
}
else if(memberToDisband->IsMerc()) {
memberToDisband->CastToMerc()->RemoveMercFromGroup(memberToDisband->CastToMerc(), group);
memberToDisband->CastToMerc()->RemoveMercFromGroup(memberToDisband->CastToMerc(), group);
Merc::RemoveMercFromGroup(memberToDisband->CastToMerc(), group);
memberToDisband->CastToMerc()->Suspend();
}
}

View File

@ -192,7 +192,7 @@ bool Client::Process() {
{
GetMerc()->Save();
if(GetMerc()->GetGroup() != NULL)
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
Merc::RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
GetMerc()->Depop();
}
LeaveGroup();
@ -210,6 +210,7 @@ bool Client::Process() {
if (GetMerc())
{
GetMerc()->Save();
if(GetMerc()->GetGroup() != NULL)
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
GetMerc()->Depop();
}
@ -679,6 +680,7 @@ bool Client::Process() {
if (GetMerc())
{
GetMerc()->Save();
if(GetMerc()->GetGroup() != NULL)
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
GetMerc()->Depop();
}
@ -728,7 +730,8 @@ bool Client::Process() {
}
if (GetMerc())
{
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
if(GetMerc()->GetGroup() != NULL)
Merc::RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
GetMerc()->Depop();
}
adverrorinfo = 811;

View File

@ -5642,9 +5642,6 @@ bool Merc::Suspend() {
SetSuspended(true);
/*if(HasGroup()) {
RemoveMercFromGroup(this, GetGroup());
}*/
mercOwner->GetMercInfo().IsSuspended = true;
mercOwner->GetMercInfo().SuspendedTime = time(NULL) + RuleI(Mercs, SuspendIntervalS);
mercOwner->GetMercInfo().MercTimerRemaining = mercOwner->GetMercTimer()->GetRemainingTime();
@ -5652,7 +5649,6 @@ bool Merc::Suspend() {
Save();
mercOwner->GetMercTimer()->Disable();
//mercOwner->UpdateMercTimer();
mercOwner->SendMercSuspendResponsePacket(mercOwner->GetMercInfo().SuspendedTime);
Depop();
@ -5782,7 +5778,7 @@ void Merc::Depop() {
entity_list.RemoveFromHateLists(this);
if(HasGroup())
RemoveMercFromGroup(this, GetGroup());
Merc::RemoveMercFromGroup(this, GetGroup());
if(HasPet()) {
GetPet()->Depop();
@ -5843,7 +5839,7 @@ bool Merc::AddMercToGroup(Merc* merc, Group* group) {
if(merc && group) {
// Remove merc from current group if any
if(merc->HasGroup()) {
merc->RemoveMercFromGroup(merc, merc->GetGroup());
Merc::RemoveMercFromGroup(merc, merc->GetGroup());
}
// Add merc to this group
if(group->AddMember(merc)) {