TrinityCore
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 __TRINITY_CHANNELMGR_H
18#define __TRINITY_CHANNELMGR_H
19
20#include "Define.h"
21#include "ObjectGuid.h"
22#include <string>
23#include <unordered_map>
24
25class Channel;
26class Player;
27struct AreaTableEntry;
28
30{
31 typedef std::unordered_map<std::wstring, Channel*> CustomChannelContainer; // custom channels only differ in name
32 typedef std::unordered_map<ObjectGuid, Channel*> BuiltinChannelContainer;
33
34 protected:
35 explicit ChannelMgr(uint32 team) : _team(team), _guidGenerator(HighGuid::ChatChannel) { }
37
38 public:
39 ChannelMgr(ChannelMgr const& right) = delete;
40 ChannelMgr(ChannelMgr&& right) = delete;
41 ChannelMgr& operator=(ChannelMgr const& right) = delete;
42 ChannelMgr& operator=(ChannelMgr&& right) = delete;
43
44 static void LoadFromDB();
45 static ChannelMgr* ForTeam(uint32 team);
46 static Channel* GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher);
47 static Channel* GetChannelForPlayerByGuid(ObjectGuid channelGuid, Player* playerSearcher);
49
50 void SaveToDB();
51 Channel* GetSystemChannel(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr);
52 Channel* CreateCustomChannel(std::string const& name);
53 Channel* GetCustomChannel(std::string const& name) const;
54 Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool notify = true, AreaTableEntry const* zoneEntry = nullptr) const;
55 void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
56
57 private:
62
63 static void SendNotOnChannelNotify(Player const* player, std::string const& name);
64 ObjectGuid CreateCustomChannelGuid();
65 ObjectGuid CreateBuiltinChannelGuid(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr) const;
66};
67
68#endif
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
HighGuid
Definition: ObjectGuid.h:75
static void SaveToDB(QuestPool const &pool, CharacterDatabaseTransaction trans)
Definition: QuestPools.cpp:50
std::unordered_map< ObjectGuid, Channel * > BuiltinChannelContainer
Definition: ChannelMgr.h:32
CustomChannelContainer _customChannels
Definition: ChannelMgr.h:58
ChannelMgr & operator=(ChannelMgr &&right)=delete
static AreaTableEntry const * SpecialLinkedArea
Definition: ChannelMgr.h:48
std::unordered_map< std::wstring, Channel * > CustomChannelContainer
Definition: ChannelMgr.h:31
ObjectGuidGenerator _guidGenerator
Definition: ChannelMgr.h:61
uint32 const _team
Definition: ChannelMgr.h:60
ChannelMgr(ChannelMgr &&right)=delete
ChannelMgr(ChannelMgr const &right)=delete
ChannelMgr(uint32 team)
Definition: ChannelMgr.h:35
ChannelMgr & operator=(ChannelMgr const &right)=delete
BuiltinChannelContainer _channels
Definition: ChannelMgr.h:59