Core/Social: Separated checks for friend and ignored limits (#23181)

* Core/Conditions: implement CONDITION_GAMEMASTER

* Core/Social: Separated checks for friend and ignored limits

* Prevent duplication of contacts

* Limit values should be included in counters

* Codestyle and comments
This commit is contained in:
ForesterDev
2019-04-15 17:25:08 +04:00
committed by Giacomo Pozzoni
parent 145f7d6a74
commit 2a6eef76e2

View File

@@ -126,40 +126,50 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
{
ASSERT(player);
uint32 count = 0;
uint32 friendsCount = 0;
uint32 ignoredCount = 0;
uint32 totalCount = 0;
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(flags); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update.
size_t countPos = data.wpos();
data << uint32(count); // friends count placeholder
data << uint32(0); // contacts count placeholder
for (auto& v : _playerSocialMap)
{
if (!(v.second.Flags & flags))
uint8 contactFlags = v.second.Flags;
if (!(contactFlags & flags))
continue;
++count;
// Check client limit for friends list
if (contactFlags & SOCIAL_FLAG_FRIEND)
if (++friendsCount > SOCIALMGR_FRIEND_LIMIT)
continue;
// Check client limit for ignore list
if (contactFlags & SOCIAL_FLAG_IGNORED)
if (++ignoredCount > SOCIALMGR_IGNORE_LIMIT)
continue;
++totalCount;
sSocialMgr->GetFriendInfo(player, v.first, v.second);
data << uint64(v.first); // player guid
data << uint32(v.second.Flags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted)
data << v.second.Note; // string note
if (v.second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
data << uint64(v.first); // player guid
data << uint32(contactFlags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted)
data << v.second.Note; // string note
if (contactFlags & SOCIAL_FLAG_FRIEND) // if IsFriend()
{
data << uint8(v.second.Status); // online/offline/etc?
if (v.second.Status) // if online
data << uint8(v.second.Status); // online/offline/etc?
if (v.second.Status) // if online
{
data << uint32(v.second.Area); // player area
data << uint32(v.second.Level); // player level
data << uint32(v.second.Class); // player class
data << uint32(v.second.Area); // player area
data << uint32(v.second.Level); // player level
data << uint32(v.second.Class); // player class
}
}
// client's friends list and ignore list limit
if (count >= (((flags & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT))
break;
}
data.put<uint32>(countPos, count);
data.put<uint32>(countPos, totalCount);
player->SendDirectMessage(&data);
}