void ClientList::SendFriendsWho(ServerFriendsWho_Struct *FriendsWho, WorldTCPConnection* connection) { std::vector<ClientListEntry*> FriendsCLEs; FriendsCLEs.reserve(100); char Friend_[65]; char *FriendsPointer = FriendsWho->FriendsString; // FriendsString is a comma delimited list of names. char *Seperator = nullptr; Seperator = strchr(FriendsPointer, ','); if(!Seperator) Seperator = strchr(FriendsPointer, '\0'); uint32 TotalLength=0; while(Seperator != nullptr) { if((Seperator - FriendsPointer) > 64) return; strncpy(Friend_, FriendsPointer, Seperator - FriendsPointer); Friend_[Seperator - FriendsPointer] = 0; ClientListEntry* CLE = FindCharacter(Friend_); if(CLE && CLE->name() && (CLE->Online() >= CLE_Status_Zoning) && !(CLE->GetGM() && CLE->Anon())) { FriendsCLEs.push_back(CLE); TotalLength += strlen(CLE->name()); int GuildNameLength = strlen(guild_mgr.GetGuildName(CLE->GuildID())); if(GuildNameLength>0) TotalLength += (GuildNameLength + 2); } if(Seperator[0] == '\0') break; FriendsPointer = Seperator + 1; Seperator = strchr(FriendsPointer, ','); if(!Seperator) Seperator = strchr(FriendsPointer, '\0'); } try{ ClientListEntry* cle; int FriendsOnline = FriendsCLEs.size(); int PacketLength = sizeof(WhoAllReturnStruct) + (47 * FriendsOnline) + TotalLength; ServerPacket* pack2 = new ServerPacket(ServerOP_WhoAllReply, PacketLength); memset(pack2->pBuffer,0,pack2->size); uchar *buffer=pack2->pBuffer; uchar *bufptr=buffer; WhoAllReturnStruct *WARS = (WhoAllReturnStruct *)bufptr; WARS->id = FriendsWho->FromID; WARS->playerineqstring = 0xffff; strcpy(WARS->line, ""); WARS->unknown35 = 0x0a; WARS->unknown36 = 0x00; if(FriendsCLEs.size() == 1) WARS->playersinzonestring = 5028; // 5028 There is %1 player in EverQuest. else WARS->playersinzonestring = 5036; // 5036 There are %1 players in EverQuest. WARS->unknown44[0] = 0; WARS->unknown44[1] = 0; WARS->unknown44[2] = 0; WARS->unknown44[3] = 0; WARS->unknown44[4] = 0; WARS->unknown52 = FriendsOnline; WARS->unknown56 = 1; WARS->playercount = FriendsOnline; bufptr+=sizeof(WhoAllReturnStruct); for(int CLEEntry = 0; CLEEntry < FriendsOnline; CLEEntry++) { cle = FriendsCLEs[CLEEntry]; char GuildName[67]={0}; if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0) sprintf(GuildName,"<%s>", guild_mgr.GetGuildName(cle->GuildID())); uint16 FormatMSGID=5025; // 5025 %T1[%2 %3] %4 (%5) %6 %7 %8 %9 if(cle->Anon()==1) FormatMSGID=5024; // 5024 %T1[ANONYMOUS] %2 %3 else if(cle->Anon()==2) FormatMSGID=5023; // 5023 %T1[ANONYMOUS] %2 %3 %4 uint16 PlayerClass=0; uint16 PlayerLevel=0; uint16 PlayerRace=0; uint16 ZoneMSGID=0xffff; uint16 PlayerZone=0; if(cle->Anon()==0) { PlayerClass=cle->class_(); PlayerLevel=cle->level(); PlayerRace=cle->race(); ZoneMSGID=5006; // 5006 ZONE: %1 PlayerZone=cle->zone(); } char PlayerName[64]={0}; strcpy(PlayerName,cle->name()); WhoAllPlayerPart1* WAPP1 = (WhoAllPlayerPart1*)bufptr; WAPP1->FormatMSGID = FormatMSGID; WAPP1->PIDMSGID = 0xffff; strcpy(WAPP1->Name, PlayerName); bufptr += sizeof(WhoAllPlayerPart1) + strlen(PlayerName); WhoAllPlayerPart2* WAPP2 = (WhoAllPlayerPart2*)bufptr; WAPP2->RankMSGID = 0xffff; strcpy(WAPP2->Guild, GuildName); bufptr += sizeof(WhoAllPlayerPart2) + strlen(GuildName); WhoAllPlayerPart3* WAPP3 = (WhoAllPlayerPart3*)bufptr; WAPP3->Unknown80[0] = 0xffff; WAPP3->Unknown80[1] = 0xffff; WAPP3->Unknown80[2] = 0xffff; WAPP3->ZoneMSGID = ZoneMSGID; WAPP3->Zone = PlayerZone; WAPP3->Class_ = PlayerClass; WAPP3->Level = PlayerLevel; WAPP3->Race = PlayerRace; WAPP3->Account[0] = 0; bufptr += sizeof(WhoAllPlayerPart3); WhoAllPlayerPart4* WAPP4 = (WhoAllPlayerPart4*)bufptr; WAPP4->Unknown100 = 211; bufptr += sizeof(WhoAllPlayerPart4); } pack2->Deflate(); SendPacket(FriendsWho->FromName,pack2); safe_delete(pack2); } catch(...){ _log(WORLD__ZONELIST_ERR,"Unknown error in world's SendFriendsWho (probably mem error), ignoring..."); return; } }
void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) { LinkedListIterator<ClientListEntry*> iterator(clientlist); ClientListEntry* cle = 0; char tmpgm[25] = ""; char accinfo[150] = ""; char line[300] = ""; char tmpguild[50] = ""; char LFG[10] = ""; uint32 x = 0; int whomlen = 0; if (whom) whomlen = strlen(whom->whom); char* output = 0; uint32 outsize = 0, outlen = 0; AppendAnyLenString(&output, &outsize, &outlen, "Players on server:"); if (connection->IsConsole()) AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else AppendAnyLenString(&output, &outsize, &outlen, "\n"); iterator.Reset(); while(iterator.MoreElements()) { cle = iterator.GetData(); const char* tmpZone = database.GetZoneName(cle->zone()); if ( (cle->Online() >= CLE_Status_Zoning) && (whom == 0 || ( ((cle->Admin() >= 80 && cle->GetGM()) || whom->gmlookup == 0xFFFF) && (whom->lvllow == 0xFFFF || (cle->level() >= whom->lvllow && cle->level() <= whom->lvlhigh)) && (whom->wclass == 0xFFFF || cle->class_() == whom->wclass) && (whom->wrace == 0xFFFF || cle->race() == whom->wrace) && (whomlen == 0 || ( (tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) || strncasecmp(cle->name(),whom->whom, whomlen) == 0 || (strncasecmp(guild_mgr.GetGuildName(cle->GuildID()), whom->whom, whomlen) == 0) || (admin >= 100 && strncasecmp(cle->AccountName(), whom->whom, whomlen) == 0) )) )) ) { line[0] = 0; // MYRA - use new (5.x) Status labels in who for telnet connection if (cle->Admin() >=250) strcpy(tmpgm, "* GM-Impossible * "); else if (cle->Admin() >= 200) strcpy(tmpgm, "* GM-Mgmt * "); else if (cle->Admin() >= 180) strcpy(tmpgm, "* GM-Coder * "); else if (cle->Admin() >= 170) strcpy(tmpgm, "* GM-Areas * "); else if (cle->Admin() >= 160) strcpy(tmpgm, "* QuestMaster * "); else if (cle->Admin() >= 150) strcpy(tmpgm, "* GM-Lead Admin * "); else if (cle->Admin() >= 100) strcpy(tmpgm, "* GM-Admin * "); else if (cle->Admin() >= 95) strcpy(tmpgm, "* GM-Staff * "); else if (cle->Admin() >= 90) strcpy(tmpgm, "* EQ Support * "); else if (cle->Admin() >= 85) strcpy(tmpgm, "* GM-Tester * "); else if (cle->Admin() >= 81) strcpy(tmpgm, "* Senior Guide * "); else if (cle->Admin() >= 80) strcpy(tmpgm, "* QuestTroupe * "); else if (cle->Admin() >= 50) strcpy(tmpgm, "* Guide * "); else if (cle->Admin() >= 20) strcpy(tmpgm, "* Apprentice Guide * "); else if (cle->Admin() >= 10) strcpy(tmpgm, "* Steward * "); else tmpgm[0] = 0; // end Myra if (guild_mgr.GuildExists(cle->GuildID())) { snprintf(tmpguild, 36, " <%s>", guild_mgr.GetGuildName(cle->GuildID())); } else tmpguild[0] = 0; if (cle->LFG()) strcpy(LFG, " LFG"); else LFG[0] = 0; if (admin >= 150 && admin >= cle->Admin()) { sprintf(accinfo, " AccID: %i AccName: %s LSID: %i Status: %i", cle->AccountID(), cle->AccountName(), cle->LSAccountID(), cle->Admin()); } else accinfo[0] = 0; if (cle->Anon() == 2) { // Roleplay if (admin >= 100 && admin >= cle->Admin()) sprintf(line, " %s[RolePlay %i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo); else if (cle->Admin() >= 80 && admin < 80 && cle->GetGM()) { iterator.Advance(); continue; } else sprintf(line, " %s[ANONYMOUS] %s%s%s%s", tmpgm, cle->name(), tmpguild, LFG, accinfo); } else if (cle->Anon() == 1) { // Anon if (admin >= 100 && admin >= cle->Admin()) sprintf(line, " %s[ANON %i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo); else if (cle->Admin() >= 80 && cle->GetGM()) { iterator.Advance(); continue; } else sprintf(line, " %s[ANONYMOUS] %s%s%s", tmpgm, cle->name(), LFG, accinfo); } else sprintf(line, " %s[%i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo); AppendAnyLenString(&output, &outsize, &outlen, line); if (outlen >= 3584) { connection->SendEmoteMessageRaw(to, 0, 0, 10, output); safe_delete(output); outsize = 0; outlen = 0; } else { if (connection->IsConsole()) AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else AppendAnyLenString(&output, &outsize, &outlen, "\n"); } x++; if (x >= 20 && admin < 80) break; } iterator.Advance(); } if (x >= 20 && admin < 80) AppendAnyLenString(&output, &outsize, &outlen, "too many results...20 players shown"); else AppendAnyLenString(&output, &outsize, &outlen, "%i players online", x); if (admin >= 150 && (whom == 0 || whom->gmlookup != 0xFFFF)) { if (connection->IsConsole()) AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else AppendAnyLenString(&output, &outsize, &outlen, "\n"); console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen); } if (output) connection->SendEmoteMessageRaw(to, 0, 0, 10, output); safe_delete(output); }
void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) { try{ LinkedListIterator<ClientListEntry*> iterator(clientlist); LinkedListIterator<ClientListEntry*> countclients(clientlist); ClientListEntry* cle = 0; ClientListEntry* countcle = 0; //char tmpgm[25] = ""; //char accinfo[150] = ""; char line[300] = ""; //char tmpguild[50] = ""; //char LFG[10] = ""; //uint32 x = 0; int whomlen = 0; if (whom) { whomlen = strlen(whom->whom); if(whom->wrace == 0x1A) // 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. } char* output = 0; uint32 outsize = 0, outlen = 0; uint16 totalusers=0; uint16 totallength=0; AppendAnyLenString(&output, &outsize, &outlen, "Players on server:"); if (connection->IsConsole()) AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); else AppendAnyLenString(&output, &outsize, &outlen, "\n"); countclients.Reset(); while(countclients.MoreElements()){ countcle = countclients.GetData(); const char* tmpZone = database.GetZoneName(countcle->zone()); if ( (countcle->Online() >= CLE_Status_Zoning) && (!countcle->GetGM() || countcle->Anon() != 1 || admin >= countcle->Admin()) && (whom == 0 || ( ((countcle->Admin() >= 80 && countcle->GetGM()) || whom->gmlookup == 0xFFFF) && (whom->lvllow == 0xFFFF || (countcle->level() >= whom->lvllow && countcle->level() <= whom->lvlhigh && (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 || ( (tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) || strncasecmp(countcle->name(),whom->whom, whomlen) == 0 || (strncasecmp(guild_mgr.GetGuildName(countcle->GuildID()), whom->whom, whomlen) == 0) || (admin >= 100 && strncasecmp(countcle->AccountName(), whom->whom, whomlen) == 0) )) )) ) { if((countcle->Anon()>0 && admin>=countcle->Admin() && admin>0) || countcle->Anon()==0 ){ totalusers++; if(totalusers<=20 || admin>=100) 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()){ totalusers++; if(totalusers<=20 || admin>=100) totallength=totallength+strlen(countcle->name())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5; } } countclients.Advance(); } uint16 plid=fromid; uint16 playerineqstring=5001; const char line2[]="---------------------------"; uint8 unknown35=0x0A; uint16 unknown36=0; uint16 playersinzonestring=5028; if(totalusers>20 && admin<100){ totalusers=20; playersinzonestring=5033; } else if(totalusers>1) playersinzonestring=5036; uint16 unknown44[5]; unknown44[0]=0; unknown44[1]=0; unknown44[2]=0; unknown44[3]=0; unknown44[4]=0; uint32 unknown52=totalusers; uint32 unknown56=1; ServerPacket* pack2 = new ServerPacket(ServerOP_WhoAllReply,58+totallength+(30*totalusers)); memset(pack2->pBuffer,0,pack2->size); uchar *buffer=pack2->pBuffer; uchar *bufptr=buffer; //memset(buffer,0,pack2->size); memcpy(bufptr,&plid, sizeof(uint32)); bufptr+=sizeof(uint32); memcpy(bufptr,&playerineqstring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&line2, strlen(line2)); bufptr+=strlen(line2); memcpy(bufptr,&unknown35, sizeof(uint8)); bufptr+=sizeof(uint8); memcpy(bufptr,&unknown36, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&playersinzonestring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown44[0], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown44[1], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown44[2], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown44[3], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown44[4], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown52, sizeof(uint32)); bufptr+=sizeof(uint32); memcpy(bufptr,&unknown56, sizeof(uint32)); bufptr+=sizeof(uint32); memcpy(bufptr,&totalusers, sizeof(uint16)); bufptr+=sizeof(uint16); iterator.Reset(); int idx=-1; while(iterator.MoreElements()) { cle = iterator.GetData(); const char* tmpZone = database.GetZoneName(cle->zone()); if ( (cle->Online() >= CLE_Status_Zoning) && (!cle->GetGM() || cle->Anon() != 1 || admin >= cle->Admin()) && (whom == 0 || ( ((cle->Admin() >= 80 && cle->GetGM()) || whom->gmlookup == 0xFFFF) && (whom->lvllow == 0xFFFF || (cle->level() >= whom->lvllow && cle->level() <= whom->lvlhigh && (cle->Anon()==0 || admin>cle->Admin()))) && (whom->wclass == 0xFFFF || (cle->class_() == whom->wclass && (cle->Anon()==0 || admin>cle->Admin()))) && (whom->wrace == 0xFFFF || (cle->race() == whom->wrace && (cle->Anon()==0 || admin>cle->Admin()))) && (whomlen == 0 || ( (tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) || strncasecmp(cle->name(),whom->whom, whomlen) == 0 || (strncasecmp(guild_mgr.GetGuildName(cle->GuildID()), whom->whom, whomlen) == 0) || (admin >= 100 && strncasecmp(cle->AccountName(), whom->whom, whomlen) == 0) )) )) ) { line[0] = 0; uint16 rankstring=0xFFFF; if((cle->Anon()==1 && cle->GetGM() && cle->Admin()>admin) || (idx>=20 && admin<100)){ //hide gms that are anon from lesser gms and normal players, cut off at 20 rankstring=0; iterator.Advance(); continue; } else if (cle->GetGM()) { if (cle->Admin() >=250) rankstring=5021; else if (cle->Admin() >= 200) rankstring=5020; else if (cle->Admin() >= 180) rankstring=5019; else if (cle->Admin() >= 170) rankstring=5018; else if (cle->Admin() >= 160) rankstring=5017; else if (cle->Admin() >= 150) rankstring=5016; else if (cle->Admin() >= 100) rankstring=5015; else if (cle->Admin() >= 95) rankstring=5014; else if (cle->Admin() >= 90) rankstring=5013; else if (cle->Admin() >= 85) rankstring=5012; else if (cle->Admin() >= 81) rankstring=5011; else if (cle->Admin() >= 80) rankstring=5010; else if (cle->Admin() >= 50) rankstring=5009; else if (cle->Admin() >= 20) rankstring=5008; else if (cle->Admin() >= 10) rankstring=5007; } idx++; char guildbuffer[67]={0}; if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0) sprintf(guildbuffer,"<%s>", guild_mgr.GetGuildName(cle->GuildID())); uint16 formatstring=5025; if(cle->Anon()==1 && (admin<cle->Admin() || admin==0)) formatstring=5024; else if(cle->Anon()==1 && admin>=cle->Admin() && admin>0) formatstring=5022; else if(cle->Anon()==2 && (admin<cle->Admin() || admin==0)) formatstring=5023;//display guild else if(cle->Anon()==2 && admin>=cle->Admin() && admin>0) formatstring=5022;//display everything //war* wars2 = (war*)pack2->pBuffer; uint16 plclass_=0; uint16 pllevel=0; uint16 pidstring=0xFFFF;//5003; uint16 plrace=0; uint16 zonestring=0xFFFF; uint32 plzone=0; uint16 unknown80[3]; if(cle->Anon()==0 || (admin>=cle->Admin() && admin>0)){ plclass_=cle->class_(); pllevel=cle->level(); if(admin>=100) pidstring=5003; plrace=cle->race(); zonestring=5006; plzone=cle->zone(); } if(admin>=cle->Admin() && admin>0) unknown80[0]=cle->Admin(); else unknown80[0]=0xFFFF; unknown80[1]=0xFFFF;//1035 unknown80[2]=0xFFFF; //char plstatus[20]={0}; //sprintf(plstatus, "Status %i",cle->Admin()); char plname[64]={0}; strcpy(plname,cle->name()); char placcount[30]={0}; if(admin>=cle->Admin() && admin>0) strcpy(placcount,cle->AccountName()); memcpy(bufptr,&formatstring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&pidstring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&plname, strlen(plname)+1); bufptr+=strlen(plname)+1; memcpy(bufptr,&rankstring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&guildbuffer, strlen(guildbuffer)+1); bufptr+=strlen(guildbuffer)+1; memcpy(bufptr,&unknown80[0], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown80[1], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&unknown80[2], sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&zonestring, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&plzone, sizeof(uint32)); bufptr+=sizeof(uint32); memcpy(bufptr,&plclass_, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&pllevel, sizeof(uint16)); bufptr+=sizeof(uint16); memcpy(bufptr,&plrace, sizeof(uint16)); bufptr+=sizeof(uint16); uint16 ending=0; memcpy(bufptr,&placcount, strlen(placcount)+1); bufptr+=strlen(placcount)+1; ending=211; memcpy(bufptr,&ending, sizeof(uint16)); bufptr+=sizeof(uint16); } iterator.Advance(); } pack2->Deflate(); //zoneserver_list.SendPacket(pack2); // NO NO NO WHY WOULD YOU SEND IT TO EVERY ZONE SERVER?!? SendPacket(to,pack2); safe_delete(pack2); safe_delete(output); } catch(...){ _log(WORLD__ZONELIST_ERR,"Unknown error in world's SendWhoAll (probably mem error), ignoring... Player id is: %i, Name is: %s", fromid, to); return; } }