root/trunk/src/game/SocialMgr.h @ 2

Revision 2, 4.6 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

RevLine 
[2]1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef __MANGOS_SOCIALMGR_H
20#define __MANGOS_SOCIALMGR_H
21
22#include "Policies/Singleton.h"
23#include "Database/DatabaseEnv.h"
24#include "Common.h"
25
26class SocialMgr;
27class PlayerSocial;
28class Player;
29class WorldPacket;
30
31enum FriendStatus
32{
33    FRIEND_STATUS_OFFLINE   = 0,
34    FRIEND_STATUS_ONLINE    = 1,
35    FRIEND_STATUS_AFK       = 2,
36    FRIEND_STATUS_UNK3      = 3,
37    FRIEND_STATUS_DND       = 4
38};
39
40enum SocialFlag
41{
42    SOCIAL_FLAG_FRIEND      = 0x01,
43    SOCIAL_FLAG_IGNORED     = 0x02,
44    SOCIAL_FLAG_MUTED       = 0x04                          // guessed
45};
46
47struct FriendInfo
48{
49    FriendStatus Status;
50    uint32 Flags;
51    uint32 Area;
52    uint32 Level;
53    uint32 Class;
54    std::string Note;
55
56    FriendInfo()
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, 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
77typedef std::map<uint32, FriendInfo> PlayerSocialMap;
78typedef std::map<uint32, PlayerSocial> SocialMap;
79
80/// Results of friend related commands
81enum FriendsResult
82{
83    FRIEND_DB_ERROR         = 0x00,
84    FRIEND_LIST_FULL        = 0x01,
85    FRIEND_ONLINE           = 0x02,
86    FRIEND_OFFLINE          = 0x03,
87    FRIEND_NOT_FOUND        = 0x04,
88    FRIEND_REMOVED          = 0x05,
89    FRIEND_ADDED_ONLINE     = 0x06,
90    FRIEND_ADDED_OFFLINE    = 0x07,
91    FRIEND_ALREADY          = 0x08,
92    FRIEND_SELF             = 0x09,
93    FRIEND_ENEMY            = 0x0A,
94    FRIEND_IGNORE_FULL      = 0x0B,
95    FRIEND_IGNORE_SELF      = 0x0C,
96    FRIEND_IGNORE_NOT_FOUND = 0x0D,
97    FRIEND_IGNORE_ALREADY   = 0x0E,
98    FRIEND_IGNORE_ADDED     = 0x0F,
99    FRIEND_IGNORE_REMOVED   = 0x10,
100    FRIEND_IGNORE_AMBIGUOUS = 0x11,                         // That name is ambiguous, type more of the player's server name
101    FRIEND_MUTE_FULL        = 0x12,
102    FRIEND_MUTE_SELF        = 0x13,
103    FRIEND_MUTE_NOT_FOUND   = 0x14,
104    FRIEND_MUTE_ALREADY     = 0x15,
105    FRIEND_MUTE_ADDED       = 0x16,
106    FRIEND_MUTE_REMOVED     = 0x17,
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
112class PlayerSocial
113{
114    friend class SocialMgr;
115    public:
116        PlayerSocial();
117        ~PlayerSocial();
118        // adding/removing
119        bool AddToSocialList(uint32 friend_guid, bool ignore);
120        void RemoveFromSocialList(uint32 friend_guid, bool ignore);
121        void SetFriendNote(uint32 friend_guid, std::string note);
122        // Packet send's
123        void SendSocialList();
124        // Misc
125        bool HasFriend(uint32 friend_guid);
126        bool HasIgnore(uint32 ignore_guid);
127        uint32 GetPlayerGUID() { return m_playerGUID; }
128        void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; }
129    private:
130        PlayerSocialMap m_playerSocialMap;
131        uint32 m_playerGUID;
132};
133
134class SocialMgr
135{
136    public:
137        SocialMgr();
138        ~SocialMgr();
139        // Misc
140        void RemovePlayerSocial(uint32 guid);
141        void GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo);
142        // Packet management
143        void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data);
144        void SendFriendStatus(Player *player, FriendsResult result, uint32 friend_guid, std::string name, bool broadcast);
145        void BroadcastToFriendListers(Player *player, WorldPacket *packet);
146        // Loading
147        PlayerSocial *LoadFromDB(QueryResult *result, uint32 guid);
148    private:
149        SocialMap m_socialMap;
150};
151
152#define sSocialMgr MaNGOS::Singleton<SocialMgr>::Instance()
153#endif
Note: See TracBrowser for help on using the browser.