[2] | 1 | /* |
---|
[102] | 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
[44] | 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 5 | * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
[44] | 21 | #ifndef __TRINITY_SOCIALMGR_H |
---|
| 22 | #define __TRINITY_SOCIALMGR_H |
---|
[2] | 23 | |
---|
| 24 | #include "Policies/Singleton.h" |
---|
| 25 | #include "Database/DatabaseEnv.h" |
---|
| 26 | #include "Common.h" |
---|
| 27 | |
---|
| 28 | class SocialMgr; |
---|
| 29 | class PlayerSocial; |
---|
| 30 | class Player; |
---|
| 31 | class WorldPacket; |
---|
| 32 | |
---|
| 33 | enum FriendStatus |
---|
| 34 | { |
---|
| 35 | FRIEND_STATUS_OFFLINE = 0, |
---|
| 36 | FRIEND_STATUS_ONLINE = 1, |
---|
| 37 | FRIEND_STATUS_AFK = 2, |
---|
| 38 | FRIEND_STATUS_UNK3 = 3, |
---|
| 39 | FRIEND_STATUS_DND = 4 |
---|
| 40 | }; |
---|
| 41 | |
---|
| 42 | enum SocialFlag |
---|
| 43 | { |
---|
| 44 | SOCIAL_FLAG_FRIEND = 0x01, |
---|
| 45 | SOCIAL_FLAG_IGNORED = 0x02, |
---|
| 46 | SOCIAL_FLAG_MUTED = 0x04 // guessed |
---|
| 47 | }; |
---|
| 48 | |
---|
| 49 | struct FriendInfo |
---|
| 50 | { |
---|
| 51 | FriendStatus Status; |
---|
| 52 | uint32 Flags; |
---|
| 53 | uint32 Area; |
---|
| 54 | uint32 Level; |
---|
| 55 | uint32 Class; |
---|
| 56 | std::string Note; |
---|
| 57 | |
---|
| 58 | FriendInfo() |
---|
| 59 | { |
---|
| 60 | Status = FRIEND_STATUS_OFFLINE; |
---|
| 61 | Flags = 0; |
---|
| 62 | Area = 0; |
---|
| 63 | Level = 0; |
---|
| 64 | Class = 0; |
---|
| 65 | Note = ""; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | FriendInfo(uint32 flags, std::string note) |
---|
| 69 | { |
---|
| 70 | Status = FRIEND_STATUS_OFFLINE; |
---|
| 71 | Flags = flags; |
---|
| 72 | Area = 0; |
---|
| 73 | Level = 0; |
---|
| 74 | Class = 0; |
---|
| 75 | Note = note; |
---|
| 76 | } |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | typedef std::map<uint32, FriendInfo> PlayerSocialMap; |
---|
| 80 | typedef std::map<uint32, PlayerSocial> SocialMap; |
---|
| 81 | |
---|
| 82 | /// Results of friend related commands |
---|
| 83 | enum FriendsResult |
---|
| 84 | { |
---|
| 85 | FRIEND_DB_ERROR = 0x00, |
---|
| 86 | FRIEND_LIST_FULL = 0x01, |
---|
| 87 | FRIEND_ONLINE = 0x02, |
---|
| 88 | FRIEND_OFFLINE = 0x03, |
---|
| 89 | FRIEND_NOT_FOUND = 0x04, |
---|
| 90 | FRIEND_REMOVED = 0x05, |
---|
| 91 | FRIEND_ADDED_ONLINE = 0x06, |
---|
| 92 | FRIEND_ADDED_OFFLINE = 0x07, |
---|
| 93 | FRIEND_ALREADY = 0x08, |
---|
| 94 | FRIEND_SELF = 0x09, |
---|
| 95 | FRIEND_ENEMY = 0x0A, |
---|
| 96 | FRIEND_IGNORE_FULL = 0x0B, |
---|
| 97 | FRIEND_IGNORE_SELF = 0x0C, |
---|
| 98 | FRIEND_IGNORE_NOT_FOUND = 0x0D, |
---|
| 99 | FRIEND_IGNORE_ALREADY = 0x0E, |
---|
| 100 | FRIEND_IGNORE_ADDED = 0x0F, |
---|
| 101 | FRIEND_IGNORE_REMOVED = 0x10, |
---|
| 102 | FRIEND_IGNORE_AMBIGUOUS = 0x11, // That name is ambiguous, type more of the player's server name |
---|
| 103 | FRIEND_MUTE_FULL = 0x12, |
---|
| 104 | FRIEND_MUTE_SELF = 0x13, |
---|
| 105 | FRIEND_MUTE_NOT_FOUND = 0x14, |
---|
| 106 | FRIEND_MUTE_ALREADY = 0x15, |
---|
| 107 | FRIEND_MUTE_ADDED = 0x16, |
---|
| 108 | FRIEND_MUTE_REMOVED = 0x17, |
---|
| 109 | FRIEND_MUTE_AMBIGUOUS = 0x18, // That name is ambiguous, type more of the player's server name |
---|
| 110 | FRIEND_UNK7 = 0x19, // no message at client |
---|
| 111 | FRIEND_UNKNOWN = 0x1A // Unknown friend response from server |
---|
| 112 | }; |
---|
| 113 | |
---|
[139] | 114 | #define SOCIALMGR_FRIEND_LIMIT 50 |
---|
| 115 | #define SOCIALMGR_IGNORE_LIMIT 25 |
---|
| 116 | |
---|
[2] | 117 | class PlayerSocial |
---|
| 118 | { |
---|
| 119 | friend class SocialMgr; |
---|
| 120 | public: |
---|
| 121 | PlayerSocial(); |
---|
| 122 | ~PlayerSocial(); |
---|
| 123 | // adding/removing |
---|
| 124 | bool AddToSocialList(uint32 friend_guid, bool ignore); |
---|
| 125 | void RemoveFromSocialList(uint32 friend_guid, bool ignore); |
---|
| 126 | void SetFriendNote(uint32 friend_guid, std::string note); |
---|
| 127 | // Packet send's |
---|
| 128 | void SendSocialList(); |
---|
| 129 | // Misc |
---|
| 130 | bool HasFriend(uint32 friend_guid); |
---|
| 131 | bool HasIgnore(uint32 ignore_guid); |
---|
| 132 | uint32 GetPlayerGUID() { return m_playerGUID; } |
---|
| 133 | void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; } |
---|
[139] | 134 | uint32 GetNumberOfSocialsWithFlag(SocialFlag flag); |
---|
[2] | 135 | private: |
---|
| 136 | PlayerSocialMap m_playerSocialMap; |
---|
| 137 | uint32 m_playerGUID; |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | class SocialMgr |
---|
| 141 | { |
---|
| 142 | public: |
---|
| 143 | SocialMgr(); |
---|
| 144 | ~SocialMgr(); |
---|
| 145 | // Misc |
---|
| 146 | void RemovePlayerSocial(uint32 guid); |
---|
| 147 | void GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo); |
---|
| 148 | // Packet management |
---|
| 149 | void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data); |
---|
[173] | 150 | void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, bool broadcast); |
---|
[2] | 151 | void BroadcastToFriendListers(Player *player, WorldPacket *packet); |
---|
| 152 | // Loading |
---|
| 153 | PlayerSocial *LoadFromDB(QueryResult *result, uint32 guid); |
---|
| 154 | private: |
---|
| 155 | SocialMap m_socialMap; |
---|
| 156 | }; |
---|
| 157 | |
---|
[44] | 158 | #define sSocialMgr Trinity::Singleton<SocialMgr>::Instance() |
---|
[2] | 159 | #endif |
---|