2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef __MANGOS_SOCIALMGR_H
20 #define __MANGOS_SOCIALMGR_H
22 #include "Policies/Singleton.h"
23 #include "Database/DatabaseEnv.h"
24 #include "ObjectGuid.h"
33 FRIEND_STATUS_OFFLINE
= 0,
34 FRIEND_STATUS_ONLINE
= 1,
35 FRIEND_STATUS_AFK
= 2,
36 FRIEND_STATUS_UNK3
= 3,
42 SOCIAL_FLAG_FRIEND
= 0x01,
43 SOCIAL_FLAG_IGNORED
= 0x02,
44 SOCIAL_FLAG_MUTED
= 0x04, // guessed
45 SOCIAL_FLAG_RAF
= 0x08 // Recruit-A-Friend
59 Status
= FRIEND_STATUS_OFFLINE
;
67 FriendInfo(uint32 flags
, const std::string
& note
)
69 Status
= FRIEND_STATUS_OFFLINE
;
78 typedef std::map
<uint32
, FriendInfo
> PlayerSocialMap
;
79 typedef std::map
<uint32
, PlayerSocial
> SocialMap
;
81 /// Results of friend related commands
84 FRIEND_DB_ERROR
= 0x00, // ERR_FRIEND_NOT_FOUND
85 FRIEND_LIST_FULL
= 0x01,
87 FRIEND_OFFLINE
= 0x03,
88 FRIEND_NOT_FOUND
= 0x04, // ERR_FRIEND_NOT_FOUND
89 FRIEND_REMOVED
= 0x05,
90 FRIEND_ADDED_ONLINE
= 0x06, // ERR_FRIEND_ADDED_S
91 FRIEND_ADDED_OFFLINE
= 0x07,
92 FRIEND_ALREADY
= 0x08,
95 FRIEND_IGNORE_FULL
= 0x0B,
96 FRIEND_IGNORE_SELF
= 0x0C,
97 FRIEND_IGNORE_NOT_FOUND
= 0x0D,
98 FRIEND_IGNORE_ALREADY
= 0x0E,
99 FRIEND_IGNORE_ADDED
= 0x0F,
100 FRIEND_IGNORE_REMOVED
= 0x10,
101 FRIEND_IGNORE_AMBIGUOUS
= 0x11, // That name is ambiguous, type more of the player's server name
102 FRIEND_MUTE_FULL
= 0x12,
103 FRIEND_MUTE_SELF
= 0x13,
104 FRIEND_MUTE_NOT_FOUND
= 0x14,
105 FRIEND_MUTE_ALREADY
= 0x15,
106 FRIEND_MUTE_ADDED
= 0x16,
107 FRIEND_MUTE_REMOVED
= 0x17,
108 FRIEND_MUTE_AMBIGUOUS
= 0x18, // ERR_VOICE_IGNORE_AMBIGUOUS
109 FRIEND_UNK7
= 0x19, // ERR_MAX_VALUE (nothing is showed)
110 FRIEND_UNKNOWN
= 0x1A // Unknown friend response from server
113 #define SOCIALMGR_FRIEND_LIMIT 50
114 #define SOCIALMGR_IGNORE_LIMIT 50
118 friend class SocialMgr
;
123 bool AddToSocialList(ObjectGuid friend_guid
, bool ignore
);
124 void RemoveFromSocialList(ObjectGuid friend_guid
, bool ignore
);
125 void SetFriendNote(ObjectGuid friend_guid
, std::string note
);
127 void SendSocialList();
129 bool HasFriend(ObjectGuid friend_guid
);
130 bool HasIgnore(ObjectGuid ignore_guid
);
131 void SetPlayerGuid(ObjectGuid guid
) { m_playerLowGuid
= guid
.GetCounter(); }
132 uint32
GetNumberOfSocialsWithFlag(SocialFlag flag
);
134 PlayerSocialMap m_playerSocialMap
;
135 uint32 m_playerLowGuid
;
144 void RemovePlayerSocial(uint32 guid
) { m_socialMap
.erase(guid
); }
146 void GetFriendInfo(Player
* player
, uint32 friendGUID
, FriendInfo
& friendInfo
);
148 void MakeFriendStatusPacket(FriendsResult result
, uint32 friend_guid
, WorldPacket
* data
);
149 void SendFriendStatus(Player
* player
, FriendsResult result
, ObjectGuid friend_guid
, bool broadcast
);
150 void BroadcastToFriendListers(Player
* player
, WorldPacket
* packet
);
152 PlayerSocial
* LoadFromDB(QueryResult
* result
, ObjectGuid guid
);
154 SocialMap m_socialMap
;
157 #define sSocialMgr MaNGOS::Singleton<SocialMgr>::Instance()