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 7fe95e4b4..077b48cc7 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -50,7 +50,6 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) _lost_confidence = false; _hatedCount = 0; - ourNPCData = d; memset(equipment, 0, sizeof(equipment)); SetMercID(0); @@ -74,7 +73,6 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) Merc::~Merc() { AI_Stop(); - safe_delete(ourNPCData); //Since mercs are dynamically alloc'd we should probably safe_delete the data they were made from. I'm not entirely sure this is safe to delete a const. entity_list.RemoveMerc(this->GetID()); UninitializeBuffSlots(); } @@ -1915,9 +1913,9 @@ void Merc::AI_Start(int32 iMoveDelay) { AIautocastspell_timer->Start(RandomTimer(0, 2000), false); } - if (ourNPCData) { + if (NPCTypedata_ours) { //AI_AddNPCSpells(ourNPCData->npc_spells_id); - NPCSpecialAttacks(ourNPCData->npc_attacks,0); + NPCSpecialAttacks(NPCTypedata_ours->npc_attacks,0); } SendTo(GetX(), GetY(), GetZ()); @@ -5841,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; diff --git a/zone/merc.h b/zone/merc.h index b76bb566d..dadba3fc1 100644 --- a/zone/merc.h +++ b/zone/merc.h @@ -379,8 +379,6 @@ private: bool _lost_confidence; int _hatedCount; uint32 owner_char_id; - const NPCType* ourNPCData; - Timer endupkeep_timer; Timer rest_timer; Timer confidence_timer;