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

View File

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

View File

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