Core/Social: Fix SMSG_WHO. Packet should contain number of players matching given criteria + number of players displayed, instead of total number of players online + number of players displayed.

Fixes issue #4886

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-12-17 16:36:01 +01:00
parent 8a196ba4b0
commit 0a8c99e02c
@@ -170,7 +170,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
sLog.outDebug("WORLD: Recvd CMSG_WHO Message"); sLog.outDebug("WORLD: Recvd CMSG_WHO Message");
//recv_data.hexlike(); //recv_data.hexlike();
uint32 clientcount = 0; uint32 matchcount = 0;
uint32 level_min, level_max, racemask, classmask, zones_count, str_count; uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
uint32 zoneids[10]; // 10 is client limit uint32 zoneids[10]; // 10 is client limit
@@ -234,10 +234,11 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
uint32 security = GetSecurity(); uint32 security = GetSecurity();
bool allowTwoSideWhoList = sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST); bool allowTwoSideWhoList = sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
uint32 gmLevelInWhoList = sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST); uint32 gmLevelInWhoList = sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
uint32 displaycount = 0;
WorldPacket data(SMSG_WHO, 50); // guess size WorldPacket data(SMSG_WHO, 50); // guess size
data << uint32(clientcount); // clientcount place holder, listed count data << uint32(matchcount); // placeholder, count of players matching criteria
data << uint32(clientcount); // clientcount place holder, online count data << uint32(displaycount); // placeholder, count of players displayed
ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock()); ACE_GUARD(ACE_Thread_Mutex, g, *HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
@@ -334,6 +335,11 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
if (!s_show) if (!s_show)
continue; continue;
// 49 is maximum player count sent to client - can be overridden
// through config, but is unstable
if ((matchcount++) == sWorld.getIntConfig(CONFIG_MAX_WHO))
continue;
data << pname; // player name data << pname; // player name
data << gname; // guild name data << gname; // guild name
data << uint32(lvl); // player level data << uint32(lvl); // player level
@@ -342,15 +348,11 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
data << uint8(gender); // player gender data << uint8(gender); // player gender
data << uint32(pzoneid); // player zone id data << uint32(pzoneid); // player zone id
// 49 is maximum player count sent to client - can be overridden ++displaycount;
// through config, but is unstable
if ((++clientcount) == sWorld.getIntConfig(CONFIG_MAX_WHO))
break;
} }
uint32 count = m.size(); data.put(0, matchcount); // insert right count, count of matches
data.put( 0, clientcount ); // insert right count, listed count data.put(4, displaycount); // insert right count, count displayed
data.put( 4, count > 50 ? count : clientcount ); // insert right count, online count
SendPacket(&data); SendPacket(&data);
sLog.outDebug("WORLD: Send SMSG_WHO Message"); sLog.outDebug("WORLD: Send SMSG_WHO Message");