mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-19 08:11:30 +00:00
Added some extra checks and clean-up related to Groups and Mercenaries.
This commit is contained in:
parent
c8278608a3
commit
94be9e9162
@ -1,5 +1,8 @@
|
|||||||
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
|
== 01/08/2015 ==
|
||||||
|
Trevius: Added some extra checks and clean-up related to Groups and Mercenaries.
|
||||||
|
|
||||||
== 01/07/2015 ==
|
== 01/07/2015 ==
|
||||||
Uleat: Excluded text link body from message scrambling in Client::GarbleMessage()
|
Uleat: Excluded text link body from message scrambling in Client::GarbleMessage()
|
||||||
Trevius: Mercenaries now load directly from tables only. The vwMercNpcTypes view is no longer required and can be deleted.
|
Trevius: Mercenaries now load directly from tables only. The vwMercNpcTypes view is no longer required and can be deleted.
|
||||||
|
|||||||
@ -26,23 +26,16 @@
|
|||||||
extern EntityList entity_list;
|
extern EntityList entity_list;
|
||||||
extern WorldServer worldserver;
|
extern WorldServer worldserver;
|
||||||
|
|
||||||
//
|
|
||||||
// Xorlac: This will need proper synchronization to make it work correctly.
|
|
||||||
// Also, should investigate client ack for packet to ensure proper synch.
|
|
||||||
//
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
note about how groups work:
|
note about how groups work:
|
||||||
A group contains 2 list, a list of pointers to members and a
|
A group contains 2 list, a list of pointers to members and a
|
||||||
list of member names. All members of a group should have their
|
list of member names. All members of a group should have their
|
||||||
name in the membername array, wether they are in the zone or not.
|
name in the membername array, whether they are in the zone or not.
|
||||||
Only members in this zone will have non-null pointers in the
|
Only members in this zone will have non-null pointers in the
|
||||||
members array.
|
members array.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//create a group which should allready exist in the database
|
//create a group which should already exist in the database
|
||||||
Group::Group(uint32 gid)
|
Group::Group(uint32 gid)
|
||||||
: GroupIDConsumer(gid)
|
: GroupIDConsumer(gid)
|
||||||
{
|
{
|
||||||
@ -112,8 +105,7 @@ Group::~Group()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cofruben:Split money used in OP_Split.
|
//Split money used in OP_Split (/split and /autosplit).
|
||||||
//Rewritten by Father Nitwit
|
|
||||||
void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter) {
|
void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter) {
|
||||||
//avoid unneeded work
|
//avoid unneeded work
|
||||||
if(copper == 0 && silver == 0 && gold == 0 && platinum == 0)
|
if(copper == 0 && silver == 0 && gold == 0 && platinum == 0)
|
||||||
@ -197,7 +189,7 @@ void Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinu
|
|||||||
|
|
||||||
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
||||||
if (members[i] != nullptr && members[i]->IsClient()) { // If Group Member is Client
|
if (members[i] != nullptr && members[i]->IsClient()) { // If Group Member is Client
|
||||||
Client *c = members[i]->CastToClient();
|
Client *c = members[i]->CastToClient();
|
||||||
//I could not get MoneyOnCorpse to work, so we use this
|
//I could not get MoneyOnCorpse to work, so we use this
|
||||||
c->AddMoneyToPP(cpsplit, spsplit, gpsplit, ppsplit, true);
|
c->AddMoneyToPP(cpsplit, spsplit, gpsplit, ppsplit, true);
|
||||||
c->Message(2, msg.c_str());
|
c->Message(2, msg.c_str());
|
||||||
@ -368,7 +360,6 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
|
|||||||
void Group::AddMember(const char *NewMemberName)
|
void Group::AddMember(const char *NewMemberName)
|
||||||
{
|
{
|
||||||
// This method should be called when both the new member and the group leader are in a different zone to this one.
|
// This method should be called when both the new member and the group leader are in a different zone to this one.
|
||||||
//
|
|
||||||
for (uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i)
|
for (uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i)
|
||||||
if(!strcasecmp(membername[i], NewMemberName))
|
if(!strcasecmp(membername[i], NewMemberName))
|
||||||
{
|
{
|
||||||
@ -395,9 +386,8 @@ void Group::QueuePacket(const EQApplicationPacket *app, bool ack_req)
|
|||||||
members[i]->CastToClient()->QueuePacket(app, ack_req);
|
members[i]->CastToClient()->QueuePacket(app, ack_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
// solar: sends the rest of the group's hps to member. this is useful when
|
// Sends the rest of the group's hps to member. this is useful when someone
|
||||||
// someone first joins a group, but otherwise there shouldn't be a need to
|
// first joins a group, but otherwise there shouldn't be a need to call it
|
||||||
// call it
|
|
||||||
void Group::SendHPPacketsTo(Mob *member)
|
void Group::SendHPPacketsTo(Mob *member)
|
||||||
{
|
{
|
||||||
if(member && member->IsClient())
|
if(member && member->IsClient())
|
||||||
@ -459,9 +449,11 @@ void Group::SendHPPacketsFrom(Mob *member)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//updates a group member's client pointer when they zone in
|
//updates a group member's client pointer when they zone in
|
||||||
//if the group was in the zone allready
|
//if the group was in the zone already
|
||||||
bool Group::UpdatePlayer(Mob* update){
|
bool Group::UpdatePlayer(Mob* update){
|
||||||
|
|
||||||
|
bool updateSuccess = false;
|
||||||
|
|
||||||
VerifyGroup();
|
VerifyGroup();
|
||||||
|
|
||||||
uint32 i=0;
|
uint32 i=0;
|
||||||
@ -487,7 +479,8 @@ bool Group::UpdatePlayer(Mob* update){
|
|||||||
{
|
{
|
||||||
members[i] = update;
|
members[i] = update;
|
||||||
members[i]->SetGrouped(true);
|
members[i]->SetGrouped(true);
|
||||||
return true;
|
updateSuccess = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +488,7 @@ bool Group::UpdatePlayer(Mob* update){
|
|||||||
if (update->IsClient() && !mentoree && mentoree_name.length() && !mentoree_name.compare(update->GetName()))
|
if (update->IsClient() && !mentoree && mentoree_name.length() && !mentoree_name.compare(update->GetName()))
|
||||||
mentoree = update->CastToClient();
|
mentoree = update->CastToClient();
|
||||||
|
|
||||||
return false;
|
return updateSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -520,6 +513,7 @@ void Group::MemberZoned(Mob* removemob) {
|
|||||||
}
|
}
|
||||||
#endif //BOTS
|
#endif //BOTS
|
||||||
}
|
}
|
||||||
|
|
||||||
if(removemob->IsClient() && HasRole(removemob, RoleAssist))
|
if(removemob->IsClient() && HasRole(removemob, RoleAssist))
|
||||||
SetGroupAssistTarget(0);
|
SetGroupAssistTarget(0);
|
||||||
|
|
||||||
@ -592,7 +586,7 @@ bool Group::DelMemberOOZ(const char *Name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Group::DelMember(Mob* oldmember,bool ignoresender)
|
bool Group::DelMember(Mob* oldmember, bool ignoresender)
|
||||||
{
|
{
|
||||||
if (oldmember == nullptr)
|
if (oldmember == nullptr)
|
||||||
{
|
{
|
||||||
@ -690,6 +684,8 @@ bool Group::DelMember(Mob* oldmember,bool ignoresender)
|
|||||||
oldmember->CastToClient()->QueuePacket(outapp);
|
oldmember->CastToClient()->QueuePacket(outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(oldmember->IsClient())
|
if(oldmember->IsClient())
|
||||||
{
|
{
|
||||||
database.SetGroupID(oldmember->GetCleanName(), 0, oldmember->CastToClient()->CharacterID(), false);
|
database.SetGroupID(oldmember->GetCleanName(), 0, oldmember->CastToClient()->CharacterID(), false);
|
||||||
@ -707,8 +703,6 @@ bool Group::DelMember(Mob* oldmember,bool ignoresender)
|
|||||||
oldmember->SetGrouped(false);
|
oldmember->SetGrouped(false);
|
||||||
disbandcheck = true;
|
disbandcheck = true;
|
||||||
|
|
||||||
safe_delete(outapp);
|
|
||||||
|
|
||||||
if(HasRole(oldmember, RoleTank))
|
if(HasRole(oldmember, RoleTank))
|
||||||
{
|
{
|
||||||
SetGroupTankTarget(0);
|
SetGroupTankTarget(0);
|
||||||
@ -998,24 +992,21 @@ void Group::SendLeadershipAAUpdate()
|
|||||||
// aware of it until they are next in the same zone as the leader.
|
// aware of it until they are next in the same zone as the leader.
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct));
|
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct));
|
||||||
|
|
||||||
GroupJoin_Struct* gu = (GroupJoin_Struct*)outapp->pBuffer;
|
GroupJoin_Struct* gu = (GroupJoin_Struct*)outapp->pBuffer;
|
||||||
|
|
||||||
gu->action = groupActAAUpdate;
|
gu->action = groupActAAUpdate;
|
||||||
|
|
||||||
uint32 i = 0;
|
|
||||||
|
|
||||||
gu->leader_aas = LeaderAbilities;
|
gu->leader_aas = LeaderAbilities;
|
||||||
|
|
||||||
gu->NPCMarkerID = GetNPCMarkerID();
|
gu->NPCMarkerID = GetNPCMarkerID();
|
||||||
|
|
||||||
|
uint32 i = 0;
|
||||||
for (i = 0;i < MAX_GROUP_MEMBERS; ++i)
|
for (i = 0;i < MAX_GROUP_MEMBERS; ++i)
|
||||||
|
{
|
||||||
if(members[i] && members[i]->IsClient())
|
if(members[i] && members[i]->IsClient())
|
||||||
{
|
{
|
||||||
strcpy(gu->yourname, members[i]->GetName());
|
strcpy(gu->yourname, members[i]->GetName());
|
||||||
strcpy(gu->membername, members[i]->GetName());
|
strcpy(gu->membername, members[i]->GetName());
|
||||||
members[i]->CastToClient()->QueuePacket(outapp);
|
members[i]->CastToClient()->QueuePacket(outapp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
}
|
}
|
||||||
@ -1037,8 +1028,8 @@ uint8 Group::GroupCount() {
|
|||||||
|
|
||||||
uint32 Group::GetHighestLevel()
|
uint32 Group::GetHighestLevel()
|
||||||
{
|
{
|
||||||
uint32 level = 1;
|
uint32 level = 1;
|
||||||
uint32 i;
|
uint32 i;
|
||||||
for (i = 0; i < MAX_GROUP_MEMBERS; i++)
|
for (i = 0; i < MAX_GROUP_MEMBERS; i++)
|
||||||
{
|
{
|
||||||
if (members[i])
|
if (members[i])
|
||||||
@ -1049,10 +1040,11 @@ uint32 i;
|
|||||||
}
|
}
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Group::GetLowestLevel()
|
uint32 Group::GetLowestLevel()
|
||||||
{
|
{
|
||||||
uint32 level = 255;
|
uint32 level = 255;
|
||||||
uint32 i;
|
uint32 i;
|
||||||
for (i = 0; i < MAX_GROUP_MEMBERS; i++)
|
for (i = 0; i < MAX_GROUP_MEMBERS; i++)
|
||||||
{
|
{
|
||||||
if (members[i])
|
if (members[i])
|
||||||
@ -1112,16 +1104,14 @@ void Group::VerifyGroup() {
|
|||||||
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
||||||
if (membername[i][0] == '\0') {
|
if (membername[i][0] == '\0') {
|
||||||
#if EQDEBUG >= 7
|
#if EQDEBUG >= 7
|
||||||
LogFile->write(EQEMuLog::Debug, "Group %lu: Verify %d: Empty.\n", (unsigned long)GetID(), i);
|
LogFile->write(EQEMuLog::Debug, "Group %lu: Verify %d: Empty.\n", (unsigned long)GetID(), i);
|
||||||
#endif
|
#endif
|
||||||
members[i] = nullptr;
|
members[i] = nullptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//it should be safe to use GetClientByName, but Group is trying
|
|
||||||
//to be generic, so we'll go for general Mob
|
|
||||||
Mob *them = entity_list.GetMob(membername[i]);
|
Mob *them = entity_list.GetMob(membername[i]);
|
||||||
if(them == nullptr && members[i] != nullptr) { //they arnt here anymore....
|
if(them == nullptr && members[i] != nullptr) { //they aren't in zone
|
||||||
#if EQDEBUG >= 6
|
#if EQDEBUG >= 6
|
||||||
LogFile->write(EQEMuLog::Debug, "Member of group %lu named '%s' has disappeared!!", (unsigned long)GetID(), membername[i]);
|
LogFile->write(EQEMuLog::Debug, "Member of group %lu named '%s' has disappeared!!", (unsigned long)GetID(), membername[i]);
|
||||||
#endif
|
#endif
|
||||||
@ -1143,7 +1133,6 @@ LogFile->write(EQEMuLog::Debug, "Group %lu: Verify %d: Empty.\n", (unsigned long
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Group::GroupMessage_StringID(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2,const char* message3,const char* message4,const char* message5,const char* message6,const char* message7,const char* message8,const char* message9, uint32 distance) {
|
void Group::GroupMessage_StringID(Mob* sender, uint32 type, uint32 string_id, const char* message,const char* message2,const char* message3,const char* message4,const char* message5,const char* message6,const char* message7,const char* message8,const char* message9, uint32 distance) {
|
||||||
uint32 i;
|
uint32 i;
|
||||||
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
for (i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
||||||
@ -1153,12 +1142,13 @@ void Group::GroupMessage_StringID(Mob* sender, uint32 type, uint32 string_id, co
|
|||||||
if(members[i] == sender)
|
if(members[i] == sender)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(!members[i]->IsClient())
|
||||||
|
continue;
|
||||||
|
|
||||||
members[i]->Message_StringID(type, string_id, message, message2, message3, message4, message5, message6, message7, message8, message9, 0);
|
members[i]->Message_StringID(type, string_id, message, message2, message3, message4, message5, message6, message7, message8, message9, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Client::LeaveGroup() {
|
void Client::LeaveGroup() {
|
||||||
Group *g = GetGroup();
|
Group *g = GetGroup();
|
||||||
|
|
||||||
@ -1178,7 +1168,7 @@ void Client::LeaveGroup() {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g->DelMember(this);
|
g->DelMember(this);
|
||||||
if (GetMerc() && GetMerc()->HasGroup() && GetMerc()->GetGroup() == g)
|
if (GetMerc() != nullptr && g == GetMerc()->GetGroup() )
|
||||||
{
|
{
|
||||||
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
|
GetMerc()->RemoveMercFromGroup(GetMerc(), GetMerc()->GetGroup());
|
||||||
}
|
}
|
||||||
@ -1363,7 +1353,7 @@ void Group::MarkNPC(Mob* Target, int Number)
|
|||||||
// Send a packet to all group members in this zone causing the client to prefix the Target mob's name
|
// Send a packet to all group members in this zone causing the client to prefix the Target mob's name
|
||||||
// with the specified Number.
|
// with the specified Number.
|
||||||
//
|
//
|
||||||
if(!Target || Target->IsClient())
|
if(!Target || Target->IsClient() || Target->IsMerc())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((Number < 1) || (Number > MAX_MARKED_NPCS))
|
if((Number < 1) || (Number > MAX_MARKED_NPCS))
|
||||||
@ -2166,7 +2156,6 @@ int8 Group::GetNumberNeedingHealedInGroup(int8 hpr, bool includePets) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return needHealed;
|
return needHealed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2228,7 +2217,7 @@ void Group::ChangeLeader(Mob* newleader)
|
|||||||
// this changes the current group leader, notifies other members, and updates leadship AA
|
// this changes the current group leader, notifies other members, and updates leadship AA
|
||||||
|
|
||||||
// if the new leader is invalid, do nothing
|
// if the new leader is invalid, do nothing
|
||||||
if (!newleader)
|
if (!newleader || !newleader->IsClient())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mob* oldleader = GetLeader();
|
Mob* oldleader = GetLeader();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user