[Core] Fix SMSG_WHO show players matching given criteria. (c2651)

Used to be total number of players online.

Also limit shown players to 49 which is how it used to be on retail.
This commit is contained in:
Machiavell1 2015-03-26 13:42:04 +00:00 committed by Antz
parent 4edda934a8
commit 0894ff4720

View File

@ -87,8 +87,6 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data)
DEBUG_LOG("WORLD: Received opcode CMSG_WHO");
// recv_data.hexlike();
uint32 clientcount = 0;
uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
uint32 zoneids[10]; // 10 is client limit
std::string player_name, guild_name;
@ -152,9 +150,12 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data)
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);
uint32 matchcount = 0;
uint32 displaycount = 0;
WorldPacket data(SMSG_WHO, 50); // guess size
data << uint32(clientcount); // clientcount place holder, listed count
data << uint32(clientcount); // clientcount place holder, online count
data << uint32(matchcount); // placeholder, count of players matching criteria
data << uint32(displaycount); // placeholder, count of players displayed
// TODO: Guard Player map
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
@ -252,21 +253,23 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data)
if (!s_show)
{ continue; }
// 49 is maximum player count sent to client
++matchcount;
if (matchcount > 49)
continue;
++displaycount;
data << pname; // player name
data << gname; // guild name
data << uint32(lvl); // player level
data << uint32(class_); // player class
data << uint32(race); // player race
data << uint32(pzoneid); // player zone id
// 50 is maximum player count sent to client
if ((++clientcount) == 49)
{ break; }
}
uint32 count = m.size();
data.put(0, clientcount); // insert right count, listed count
data.put(4, count > 49 ? count : clientcount); // insert right count, online count
data.put(0, displaycount); // insert right count, count displayed
data.put(4, matchcount); // insert right count, count of matches
SendPacket(&data);
DEBUG_LOG("WORLD: Send SMSG_WHO Message");