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 __TRINITY_CHANNELMGR_H
18#define __TRINITY_CHANNELMGR_H
19
20#include "Define.h"
21#include "Hash.h"
22#include <string>
23#include <unordered_map>
24
25class Channel;
26class Player;
27class WorldPacket;
28struct AreaTableEntry;
29
31{
32 typedef std::unordered_map<std::wstring, Channel*> CustomChannelContainer; // custom channels only differ in name
33 typedef std::unordered_map<std::pair<uint32 /*channelId*/, uint32 /*zoneId*/>, Channel*> BuiltinChannelContainer; //identify builtin (DBC) channels by zoneId instead, since name changes by client locale
34
35 protected:
36 explicit ChannelMgr(uint32 team) : _team(team) { }
38
39 public:
40 static void LoadFromDB();
41 static ChannelMgr* forTeam(uint32 team);
42 static Channel* GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher);
43
44 void SaveToDB();
45 Channel* GetSystemChannel(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr);
46 Channel* CreateCustomChannel(std::string const& name);
47 Channel* GetCustomChannel(std::string const& name) const;
48 Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool pkt = true, AreaTableEntry const* zoneEntry = nullptr) const;
49 void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
50
51 private:
55
56 static void MakeNotOnPacket(WorldPacket* data, std::string const& name);
57};
58
59#endif
#define TC_GAME_API
Definition Define.h:114
uint32_t uint32
Definition Define.h:133
static void SaveToDB(QuestPool const &pool, CharacterDatabaseTransaction trans)
CustomChannelContainer _customChannels
Definition ChannelMgr.h:52
std::unordered_map< std::wstring, Channel * > CustomChannelContainer
Definition ChannelMgr.h:32
uint32 const _team
Definition ChannelMgr.h:54
ChannelMgr(uint32 team)
Definition ChannelMgr.h:36
std::unordered_map< std::pair< uint32, uint32 >, Channel * > BuiltinChannelContainer
Definition ChannelMgr.h:33
BuiltinChannelContainer _channels
Definition ChannelMgr.h:53