TrinityCore
Loading...
Searching...
No Matches
ChannelMgr.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore 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#ifndef TRINITYCORE_CHANNEL_MGR_H
18#define TRINITYCORE_CHANNEL_MGR_H
19
20#include "Define.h"
21#include "ObjectGuid.h"
23#include "SharedDefines.h"
24#include <string>
25#include <unordered_map>
26
27class Channel;
28class Player;
29struct AreaTableEntry;
30
32{
33 typedef std::unordered_map<std::wstring, Channel*> CustomChannelContainer; // custom channels only differ in name
34 typedef std::unordered_map<ObjectGuid, Channel*> BuiltinChannelContainer;
35
36 protected:
37 explicit ChannelMgr(Team team);
39
40 public:
41 ChannelMgr(ChannelMgr const& right) = delete;
42 ChannelMgr(ChannelMgr&& right) = delete;
43 ChannelMgr& operator=(ChannelMgr const& right) = delete;
44 ChannelMgr& operator=(ChannelMgr&& right) = delete;
45
46 static void LoadFromDB();
47 static ChannelMgr* ForTeam(Team team);
48 static Channel* GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher);
49 static Channel* GetChannelForPlayerByGuid(ObjectGuid channelGuid, Player* playerSearcher);
51
52 void SaveToDB();
53 Channel* GetSystemChannel(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr);
54 Channel* CreateCustomChannel(std::string const& name);
55 Channel* GetCustomChannel(std::string const& name) const;
56 Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool notify = true, AreaTableEntry const* zoneEntry = nullptr) const;
57 void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
58
59 private:
62 Team const _team;
64
65 static void SendNotOnChannelNotify(Player const* player, std::string const& name);
66 ObjectGuid CreateCustomChannelGuid();
67 ObjectGuid CreateBuiltinChannelGuid(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr) const;
68};
69
70#endif
#define TC_GAME_API
Definition Define.h:129
uint32_t uint32
Definition Define.h:154
static void SaveToDB(QuestPool const &pool, CharacterDatabaseTransaction trans)
std::unordered_map< ObjectGuid, Channel * > BuiltinChannelContainer
Definition ChannelMgr.h:34
CustomChannelContainer _customChannels
Definition ChannelMgr.h:60
ChannelMgr & operator=(ChannelMgr &&right)=delete
static AreaTableEntry const * SpecialLinkedArea
Definition ChannelMgr.h:50
std::unordered_map< std::wstring, Channel * > CustomChannelContainer
Definition ChannelMgr.h:33
Team const _team
Definition ChannelMgr.h:62
ObjectGuidGenerator _guidGenerator
Definition ChannelMgr.h:63
ChannelMgr(ChannelMgr &&right)=delete
ChannelMgr(ChannelMgr const &right)=delete
ChannelMgr & operator=(ChannelMgr const &right)=delete
BuiltinChannelContainer _channels
Definition ChannelMgr.h:61