Core/SocialMgr: fix case when contacts appears in friend list many times

Closes #19306
This commit is contained in:
ForesterDev
2017-03-18 11:07:41 +01:00
committed by Aokromes
parent 6f7d714bef
commit 761c0faf72

View File

@@ -126,14 +126,13 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
{
ASSERT(player);
uint32 size = _playerSocialMap.size();
uint32 count = 0;
WorldPacket data(SMSG_CONTACT_LIST, (4 + 4 + size * 25)); // just can guess size
WorldPacket data(SMSG_CONTACT_LIST, (4 + 4 + _playerSocialMap.size() * 25)); // just can guess size
data << uint32(flags); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update.
data << uint32(size); // friends count
size_t countPos = data.wpos();
data << uint32(count); // friends count placeholder
for (PlayerSocialMap::value_type& v : _playerSocialMap)
for (auto& v : _playerSocialMap)
{
if (!(v.second.Flags & flags))
continue;
@@ -160,6 +159,8 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
break;
}
data.put<uint32>(countPos, count);
player->SendDirectMessage(&data);
}