TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ChannelMgr Class Reference

#include <ChannelMgr.h>

Public Member Functions

void SetTeam (uint32 newTeam)
 
ChannelGetJoinChannel (std::string const &name, uint32 channelId)
 
ChannelGetChannel (std::string const &name, Player *player, bool notify=true)
 
void LeftChannel (std::string const &name)
 

Static Public Member Functions

static ChannelMgrForTeam (uint32 team)
 

Protected Member Functions

 ChannelMgr ()
 
 ~ChannelMgr ()
 

Private Types

typedef std::map< std::wstring,
Channel * > 
ChannelMap
 

Static Private Member Functions

static void SendNotOnChannelNotify (Player const *player, std::string const &name)
 

Private Attributes

ChannelMap _channels
 
uint32 _team
 

Member Typedef Documentation

typedef std::map<std::wstring, Channel*> ChannelMgr::ChannelMap
private

Constructor & Destructor Documentation

ChannelMgr::ChannelMgr ( )
inlineprotected
32 : _team(0) { }
uint32 _team
Definition: ChannelMgr.h:45
ChannelMgr::~ChannelMgr ( )
protected
25 {
26  for (ChannelMap::iterator itr = _channels.begin(); itr != _channels.end(); ++itr)
27  delete itr->second;
28 }
ChannelMap _channels
Definition: ChannelMgr.h:44

Member Function Documentation

ChannelMgr * ChannelMgr::ForTeam ( uint32  team)
static
31 {
32  static ChannelMgr allianceChannelMgr;
33  static ChannelMgr hordeChannelMgr;
35  return &allianceChannelMgr; // cross-faction
36 
37  if (team == ALLIANCE)
38  return &allianceChannelMgr;
39 
40  if (team == HORDE)
41  return &hordeChannelMgr;
42 
43  return nullptr;
44 }
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:1000
Definition: SharedDefines.h:999
Definition: ChannelMgr.h:27

+ Here is the caller graph for this function:

Channel * ChannelMgr::GetChannel ( std::string const name,
Player player,
bool  notify = true 
)
66 {
67  std::wstring wname;
68  if (!Utf8toWStr(name, wname))
69  return nullptr;
70 
71  wstrToLower(wname);
72 
73  ChannelMap::const_iterator i = _channels.find(wname);
74  if (i == _channels.end())
75  {
76  if (notify)
77  SendNotOnChannelNotify(player, name);
78 
79  return nullptr;
80  }
81 
82  return i->second;
83 }
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
static void SendNotOnChannelNotify(Player const *player, std::string const &name)
Definition: ChannelMgr.cpp:106
ChannelMap _channels
Definition: ChannelMgr.h:44

+ Here is the call graph for this function:

Channel * ChannelMgr::GetJoinChannel ( std::string const name,
uint32  channelId 
)
47 {
48  std::wstring wname;
49  if (!Utf8toWStr(name, wname))
50  return nullptr;
51 
52  wstrToLower(wname);
53 
54  ChannelMap::const_iterator i = _channels.find(wname);
55  if (i == _channels.end())
56  {
57  Channel* nchan = new Channel(name, channelId, _team);
58  _channels[wname] = nchan;
59  return nchan;
60  }
61 
62  return i->second;
63 }
uint32 _team
Definition: ChannelMgr.h:45
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: Channel.h:126
ChannelMap _channels
Definition: ChannelMgr.h:44

+ Here is the call graph for this function:

void ChannelMgr::LeftChannel ( std::string const name)
86 {
87  std::wstring wname;
88  if (!Utf8toWStr(name, wname))
89  return;
90 
91  wstrToLower(wname);
92 
93  ChannelMap::const_iterator i = _channels.find(wname);
94  if (i == _channels.end())
95  return;
96 
97  Channel* channel = i->second;
98 
99  if (!channel->GetNumPlayers() && !channel->IsConstant())
100  {
101  _channels.erase(i);
102  delete channel;
103  }
104 }
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: Channel.h:126
uint32 GetNumPlayers() const
Definition: Channel.h:179
bool IsConstant() const
Definition: Channel.h:173
ChannelMap _channels
Definition: ChannelMgr.h:44

+ Here is the call graph for this function:

void ChannelMgr::SendNotOnChannelNotify ( Player const player,
std::string const name 
)
staticprivate
107 {
109  notify.Type = CHAT_NOT_MEMBER_NOTICE;
110  notify._Channel = name;
111  player->SendDirectMessage(notify.Write());
112 }
WorldPacket const * Write() override
Definition: ChannelPackets.cpp:38
Definition: ChannelPackets.h:52
Definition: Channel.h:45
std::string _Channel
Channel Name.
Definition: ChannelPackets.h:65
uint8 Type
Definition: ChannelPackets.h:62

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ChannelMgr::SetTeam ( uint32  newTeam)
inline
37 { _team = newTeam; }
uint32 _team
Definition: ChannelMgr.h:45

Member Data Documentation

ChannelMap ChannelMgr::_channels
private
uint32 ChannelMgr::_team
private

The documentation for this class was generated from the following files: