[Bug] Anon players should not show in /who all (#4392)

Updated to properly filter anon players from /who all.

The code formatting was very inconsistant and needed cleanup.
This commit is contained in:
Fryguy 2024-06-14 13:39:41 -04:00 committed by GitHub
parent ae213a4e4b
commit 7362c0ebb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -528,7 +528,6 @@ void ClientList::SendOnlineGuildMembers(uint32 FromID, uint32 GuildID)
safe_delete(pack); safe_delete(pack);
} }
void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) { void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) {
try { try {
LinkedListIterator<ClientListEntry*> iterator(clientlist); LinkedListIterator<ClientListEntry*> iterator(clientlist);
@ -542,33 +541,40 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
//char LFG[10] = ""; //char LFG[10] = "";
//uint32 x = 0; //uint32 x = 0;
int whomlen = 0; int whomlen = 0;
if (whom) { if (whom) {
// fixes for client converting some queries into a race query instead of zone // fixes for client converting some queries into a race query instead of zone
if (whom->wrace == 221) { if (whom->wrace == 221) {
whom->wrace = 0xFFFF; whom->wrace = 0xFFFF;
strcpy(whom->whom, "scarlet"); strcpy(whom->whom, "scarlet");
} }
if (whom->wrace == 327) { if (whom->wrace == 327) {
whom->wrace = 0xFFFF; whom->wrace = 0xFFFF;
strcpy(whom->whom, "crystal"); strcpy(whom->whom, "crystal");
} }
if (whom->wrace == 103) { if (whom->wrace == 103) {
whom->wrace = 0xFFFF; whom->wrace = 0xFFFF;
strcpy(whom->whom, "kedge"); strcpy(whom->whom, "kedge");
} }
if (whom->wrace == 230) { if (whom->wrace == 230) {
whom->wrace = 0xFFFF; whom->wrace = 0xFFFF;
strcpy(whom->whom, "akheva"); strcpy(whom->whom, "akheva");
} }
if (whom->wrace == 229) { if (whom->wrace == 229) {
whom->wrace = 0xFFFF; whom->wrace = 0xFFFF;
strcpy(whom->whom, "netherbian"); strcpy(whom->whom, "netherbian");
} }
whomlen = strlen(whom->whom); whomlen = strlen(whom->whom);
if(whom->wrace == 0x001A) // 0x001A is the old Froglok race number and is sent by the client for /who all froglok
if (whom->wrace == 0x001A) { // 0x001A is the old Froglok race number and is sent by the client for /who all froglok
whom->wrace = FROGLOK; // This is what EQEmu uses for the Froglok Race number. whom->wrace = FROGLOK; // This is what EQEmu uses for the Froglok Race number.
} }
}
uint32 totalusers=0; uint32 totalusers=0;
uint32 totallength=0; uint32 totallength=0;
@ -581,9 +587,13 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
(!countcle->GetGM() || countcle->Anon() != 1 || admin >= countcle->Admin()) && (!countcle->GetGM() || countcle->Anon() != 1 || admin >= countcle->Admin()) &&
(whom == 0 || ( (whom == 0 || (
((countcle->Admin() >= AccountStatus::QuestTroupe && countcle->GetGM()) || whom->gmlookup == 0xFFFF) && ((countcle->Admin() >= AccountStatus::QuestTroupe && countcle->GetGM()) || whom->gmlookup == 0xFFFF) &&
(whom->lvllow == 0xFFFF || (countcle->level() >= whom->lvllow && countcle->level() <= whom->lvlhigh && (countcle->Anon()==0 || admin > countcle->Admin()))) && (whom->lvllow == 0xFFFF ||
(whom->wclass == 0xFFFF || (countcle->class_() == whom->wclass && (countcle->Anon()==0 || admin > countcle->Admin()))) && (countcle->level() >= whom->lvllow && countcle->level() <= whom->lvlhigh &&
(whom->wrace == 0xFFFF || (countcle->race() == whom->wrace && (countcle->Anon()==0 || admin > countcle->Admin()))) && (countcle->Anon() == 0 || admin > countcle->Admin()))) &&
(whom->wclass == 0xFFFF || (countcle->class_() == whom->wclass &&
(countcle->Anon() == 0 || admin > countcle->Admin()))) &&
(whom->wrace == 0xFFFF ||
(countcle->race() == whom->wrace && (countcle->Anon() == 0 || admin > countcle->Admin()))) &&
(whomlen == 0 || ( (whomlen == 0 || (
(tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) || (tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) ||
strncasecmp(countcle->name(),whom->whom, whomlen) == 0 || strncasecmp(countcle->name(),whom->whom, whomlen) == 0 ||
@ -592,31 +602,47 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
)) ))
)) ))
) { ) {
// these blocks can all be condensed but it's simpler to conceptualize this way
if ((countcle->Anon()>0 && admin >= countcle->Admin() && admin > AccountStatus::Player) || countcle->Anon()==0 ) { if ((countcle->Anon()>0 && admin >= countcle->Admin() && admin > AccountStatus::Player) || countcle->Anon()==0 ) {
totalusers++; totalusers++;
if(totalusers<=20 || admin >= AccountStatus::GMAdmin) if (totalusers<=20 || admin >= AccountStatus::GMAdmin) {
totallength=totallength+strlen(countcle->name())+strlen(countcle->AccountName())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5; totallength = totallength + strlen(countcle->name()) + strlen(countcle->AccountName()) +
strlen(guild_mgr.GetGuildName(countcle->GuildID())) + 5;
} }
else if((countcle->Anon()>0 && admin<=countcle->Admin()) || (countcle->Anon()==0 && !countcle->GetGM())) { } else if (((countcle->Anon() == 1 && admin <= countcle->Admin()) && whomlen != 0 &&
strncasecmp(countcle->name(), whom->whom, whomlen) == 0)) {
totalusers++; totalusers++;
if(totalusers<=20 || admin >= AccountStatus::GMAdmin) if (totalusers <= 20 || admin >= AccountStatus::GMAdmin) {
totallength=totallength+strlen(countcle->name())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5; totallength = totallength + strlen(countcle->name()) + strlen(countcle->AccountName()) +
strlen(guild_mgr.GetGuildName(countcle->GuildID())) + 5;
}
} else if (((countcle->Anon() == 2 && admin <= countcle->Admin()) && whomlen != 0 &&
(strncasecmp(countcle->name(), whom->whom, whomlen) == 0 ||
strncasecmp(guild_mgr.GetGuildName(countcle->GuildID()), whom->whom, whomlen) == 0))) {
totalusers++;
if (totalusers <= 20 || admin >= AccountStatus::GMAdmin) {
totallength = totallength + strlen(countcle->name()) + strlen(countcle->AccountName()) +
strlen(guild_mgr.GetGuildName(countcle->GuildID())) + 5;
}
} }
} }
countclients.Advance(); countclients.Advance();
} }
uint32 plid=fromid; uint32 plid=fromid;
uint32 playerineqstring=5001; uint32 playerineqstring=5001;
const char line2[]="---------------------------"; const char line2[]="---------------------------";
uint8 unknown35=0x0A; uint8 unknown35=0x0A;
uint32 unknown36=0; uint32 unknown36=0;
uint32 playersinzonestring=5028; uint32 playersinzonestring=5028;
if (totalusers>20 && admin<AccountStatus::GMAdmin) { if (totalusers>20 && admin<AccountStatus::GMAdmin) {
totalusers=20; totalusers=20;
playersinzonestring=5033; playersinzonestring=5033;
} } else if(totalusers>1) {
else if(totalusers>1)
playersinzonestring=5036; playersinzonestring=5036;
}
uint32 unknown44[2]; uint32 unknown44[2];
unknown44[0]=0; unknown44[0]=0;
unknown44[1]=0; unknown44[1]=0;
@ -674,55 +700,71 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
) { ) {
line[0] = 0; line[0] = 0;
uint32 rankstring = 0xFFFFFFFF; uint32 rankstring = 0xFFFFFFFF;
// These lines can be simplified but easier to conceptualize this way
if ((cle->Anon()==1 && cle->GetGM() && cle->Admin()>admin) || (idx>=20 && admin < AccountStatus::GMAdmin)) { //hide gms that are anon from lesser gms and normal players, cut off at 20 if ((cle->Anon()==1 && cle->GetGM() && cle->Admin()>admin) || (idx>=20 && admin < AccountStatus::GMAdmin)) { //hide gms that are anon from lesser gms and normal players, cut off at 20
rankstring = 0; rankstring = 0;
iterator.Advance(); iterator.Advance();
continue; continue;
} else if (cle->Anon() == 1 && cle->Admin()>=admin && (whomlen == 0 || (whomlen !=0 && strncasecmp(cle->name(), whom->whom, whomlen) != 0))) {
rankstring = 0;
iterator.Advance();
continue;
} else if (cle->Anon() == 2 && cle->Admin()>=admin && (whomlen == 0 || (whomlen !=0 && strncasecmp(cle->name(), whom->whom, whomlen) != 0 && strncasecmp(guild_mgr.GetGuildName(cle->GuildID()), whom->whom, whomlen) != 0))) {
rankstring = 0;
iterator.Advance();
continue;
} else if (cle->GetGM()) { } else if (cle->GetGM()) {
if (cle->Admin() >= AccountStatus::GMImpossible) if (cle->Admin() >= AccountStatus::GMImpossible) {
rankstring = 5021; rankstring = 5021;
else if (cle->Admin() >= AccountStatus::GMMgmt) } else if (cle->Admin() >= AccountStatus::GMMgmt) {
rankstring = 5020; rankstring = 5020;
else if (cle->Admin() >= AccountStatus::GMCoder) } else if (cle->Admin() >= AccountStatus::GMCoder) {
rankstring = 5019; rankstring = 5019;
else if (cle->Admin() >= AccountStatus::GMAreas) } else if (cle->Admin() >= AccountStatus::GMAreas) {
rankstring = 5018; rankstring = 5018;
else if (cle->Admin() >= AccountStatus::QuestMaster) } else if (cle->Admin() >= AccountStatus::QuestMaster) {
rankstring = 5017; rankstring = 5017;
else if (cle->Admin() >= AccountStatus::GMLeadAdmin) } else if (cle->Admin() >= AccountStatus::GMLeadAdmin) {
rankstring = 5016; rankstring = 5016;
else if (cle->Admin() >= AccountStatus::GMAdmin) } else if (cle->Admin() >= AccountStatus::GMAdmin) {
rankstring = 5015; rankstring = 5015;
else if (cle->Admin() >= AccountStatus::GMStaff) } else if (cle->Admin() >= AccountStatus::GMStaff) {
rankstring = 5014; rankstring = 5014;
else if (cle->Admin() >= AccountStatus::EQSupport) } else if (cle->Admin() >= AccountStatus::EQSupport) {
rankstring = 5013; rankstring = 5013;
else if (cle->Admin() >= AccountStatus::GMTester) } else if (cle->Admin() >= AccountStatus::GMTester) {
rankstring = 5012; rankstring = 5012;
else if (cle->Admin() >= AccountStatus::SeniorGuide) } else if (cle->Admin() >= AccountStatus::SeniorGuide) {
rankstring = 5011; rankstring = 5011;
else if (cle->Admin() >= AccountStatus::QuestTroupe) } else if (cle->Admin() >= AccountStatus::QuestTroupe) {
rankstring = 5010; rankstring = 5010;
else if (cle->Admin() >= AccountStatus::Guide) } else if (cle->Admin() >= AccountStatus::Guide) {
rankstring = 5009; rankstring = 5009;
else if (cle->Admin() >= AccountStatus::ApprenticeGuide) } else if (cle->Admin() >= AccountStatus::ApprenticeGuide) {
rankstring = 5008; rankstring = 5008;
else if (cle->Admin() >= AccountStatus::Steward) } else if (cle->Admin() >= AccountStatus::Steward) {
rankstring = 5007; rankstring = 5007;
} }
}
idx++; idx++;
char guildbuffer[67]={0}; char guildbuffer[67]={0};
if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0)
if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0) {
sprintf(guildbuffer,"<%s>", guild_mgr.GetGuildName(cle->GuildID())); sprintf(guildbuffer,"<%s>", guild_mgr.GetGuildName(cle->GuildID()));
}
uint32 formatstring=5025; uint32 formatstring=5025;
if(cle->Anon()==1 && (admin<cle->Admin() || admin == AccountStatus::Player))
if (cle->Anon()==1 && (admin<cle->Admin() || admin == AccountStatus::Player)) {
formatstring=5024; formatstring=5024;
else if(cle->Anon()==1 && admin>=cle->Admin() && admin > AccountStatus::Player) } else if(cle->Anon()==1 && admin>=cle->Admin() && admin > AccountStatus::Player) {
formatstring=5022; formatstring=5022;
else if(cle->Anon()==2 && (admin<cle->Admin() || admin == AccountStatus::Player)) } else if(cle->Anon()==2 && (admin<cle->Admin() || admin == AccountStatus::Player)) {
formatstring=5023;//display guild formatstring=5023;//display guild
else if(cle->Anon()==2 && admin>=cle->Admin() && admin > AccountStatus::Player) } else if(cle->Anon()==2 && admin>=cle->Admin() && admin > AccountStatus::Player) {
formatstring=5022;//display everything formatstring=5022;//display everything
}
//war* wars2 = (war*)pack2->pBuffer; //war* wars2 = (war*)pack2->pBuffer;
@ -733,23 +775,26 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
uint32 zonestring=0xFFFFFFFF; uint32 zonestring=0xFFFFFFFF;
uint32 plzone=0; uint32 plzone=0;
uint32 unknown80[2]; uint32 unknown80[2];
if (cle->Anon()==0 || (admin>=cle->Admin() && admin> AccountStatus::Player)) { if (cle->Anon()==0 || (admin>=cle->Admin() && admin> AccountStatus::Player)) {
plclass_=cle->class_(); plclass_=cle->class_();
pllevel=cle->level(); pllevel=cle->level();
if(admin>=AccountStatus::GMAdmin)
if(admin>=AccountStatus::GMAdmin) {
pidstring=5003; pidstring=5003;
}
plrace=cle->race(); plrace=cle->race();
zonestring=5006; zonestring=5006;
plzone=cle->zone(); plzone=cle->zone();
} }
if (admin>=cle->Admin() && admin > AccountStatus::Player) {
if(admin>=cle->Admin() && admin > AccountStatus::Player)
unknown80[0]=cle->Admin(); unknown80[0]=cle->Admin();
else } else {
unknown80[0]=0xFFFFFFFF; unknown80[0]=0xFFFFFFFF;
unknown80[1]=0xFFFFFFFF;//1035 }
unknown80[1]=0xFFFFFFFF;//1035
//char plstatus[20]={0}; //char plstatus[20]={0};
//sprintf(plstatus, "Status %i",cle->Admin()); //sprintf(plstatus, "Status %i",cle->Admin());
@ -757,8 +802,9 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
strcpy(plname,cle->name()); strcpy(plname,cle->name());
char placcount[30]={0}; char placcount[30]={0};
if(admin>=cle->Admin() && admin > AccountStatus::Player) if (admin>=cle->Admin() && admin > AccountStatus::Player) {
strcpy(placcount,cle->AccountName()); strcpy(placcount,cle->AccountName());
}
memcpy(bufptr,&formatstring, sizeof(uint32)); memcpy(bufptr,&formatstring, sizeof(uint32));
bufptr+=sizeof(uint32); bufptr+=sizeof(uint32);
@ -793,11 +839,10 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S
} }
iterator.Advance(); iterator.Advance();
} }
//zoneserver_list.SendPacket(pack2); // NO NO NO WHY WOULD YOU SEND IT TO EVERY ZONE SERVER?!?
SendPacket(to,pack2); SendPacket(to,pack2);
safe_delete(pack2); safe_delete(pack2);
} } catch(...) {
catch(...){
LogInfo("Unknown error in world's SendWhoAll (probably mem error), ignoring"); LogInfo("Unknown error in world's SendWhoAll (probably mem error), ignoring");
return; return;
} }