TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SocialMgr Class Reference

#include <SocialMgr.h>

Public Member Functions

void RemovePlayerSocial (ObjectGuid const &guid)
 
void GetFriendInfo (Player *player, ObjectGuid const &friendGUID, FriendInfo &friendInfo)
 
void SendFriendStatus (Player *player, FriendsResult result, ObjectGuid const &friendGuid, bool broadcast=false)
 
void BroadcastToFriendListers (Player *player, WorldPacket const *packet)
 
PlayerSocialLoadFromDB (PreparedQueryResult result, ObjectGuid const &guid)
 

Static Public Member Functions

static SocialMgrinstance ()
 

Private Types

typedef std::map< ObjectGuid,
PlayerSocial
SocialMap
 

Private Member Functions

 SocialMgr ()
 
 ~SocialMgr ()
 

Private Attributes

SocialMap _socialMap
 

Member Typedef Documentation

typedef std::map<ObjectGuid, PlayerSocial> SocialMgr::SocialMap
private

Constructor & Destructor Documentation

SocialMgr::SocialMgr ( )
inlineprivate
137 { }
SocialMgr::~SocialMgr ( )
inlineprivate
138 { }

Member Function Documentation

void SocialMgr::BroadcastToFriendListers ( Player player,
WorldPacket const packet 
)
229 {
230  ASSERT(player);
231 
232  AccountTypes gmSecLevel = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
233  for (SocialMap::const_iterator itr = _socialMap.begin(); itr != _socialMap.end(); ++itr)
234  {
235  PlayerSocial::PlayerSocialMap::const_iterator itr2 = itr->second._playerSocialMap.find(player->GetGUID());
236  if (itr2 != itr->second._playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND) != 0)
237  {
238  Player* target = ObjectAccessor::FindPlayer(itr->first);
239  if (!target)
240  continue;
241 
242  WorldSession* session = target->GetSession();
243  if (!session->HasPermission(rbac::RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) && player->GetSession()->GetSecurity() > gmSecLevel)
244  continue;
245 
246  if (target->GetTeam() != player->GetTeam() && !session->HasPermission(rbac::RBAC_PERM_TWO_SIDE_WHO_LIST))
247  continue;
248 
249  if (player->IsVisibleGloballyFor(target))
250  session->SendPacket(packet);
251  }
252  }
253 }
SocialMap _socialMap
Definition: SocialMgr.h:157
#define sWorld
Definition: World.h:887
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
AccountTypes
Definition: Common.h:106
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: World.h:264
#define ASSERT
Definition: Errors.h:55
Player session in the World.
Definition: WorldSession.h:882
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: SocialMgr.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SocialMgr::GetFriendInfo ( Player player,
ObjectGuid const friendGUID,
FriendInfo friendInfo 
)
171 {
172  if (!player)
173  return;
174 
175  friendInfo.Status = FRIEND_STATUS_OFFLINE;
176  friendInfo.Area = 0;
177  friendInfo.Level = 0;
178  friendInfo.Class = 0;
179 
180  Player* target = ObjectAccessor::FindPlayer(friendGUID);
181  if (!target)
182  return;
183 
184  PlayerSocial::PlayerSocialMap::iterator itr = player->GetSocial()->_playerSocialMap.find(friendGUID);
185  if (itr != player->GetSocial()->_playerSocialMap.end())
186  friendInfo.Note = itr->second.Note;
187 
188  // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
189  // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
190 
191  if (!player->GetSession()->HasPermission(rbac::RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) &&
192  target->GetSession()->GetSecurity() > AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST)))
193  return;
194 
195  // player can see member of other team only if CONFIG_ALLOW_TWO_SIDE_WHO_LIST
196  if (target->GetTeam() != player->GetTeam() && !player->GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_WHO_LIST))
197  return;
198 
199  if (target->IsVisibleGloballyFor(player))
200  {
201  if (target->isDND())
202  friendInfo.Status = FRIEND_STATUS_DND;
203  else if (target->isAFK())
204  friendInfo.Status = FRIEND_STATUS_AFK;
205  else
206  friendInfo.Status = FRIEND_STATUS_ONLINE;
207 
208  friendInfo.Area = target->GetZoneId();
209  friendInfo.Level = target->getLevel();
210  friendInfo.Class = target->getClass();
211  }
212 }
std::string Note
Definition: SocialMgr.h:56
Definition: SocialMgr.h:34
FriendStatus Status
Definition: SocialMgr.h:51
#define sWorld
Definition: World.h:887
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint8 Level
Definition: SocialMgr.h:54
Definition: SocialMgr.h:31
AccountTypes
Definition: Common.h:106
Definition: World.h:264
uint8 Class
Definition: SocialMgr.h:55
uint32 Area
Definition: SocialMgr.h:53
Definition: SocialMgr.h:33
Definition: SocialMgr.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SocialMgr * SocialMgr::instance ( )
static
165 {
166  static SocialMgr instance;
167  return &instance;
168 }
Definition: SocialMgr.h:134
static SocialMgr * instance()
Definition: SocialMgr.cpp:164
PlayerSocial * SocialMgr::LoadFromDB ( PreparedQueryResult  result,
ObjectGuid const guid 
)
256 {
257  PlayerSocial* social = &_socialMap[guid];
258  social->SetPlayerGUID(guid);
259 
260  if (result)
261  {
262  do
263  {
264  Field* fields = result->Fetch();
265 
266  ObjectGuid friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
267  ObjectGuid friendAccountGuid = ObjectGuid::Create<HighGuid::WowAccount>(uint64(fields[1].GetUInt32()));
268 
269  uint8 flag = fields[2].GetUInt8();
270  social->_playerSocialMap[friendGuid] = FriendInfo(friendAccountGuid, flag, fields[3].GetString());
271  }
272  while (result->NextRow());
273  }
274 
275  return social;
276 }
uint64 GetUInt64() const
Definition: Field.h:184
Definition: SocialMgr.h:48
SocialMap _socialMap
Definition: SocialMgr.h:157
Class used to access individual fields of database query result.
Definition: Field.h:56
uint64_t uint64
Definition: g3dmath.h:170
uint8 GetUInt8() const
Definition: Field.h:70
Definition: SocialMgr.h:103
void SetPlayerGUID(ObjectGuid const &guid)
Definition: SocialMgr.h:121
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

void SocialMgr::RemovePlayerSocial ( ObjectGuid const guid)
inline
144 { _socialMap.erase(guid); }
SocialMap _socialMap
Definition: SocialMgr.h:157
void SocialMgr::SendFriendStatus ( Player player,
FriendsResult  result,
ObjectGuid const friendGuid,
bool  broadcast = false 
)
215 {
216  FriendInfo fi;
217  GetFriendInfo(player, friendGuid, fi);
218 
220  friendStatus.Initialize(friendGuid, result, fi);
221 
222  if (broadcast)
223  BroadcastToFriendListers(player, friendStatus.Write());
224  else
225  player->SendDirectMessage(friendStatus.Write());
226 }
Definition: SocialMgr.h:48
void BroadcastToFriendListers(Player *player, WorldPacket const *packet)
Definition: SocialMgr.cpp:228
Definition: SocialPackets.h:69
void Initialize(ObjectGuid const &guid, FriendsResult result, FriendInfo const &friendInfo)
Definition: SocialPackets.cpp:72
void GetFriendInfo(Player *player, ObjectGuid const &friendGUID, FriendInfo &friendInfo)
Definition: SocialMgr.cpp:170
WorldPacket const * Write() override
Definition: SocialPackets.cpp:85

+ Here is the call graph for this function:

Member Data Documentation

SocialMap SocialMgr::_socialMap
private

The documentation for this class was generated from the following files: