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

#include <SocialMgr.h>

Public Member Functions

bool AddToSocialList (ObjectGuid const &guid, SocialFlag flag)
 
void RemoveFromSocialList (ObjectGuid const &guid, SocialFlag flag)
 
void SetFriendNote (ObjectGuid const &guid, std::string const &note)
 
void SendSocialList (Player *player, uint32 flags)
 
bool HasFriend (ObjectGuid const &friendGuid)
 
bool HasIgnore (ObjectGuid const &ignoreGuid)
 
ObjectGuid constGetPlayerGUID () const
 
void SetPlayerGUID (ObjectGuid const &guid)
 
uint32 GetNumberOfSocialsWithFlag (SocialFlag flag)
 

Private Types

typedef std::map< ObjectGuid,
FriendInfo
PlayerSocialMap
 

Private Member Functions

bool _HasContact (ObjectGuid const &guid, SocialFlag flags)
 

Private Attributes

PlayerSocialMap _playerSocialMap
 
ObjectGuid _playerGUID
 

Friends

class SocialMgr
 

Member Typedef Documentation

Member Function Documentation

bool PlayerSocial::_HasContact ( ObjectGuid const guid,
SocialFlag  flags 
)
private
146 {
147  PlayerSocialMap::const_iterator itr = _playerSocialMap.find(guid);
148  if (itr != _playerSocialMap.end())
149  return (itr->second.Flags & flags) != 0;
150 
151  return false;
152 }
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the caller graph for this function:

bool PlayerSocial::AddToSocialList ( ObjectGuid const guid,
SocialFlag  flag 
)
38 {
39  // check client limits
41  return false;
42 
43  PlayerSocialMap::iterator itr = _playerSocialMap.find(friendGuid);
44  if (itr != _playerSocialMap.end())
45  {
46  itr->second.Flags |= flag;
47 
49 
50  stmt->setUInt8(0, itr->second.Flags);
51  stmt->setUInt64(1, GetPlayerGUID().GetCounter());
52  stmt->setUInt64(2, friendGuid.GetCounter());
53 
55  }
56  else
57  {
58  _playerSocialMap[friendGuid].Flags |= flag;
59 
61 
62  stmt->setUInt64(0, GetPlayerGUID().GetCounter());
63  stmt->setUInt64(1, friendGuid.GetCounter());
64  stmt->setUInt8(2, flag);
65 
67  }
68 
69  return true;
70 }
ObjectGuid const & GetPlayerGUID() const
Definition: SocialMgr.h:120
#define SOCIALMGR_FRIEND_LIMIT
Definition: SocialMgr.h:100
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:365
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:366
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
#define SOCIALMGR_IGNORE_LIMIT
Definition: SocialMgr.h:101
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: SocialMgr.h:40
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag)
Definition: SocialMgr.cpp:27

+ Here is the call graph for this function:

uint32 PlayerSocial::GetNumberOfSocialsWithFlag ( SocialFlag  flag)
28 {
29  uint32 counter = 0;
30  for (PlayerSocialMap::const_iterator itr = _playerSocialMap.begin(); itr != _playerSocialMap.end(); ++itr)
31  if ((itr->second.Flags & flag) != 0)
32  ++counter;
33 
34  return counter;
35 }
uint32_t uint32
Definition: Define.h:150
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129

+ Here is the caller graph for this function:

ObjectGuid const& PlayerSocial::GetPlayerGUID ( ) const
inline
120 { return _playerGUID; }
ObjectGuid _playerGUID
Definition: SocialMgr.h:131

+ Here is the caller graph for this function:

bool PlayerSocial::HasFriend ( ObjectGuid const friendGuid)
155 {
156  return _HasContact(friendGuid, SOCIAL_FLAG_FRIEND);
157 }
bool _HasContact(ObjectGuid const &guid, SocialFlag flags)
Definition: SocialMgr.cpp:145
Definition: SocialMgr.h:40

+ Here is the call graph for this function:

bool PlayerSocial::HasIgnore ( ObjectGuid const ignoreGuid)
160 {
161  return _HasContact(ignoreGuid, SOCIAL_FLAG_IGNORED);
162 }
Definition: SocialMgr.h:41
bool _HasContact(ObjectGuid const &guid, SocialFlag flags)
Definition: SocialMgr.cpp:145

+ Here is the call graph for this function:

void PlayerSocial::RemoveFromSocialList ( ObjectGuid const guid,
SocialFlag  flag 
)
73 {
74  PlayerSocialMap::iterator itr = _playerSocialMap.find(friendGuid);
75  if (itr == _playerSocialMap.end())
76  return;
77 
78  itr->second.Flags &= ~flag;
79 
80  if (!itr->second.Flags)
81  {
83 
84  stmt->setUInt64(0, GetPlayerGUID().GetCounter());
85  stmt->setUInt64(1, friendGuid.GetCounter());
86 
88 
89  _playerSocialMap.erase(itr);
90  }
91  else
92  {
94 
95  stmt->setUInt8(0, itr->second.Flags);
96  stmt->setUInt64(1, GetPlayerGUID().GetCounter());
97  stmt->setUInt64(2, friendGuid.GetCounter());
98 
100  }
101 }
ObjectGuid const & GetPlayerGUID() const
Definition: SocialMgr.h:120
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:365
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:367

+ Here is the call graph for this function:

void PlayerSocial::SendSocialList ( Player player,
uint32  flags 
)
122 {
123  ASSERT(player);
124 
126  contactList.Flags = flags;
127 
128  for (PlayerSocialMap::value_type& v : _playerSocialMap)
129  {
130  if (!(v.second.Flags & flags))
131  continue;
132 
133  sSocialMgr->GetFriendInfo(player, v.first, v.second);
134 
135  contactList.Contacts.emplace_back(v.first, v.second);
136 
137  // client's friends list and ignore list limit
138  if (contactList.Contacts.size() >= (((flags & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT))
139  break;
140  }
141 
142  player->SendDirectMessage(contactList.Write());
143 }
#define SOCIALMGR_FRIEND_LIMIT
Definition: SocialMgr.h:100
std::vector< ContactInfo > Contacts
Definition: SocialPackets.h:65
uint32 Flags
Definition: SocialPackets.h:66
#define sSocialMgr
Definition: SocialMgr.h:160
Definition: SocialPackets.h:58
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
#define SOCIALMGR_IGNORE_LIMIT
Definition: SocialMgr.h:101
#define ASSERT
Definition: Errors.h:55
WorldPacket const * Write() override
Definition: SocialPackets.cpp:60
uint8 flags
Definition: DisableMgr.cpp:44
Definition: SocialMgr.h:40

+ Here is the call graph for this function:

void PlayerSocial::SetFriendNote ( ObjectGuid const guid,
std::string const note 
)
104 {
105  PlayerSocialMap::iterator itr = _playerSocialMap.find(friendGuid);
106  if (itr == _playerSocialMap.end()) // not exist
107  return;
108 
109  itr->second.Note = note;
110  utf8truncate(itr->second.Note, 48); // DB and client size limitation
111 
113 
114  stmt->setString(0, itr->second.Note);
115  stmt->setUInt64(1, GetPlayerGUID().GetCounter());
116  stmt->setUInt64(2, friendGuid.GetCounter());
117 
119 }
ObjectGuid const & GetPlayerGUID() const
Definition: SocialMgr.h:120
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:368
void utf8truncate(std::string &utf8str, size_t len)
Definition: Util.cpp:260
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
PlayerSocialMap _playerSocialMap
Definition: SocialMgr.h:129
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

void PlayerSocial::SetPlayerGUID ( ObjectGuid const guid)
inline
121 { _playerGUID = guid; }
ObjectGuid _playerGUID
Definition: SocialMgr.h:131

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class SocialMgr
friend

Member Data Documentation

ObjectGuid PlayerSocial::_playerGUID
private
PlayerSocialMap PlayerSocial::_playerSocialMap
private

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