aboutsummaryrefslogtreecommitdiff
path: root/src/game/ChannelMgr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ChannelMgr.h')
-rw-r--r--src/game/ChannelMgr.h73
1 files changed, 12 insertions, 61 deletions
diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h
index 956309e9873..f65a8520648 100644
--- a/src/game/ChannelMgr.h
+++ b/src/game/ChannelMgr.h
@@ -17,8 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef TRINITYCORE_CHANNELMGR_H
-#define TRINITYCORE_CHANNELMGR_H
+#ifndef MANGOSSERVER_CHANNELMGR_H
+#define MANGOSSERVER_CHANNELMGR_H
+
+#include "Common.h"
+#include "Channel.h"
+#include "Policies/Singleton.h"
#include <map>
#include <string>
@@ -34,73 +38,20 @@ class ChannelMgr
uint32 team;
typedef std::map<std::string,Channel *> ChannelMap;
ChannelMgr() {team = 0;}
- ~ChannelMgr()
- {
- for(ChannelMap::const_iterator itr = channels.begin();itr!=channels.end(); ++itr)
- delete itr->second;
- channels.clear();
- }
- Channel *GetJoinChannel(const std::string& name, uint32 channel_id)
- {
- if (channels.find(name) == channels.end())
- {
- Channel *nchan = new Channel(name,channel_id, team);
- channels[name] = nchan;
- }
- return channels[name];
- }
- Channel *GetChannel(const std::string& name, Player *p)
- {
- ChannelMap::const_iterator i = channels.find(name);
-
- if(i == channels.end())
- {
- WorldPacket data;
- MakeNotOnPacket(&data,name);
- p->GetSession()->SendPacket(&data);
- return NULL;
- }
- else
- return i->second;
- }
- void LeftChannel(const std::string& name)
- {
- ChannelMap::const_iterator i = channels.find(name);
+ ~ChannelMgr();
- if(i == channels.end())
- return;
-
- Channel* channel = i->second;
-
- if(channel->GetNumPlayers() == 0 && !channel->IsConstant())
- {
- channels.erase(name);
- delete channel;
- }
- }
+ Channel *GetJoinChannel(std::string name, uint32 channel_id);
+ Channel *GetChannel(std::string name, Player *p, bool pkt = true);
+ void LeftChannel(std::string name);
private:
ChannelMap channels;
- void MakeNotOnPacket(WorldPacket *data, const std::string& name)
- {
- data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size
- (*data) << (uint8)0x05 << name;
- }
+ void MakeNotOnPacket(WorldPacket *data, std::string name);
};
class AllianceChannelMgr : public ChannelMgr {};
class HordeChannelMgr : public ChannelMgr {};
-inline ChannelMgr* channelMgr(uint32 team)
-{
- if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
- //For Test,No Seprate Faction
- return &Trinity::Singleton<AllianceChannelMgr>::Instance();
+ChannelMgr* channelMgr(uint32 team);
- if(team==ALLIANCE)
- return &Trinity::Singleton<AllianceChannelMgr>::Instance();
- if(team==HORDE)
- return &Trinity::Singleton<HordeChannelMgr>::Instance();
- return NULL;
-}
#endif