OregonCore  revision fb2a440-git
Your Favourite TBC server
SocialMgr.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __OREGON_SOCIALMGR_H
19 #define __OREGON_SOCIALMGR_H
20 
21 #include "Policies/Singleton.h"
22 #include "Database/DatabaseEnv.h"
23 #include "Common.h"
24 
25 class SocialMgr;
26 class PlayerSocial;
27 class Player;
28 class WorldPacket;
29 
31 {
38 };
39 
41 {
44  SOCIAL_FLAG_MUTED = 0x04 // guessed
45 };
46 
47 struct FriendInfo
48 {
54  std::string Note;
55 
57  {
58  Status = FRIEND_STATUS_OFFLINE;
59  Flags = 0;
60  Area = 0;
61  Level = 0;
62  Class = 0;
63  Note = "";
64  }
65 
66  FriendInfo(uint32 flags, const std::string& note)
67  {
68  Status = FRIEND_STATUS_OFFLINE;
69  Flags = flags;
70  Area = 0;
71  Level = 0;
72  Class = 0;
73  Note = note;
74  }
75 };
76 
77 typedef std::map<uint32, FriendInfo> PlayerSocialMap;
78 typedef std::map<uint32, PlayerSocial> SocialMap;
79 
80 // Results of friend related commands
82 {
85  FRIEND_ONLINE = 0x02,
92  FRIEND_SELF = 0x09,
93  FRIEND_ENEMY = 0x0A,
100  FRIEND_IGNORE_AMBIGUOUS = 0x11, // That name is ambiguous, type more of the player's server name
107  FRIEND_MUTE_AMBIGUOUS = 0x18, // That name is ambiguous, type more of the player's server name
108  FRIEND_UNK7 = 0x19, // no message at client
109  FRIEND_UNKNOWN = 0x1A // Unknown friend response from server
110 };
111 
112 #define SOCIALMGR_FRIEND_LIMIT 50
113 #define SOCIALMGR_IGNORE_LIMIT 25
114 
116 {
117  friend class SocialMgr;
118  public:
119  PlayerSocial();
120  ~PlayerSocial();
121  // adding/removing
122  bool AddToSocialList(uint32 friend_guid, bool ignore);
123  void RemoveFromSocialList(uint32 friend_guid, bool ignore);
124  void SetFriendNote(uint32 friend_guid, std::string note);
125  // Packet send's
126  void SendSocialList();
127  // Misc
128  bool HasFriend(uint32 friend_guid);
129  bool HasIgnore(uint32 ignore_guid);
131  {
132  return m_playerGUID;
133  }
135  {
136  m_playerGUID = guid;
137  }
138  uint32 GetNumberOfSocialsWithFlag(SocialFlag flag);
139  private:
142 };
143 
145 {
146  public:
147  SocialMgr();
148  ~SocialMgr();
149  // Misc
151  {
152  m_socialMap.erase(guid);
153  }
154 
155  void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo& friendInfo);
156  // Packet management
157  void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data);
158  void SendFriendStatus(Player* player, FriendsResult result, uint32 friend_guid, bool broadcast);
159  void BroadcastToFriendListers(Player* player, WorldPacket* packet);
160  // Loading
161  PlayerSocial* LoadFromDB(QueryResult_AutoPtr result, uint32 guid);
162  private:
164 };
165 
166 #define sSocialMgr Oregon::Singleton<SocialMgr>::Instance()
167 #endif
168 
uint32 Level
Definition: SocialMgr.h:52
SocialFlag
Definition: SocialMgr.h:40
std::string Note
Definition: SocialMgr.h:54
std::map< uint32, FriendInfo > PlayerSocialMap
Definition: SocialMgr.h:77
void RemovePlayerSocial(uint32 guid)
Definition: SocialMgr.h:150
uint32 Class
Definition: SocialMgr.h:53
FriendStatus Status
Definition: SocialMgr.h:49
std::map< uint32, PlayerSocial > SocialMap
Definition: SocialMgr.h:78
FriendInfo(uint32 flags, const std::string &note)
Definition: SocialMgr.h:66
FriendsResult
Definition: SocialMgr.h:81
uint32 m_playerGUID
Definition: SocialMgr.h:141
uint32 Flags
Definition: SocialMgr.h:50
PlayerSocialMap m_playerSocialMap
Definition: SocialMgr.h:140
void SetPlayerGUID(uint32 guid)
Definition: SocialMgr.h:134
SocialMap m_socialMap
Definition: SocialMgr.h:163
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
uint32 GetPlayerGUID()
Definition: SocialMgr.h:130
uint32 Area
Definition: SocialMgr.h:51
FriendStatus
Definition: SocialMgr.h:30
ACE_UINT32 uint32
Definition: Define.h:71
FriendInfo()
Definition: SocialMgr.h:56
Definition: Player.h:922