2010-10-07 15:35:36 +02:00
|
|
|
/*
|
2011-01-01 15:01:13 +01:00
|
|
|
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:35:36 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-11 14:16:25 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
#include "SocialMgr.h"
|
2010-06-25 00:18:01 +02:00
|
|
|
|
2010-06-08 16:13:55 -06:00
|
|
|
#include "DatabaseEnv.h"
|
2008-10-11 14:16:25 -05:00
|
|
|
#include "Opcodes.h"
|
|
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "Player.h"
|
|
|
|
|
#include "ObjectMgr.h"
|
|
|
|
|
#include "World.h"
|
|
|
|
|
#include "Util.h"
|
2011-09-08 15:11:55 +02:00
|
|
|
#include "AccountMgr.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
PlayerSocial::PlayerSocial()
|
|
|
|
|
{
|
|
|
|
|
m_playerGUID = 0;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
PlayerSocial::~PlayerSocial()
|
|
|
|
|
{
|
|
|
|
|
m_playerSocialMap.clear();
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-31 11:04:32 -05:00
|
|
|
uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
|
|
|
|
|
{
|
|
|
|
|
uint32 counter = 0;
|
2009-10-17 16:20:24 -07:00
|
|
|
for (PlayerSocialMap::const_iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr->second.Flags & flag)
|
2009-04-29 00:26:07 -05:00
|
|
|
++counter;
|
2009-11-01 23:01:26 -08:00
|
|
|
|
2008-10-31 11:04:32 -05:00
|
|
|
return counter;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-12-31 00:32:05 +01:00
|
|
|
bool PlayerSocial::AddToSocialList(uint32 friendGuid, bool ignore)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2008-10-31 11:04:32 -05:00
|
|
|
// check client limits
|
2009-11-01 23:01:26 -08:00
|
|
|
if (ignore)
|
2008-10-31 11:04:32 -05:00
|
|
|
{
|
2009-11-01 23:01:26 -08:00
|
|
|
if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT)
|
2008-10-31 11:04:32 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-11-01 23:01:26 -08:00
|
|
|
if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT)
|
2008-10-31 11:04:32 -05:00
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
uint32 flag = SOCIAL_FLAG_FRIEND;
|
2010-04-07 19:14:10 +02:00
|
|
|
if (ignore)
|
2008-10-11 14:16:25 -05:00
|
|
|
flag = SOCIAL_FLAG_IGNORED;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-12-31 00:32:05 +01:00
|
|
|
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (itr != m_playerSocialMap.end())
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-12-31 00:32:05 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS);
|
|
|
|
|
|
|
|
|
|
stmt->setUInt8(0, uint8(flag));
|
|
|
|
|
stmt->setUInt32(1, GetPlayerGUID());
|
|
|
|
|
stmt->setUInt32(2, friendGuid);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
|
|
|
|
|
m_playerSocialMap[friendGuid].Flags |= flag;
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-12-31 00:32:05 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);
|
|
|
|
|
|
|
|
|
|
stmt->setUInt32(0, GetPlayerGUID());
|
|
|
|
|
stmt->setUInt32(1, friendGuid);
|
|
|
|
|
stmt->setUInt8(2, uint8(flag));
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
FriendInfo fi;
|
|
|
|
|
fi.Flags |= flag;
|
2011-12-31 00:32:05 +01:00
|
|
|
m_playerSocialMap[friendGuid] = fi;
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-12-31 00:32:05 +01:00
|
|
|
void PlayerSocial::RemoveFromSocialList(uint32 friendGuid, bool ignore)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-12-31 00:32:05 +01:00
|
|
|
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friendGuid);
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr == m_playerSocialMap.end()) // not exist
|
2008-10-11 14:16:25 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
uint32 flag = SOCIAL_FLAG_FRIEND;
|
2009-11-01 23:01:26 -08:00
|
|
|
if (ignore)
|
2008-10-11 14:16:25 -05:00
|
|
|
flag = SOCIAL_FLAG_IGNORED;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
itr->second.Flags &= ~flag;
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr->second.Flags == 0)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-12-31 00:32:05 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SOCIAL);
|
|
|
|
|
|
|
|
|
|
stmt->setUInt32(0, GetPlayerGUID());
|
|
|
|
|
stmt->setUInt32(1, friendGuid);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
m_playerSocialMap.erase(itr);
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-12-31 00:32:05 +01:00
|
|
|
{
|
|
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_CHARACTER_SOCIAL_FLAGS);
|
|
|
|
|
|
|
|
|
|
stmt->setUInt8(0, uint8(flag));
|
|
|
|
|
stmt->setUInt32(1, GetPlayerGUID());
|
|
|
|
|
stmt->setUInt32(2, friendGuid);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
}
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-12-31 00:32:05 +01:00
|
|
|
void PlayerSocial::SetFriendNote(uint32 friendGuid, std::string note)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-12-31 00:32:05 +01:00
|
|
|
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friendGuid);
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr == m_playerSocialMap.end()) // not exist
|
2008-10-11 14:16:25 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-29 20:47:02 +02:00
|
|
|
utf8truncate(note, 48); // DB and client size limitation
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-12-31 00:32:05 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE);
|
|
|
|
|
|
|
|
|
|
stmt->setString(0, note);
|
|
|
|
|
stmt->setUInt32(1, GetPlayerGUID());
|
|
|
|
|
stmt->setUInt32(2, friendGuid);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
|
|
|
|
|
m_playerSocialMap[friendGuid].Note = note;
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
void PlayerSocial::SendSocialList(Player* player)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-11-07 11:06:39 -06:00
|
|
|
if (!player)
|
2008-10-11 14:16:25 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
uint32 size = m_playerSocialMap.size();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
WorldPacket data(SMSG_CONTACT_LIST, (4+4+size*25)); // just can guess size
|
2011-11-07 07:16:31 +01:00
|
|
|
data << uint32(7); // 0x1 = Friendlist update. 0x2 = Ignorelist update. 0x4 = Mutelist update.
|
2008-10-11 14:16:25 -05:00
|
|
|
data << uint32(size); // friends count
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-10-17 16:20:24 -07:00
|
|
|
for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-11-07 11:06:39 -06:00
|
|
|
sSocialMgr->GetFriendInfo(player, itr->first, itr->second);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
data << uint64(itr->first); // player guid
|
2011-11-26 01:53:44 +01:00
|
|
|
data << uint32(itr->second.Flags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted)
|
2008-10-11 14:16:25 -05:00
|
|
|
data << itr->second.Note; // string note
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
data << uint8(itr->second.Status); // online/offline/etc?
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr->second.Status) // if online
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
data << uint32(itr->second.Area); // player area
|
|
|
|
|
data << uint32(itr->second.Level); // player level
|
|
|
|
|
data << uint32(itr->second.Class); // player class
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-11-07 11:06:39 -06:00
|
|
|
player->GetSession()->SendPacket(&data);
|
2011-02-20 20:16:34 +01:00
|
|
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_CONTACT_LIST");
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
bool PlayerSocial::HasFriend(uint32 friend_guid)
|
|
|
|
|
{
|
2009-04-29 00:26:07 -05:00
|
|
|
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (itr != m_playerSocialMap.end())
|
2008-10-11 14:16:25 -05:00
|
|
|
return itr->second.Flags & SOCIAL_FLAG_FRIEND;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
bool PlayerSocial::HasIgnore(uint32 ignore_guid)
|
|
|
|
|
{
|
2009-04-29 00:26:07 -05:00
|
|
|
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (itr != m_playerSocialMap.end())
|
2008-10-11 14:16:25 -05:00
|
|
|
return itr->second.Flags & SOCIAL_FLAG_IGNORED;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
SocialMgr::SocialMgr()
|
|
|
|
|
{
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
SocialMgr::~SocialMgr()
|
|
|
|
|
{
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-06-12 01:47:45 +02:00
|
|
|
void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &friendInfo)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!player)
|
2008-10-11 14:16:25 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-04-18 00:52:44 +02:00
|
|
|
friendInfo.Status = FRIEND_STATUS_OFFLINE;
|
|
|
|
|
friendInfo.Area = 0;
|
|
|
|
|
friendInfo.Level = 0;
|
|
|
|
|
friendInfo.Class = 0;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-15 14:08:17 +02:00
|
|
|
Player* pFriend = ObjectAccessor::FindPlayer(friendGUID);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!pFriend)
|
2009-04-18 00:52:44 +02:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
uint32 team = player->GetTeam();
|
2009-04-29 00:31:03 -05:00
|
|
|
AccountTypes security = player->GetSession()->GetSecurity();
|
2010-12-23 23:25:44 +01:00
|
|
|
bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
|
2011-06-09 19:41:13 +07:00
|
|
|
AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friendGUID);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (itr != player->GetSocial()->m_playerSocialMap.end())
|
2008-10-11 14:16:25 -05:00
|
|
|
friendInfo.Note = itr->second.Note;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
|
|
|
|
|
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
|
2009-07-20 11:51:20 +08:00
|
|
|
if (pFriend && pFriend->GetName() &&
|
2011-09-08 15:11:55 +02:00
|
|
|
(!AccountMgr::IsPlayerAccount(security) ||
|
2009-09-18 14:10:37 -07:00
|
|
|
((pFriend->GetTeam() == team || allowTwoSideWhoList) && (pFriend->GetSession()->GetSecurity() <= gmLevelInWhoList))) &&
|
2009-07-20 11:51:20 +08:00
|
|
|
pFriend->IsVisibleGloballyFor(player))
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
friendInfo.Status = FRIEND_STATUS_ONLINE;
|
2010-04-07 19:14:10 +02:00
|
|
|
if (pFriend->isAFK())
|
2008-10-11 14:16:25 -05:00
|
|
|
friendInfo.Status = FRIEND_STATUS_AFK;
|
2010-04-07 19:14:10 +02:00
|
|
|
if (pFriend->isDND())
|
2008-10-11 14:16:25 -05:00
|
|
|
friendInfo.Status = FRIEND_STATUS_DND;
|
|
|
|
|
friendInfo.Area = pFriend->GetZoneId();
|
|
|
|
|
friendInfo.Level = pFriend->getLevel();
|
|
|
|
|
friendInfo.Class = pFriend->getClass();
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-15 14:08:17 +02:00
|
|
|
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
data->Initialize(SMSG_FRIEND_STATUS, 5);
|
|
|
|
|
*data << uint8(result);
|
|
|
|
|
*data << uint64(guid);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-06-12 01:47:45 +02:00
|
|
|
void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
FriendInfo fi;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
WorldPacket data;
|
|
|
|
|
MakeFriendStatusPacket(result, friend_guid, &data);
|
|
|
|
|
GetFriendInfo(player, friend_guid, fi);
|
2009-11-01 23:01:26 -08:00
|
|
|
switch (result)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
case FRIEND_ADDED_OFFLINE:
|
|
|
|
|
case FRIEND_ADDED_ONLINE:
|
|
|
|
|
data << fi.Note;
|
|
|
|
|
break;
|
2009-05-03 22:21:46 -05:00
|
|
|
default:
|
|
|
|
|
break;
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-11-01 23:01:26 -08:00
|
|
|
switch (result)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
case FRIEND_ADDED_ONLINE:
|
|
|
|
|
case FRIEND_ONLINE:
|
|
|
|
|
data << uint8(fi.Status);
|
|
|
|
|
data << uint32(fi.Area);
|
|
|
|
|
data << uint32(fi.Level);
|
|
|
|
|
data << uint32(fi.Class);
|
|
|
|
|
break;
|
2009-05-03 22:21:46 -05:00
|
|
|
default:
|
|
|
|
|
break;
|
2008-10-11 14:16:25 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-11-01 23:01:26 -08:00
|
|
|
if (broadcast)
|
2008-10-11 14:16:25 -05:00
|
|
|
BroadcastToFriendListers(player, &data);
|
|
|
|
|
else
|
|
|
|
|
player->GetSession()->SendPacket(&data);
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-06-12 02:06:07 +02:00
|
|
|
void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2009-11-01 23:01:26 -08:00
|
|
|
if (!player)
|
2008-10-11 14:16:25 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-11-01 23:01:26 -08:00
|
|
|
uint32 team = player->GetTeam();
|
2009-04-29 00:31:03 -05:00
|
|
|
AccountTypes security = player->GetSession()->GetSecurity();
|
2009-11-01 23:01:26 -08:00
|
|
|
uint32 guid = player->GetGUIDLow();
|
2010-12-23 23:25:44 +01:00
|
|
|
AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
|
|
|
|
|
bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-10-17 16:20:24 -07:00
|
|
|
for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2009-02-16 20:12:55 -06:00
|
|
|
PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid);
|
2009-11-01 23:01:26 -08:00
|
|
|
if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
2011-09-15 14:08:17 +02:00
|
|
|
Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
|
|
|
|
|
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
|
2009-07-20 11:51:20 +08:00
|
|
|
if (pFriend && pFriend->IsInWorld() &&
|
2011-09-08 15:11:55 +02:00
|
|
|
(!AccountMgr::IsPlayerAccount(pFriend->GetSession()->GetSecurity()) ||
|
2009-09-18 14:10:37 -07:00
|
|
|
((pFriend->GetTeam() == team || allowTwoSideWhoList) && security <= gmLevelInWhoList)) &&
|
2009-07-20 11:51:20 +08:00
|
|
|
player->IsVisibleGloballyFor(pFriend))
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
pFriend->GetSession()->SendPacket(packet);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-09-20 18:20:40 +02:00
|
|
|
PlayerSocial *SocialMgr::LoadFromDB(PreparedQueryResult result, uint32 guid)
|
2008-10-11 14:16:25 -05:00
|
|
|
{
|
|
|
|
|
PlayerSocial *social = &m_socialMap[guid];
|
|
|
|
|
social->SetPlayerGUID(guid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!result)
|
2008-10-11 14:16:25 -05:00
|
|
|
return social;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
uint32 friend_guid = 0;
|
|
|
|
|
uint32 flags = 0;
|
|
|
|
|
std::string note = "";
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
do
|
|
|
|
|
{
|
2010-09-24 22:16:21 +02:00
|
|
|
Field* fields = result->Fetch();
|
|
|
|
|
|
|
|
|
|
friend_guid = fields[0].GetUInt32();
|
|
|
|
|
flags = fields[1].GetUInt32();
|
|
|
|
|
note = fields[2].GetString();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-01 17:28:59 +02:00
|
|
|
// client's friends list and ignore list limit
|
2010-04-07 19:14:10 +02:00
|
|
|
if (social->m_playerSocialMap.size() >= (SOCIALMGR_FRIEND_LIMIT + SOCIALMGR_IGNORE_LIMIT))
|
2008-10-11 14:16:25 -05:00
|
|
|
break;
|
2010-09-24 22:16:21 +02:00
|
|
|
}
|
|
|
|
|
while (result->NextRow());
|
2010-09-20 18:20:40 +02:00
|
|
|
|
2008-10-11 14:16:25 -05:00
|
|
|
return social;
|
|
|
|
|
}
|
2009-02-17 20:07:49 -06:00
|
|
|
|