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

#include <BattlefieldMgr.h>

Public Member Functions

void InitBattlefield ()
 
void HandlePlayerEnterZone (Player *player, uint32 zoneId)
 
void HandlePlayerLeaveZone (Player *player, uint32 zoneId)
 
BattlefieldGetBattlefieldToZoneId (uint32 zoneId)
 
BattlefieldGetBattlefieldByBattleId (uint32 battleId)
 
BattlefieldGetBattlefieldByQueueId (uint64 queueId)
 
ZoneScriptGetZoneScript (uint32 zoneId)
 
void AddZone (uint32 zoneId, Battlefield *bf)
 
void Update (uint32 diff)
 

Static Public Member Functions

static BattlefieldMgrinstance ()
 

Private Types

typedef std::vector
< Battlefield * > 
BattlefieldSet
 
typedef std::map< uint32,
Battlefield * > 
BattlefieldMap
 

Private Member Functions

 BattlefieldMgr ()
 
 ~BattlefieldMgr ()
 

Private Attributes

BattlefieldSet _battlefieldSet
 
BattlefieldMap _battlefieldMap
 
uint32 _updateTimer
 

Member Typedef Documentation

typedef std::map<uint32 , Battlefield*> BattlefieldMgr::BattlefieldMap
private
typedef std::vector<Battlefield*> BattlefieldMgr::BattlefieldSet
private

Constructor & Destructor Documentation

BattlefieldMgr::BattlefieldMgr ( )
private
23 {
24  _updateTimer = 0;
25 }
uint32 _updateTimer
Definition: BattlefieldMgr.h:64
BattlefieldMgr::~BattlefieldMgr ( )
private
28 {
29  for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
30  delete *itr;
31 
32  _battlefieldMap.clear();
33 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59

Member Function Documentation

void BattlefieldMgr::AddZone ( uint32  zoneId,
Battlefield bf 
)
74 {
75  _battlefieldMap[zoneId] = bf;
76 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
Battlefield * BattlefieldMgr::GetBattlefieldByBattleId ( uint32  battleId)
122 {
123  for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
124  {
125  if ((*itr)->GetBattleId() == battleId)
126  return *itr;
127  }
128  return NULL;
129 }
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59
arena_t NULL
Definition: jemalloc_internal.h:624
Battlefield * BattlefieldMgr::GetBattlefieldByQueueId ( uint64  queueId)
132 {
133  for (Battlefield* bf : _battlefieldSet)
134  if (bf->GetQueueId() == queueId)
135  return bf;
136 
137  return NULL;
138 }
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Battlefield.h:196
Battlefield * BattlefieldMgr::GetBattlefieldToZoneId ( uint32  zoneId)
107 {
108  BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
109  if (itr == _battlefieldMap.end())
110  {
111  // no handle for this zone, return
112  return NULL;
113  }
114 
115  if (!itr->second->IsEnabled())
116  return NULL;
117 
118  return itr->second;
119 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
arena_t NULL
Definition: jemalloc_internal.h:624
ZoneScript * BattlefieldMgr::GetZoneScript ( uint32  zoneId)
141 {
142  BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
143  if (itr != _battlefieldMap.end())
144  return itr->second;
145 
146  return NULL;
147 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
arena_t NULL
Definition: jemalloc_internal.h:624
void BattlefieldMgr::HandlePlayerEnterZone ( Player player,
uint32  zoneId 
)
79 {
80  BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
81  if (itr == _battlefieldMap.end())
82  return;
83 
84  Battlefield* bf = itr->second;
85  if (!bf->IsEnabled() || bf->HasPlayer(player))
86  return;
87 
88  bf->HandlePlayerEnterZone(player, zoneId);
89  TC_LOG_DEBUG("bg.battlefield", "%s entered battlefield id %u", player->GetGUID().ToString().c_str(), bf->GetTypeId());
90 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool HasPlayer(Player *player) const
Definition: Battlefield.cpp:353
Definition: Battlefield.h:196
uint32 GetTypeId() const
Definition: Battlefield.h:234
void HandlePlayerEnterZone(Player *player, uint32 zone)
Called when player (player) enter in zone.
Definition: Battlefield.cpp:72
bool IsEnabled() const
Return if battlefield is enable.
Definition: Battlefield.h:248

+ Here is the call graph for this function:

void BattlefieldMgr::HandlePlayerLeaveZone ( Player player,
uint32  zoneId 
)
93 {
94  BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
95  if (itr == _battlefieldMap.end())
96  return;
97 
98  // teleport: remove once in removefromworld, once in updatezone
99  if (!itr->second->HasPlayer(player))
100  return;
101 
102  itr->second->HandlePlayerLeaveZone(player, zoneId);
103  TC_LOG_DEBUG("bg.battlefield", "Player %s left battlefield id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
104 }
BattlefieldMap _battlefieldMap
Definition: BattlefieldMgr.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void BattlefieldMgr::InitBattlefield ( )
42 {
43  Battlefield* wg = new BattlefieldWG();
44  // respawn, init variables
45  if (!wg->SetupBattlefield())
46  {
47  TC_LOG_INFO("bg.battlefield", "Battlefield: Wintergrasp init failed.");
48  delete wg;
49  }
50  else
51  {
52  _battlefieldSet.push_back(wg);
53  TC_LOG_INFO("bg.battlefield", "Battlefield: Wintergrasp successfully initiated.");
54  }
55 
56  /*
57  For Cataclysm: Tol Barad
58  Battlefield* tb = new BattlefieldTB;
59  // respawn, init variables
60  if (!tb->SetupBattlefield())
61  {
62  TC_LOG_DEBUG("bg.battlefield", "Battlefield: Tol Barad init failed.");
63  delete tb;
64  }
65  else
66  {
67  _battlefieldSet.push_back(tb);
68  TC_LOG_DEBUG("bg.battlefield", "Battlefield: Tol Barad successfully initiated.");
69  }
70  */
71 }
virtual bool SetupBattlefield()
Call this to init the Battlefield.
Definition: Battlefield.h:210
Definition: BattlefieldWG.h:269
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59
Definition: Battlefield.h:196
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the call graph for this function:

BattlefieldMgr * BattlefieldMgr::instance ( )
static
36 {
37  static BattlefieldMgr instance;
38  return &instance;
39 }
Definition: BattlefieldMgr.h:27
static BattlefieldMgr * instance()
Definition: BattlefieldMgr.cpp:35
void BattlefieldMgr::Update ( uint32  diff)
150 {
151  _updateTimer += diff;
153  {
154  for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
155  if ((*itr)->IsEnabled())
156  (*itr)->Update(_updateTimer);
157  _updateTimer = 0;
158  }
159 }
BattlefieldSet _battlefieldSet
Definition: BattlefieldMgr.h:59
Definition: Battlefield.h:65
uint32 _updateTimer
Definition: BattlefieldMgr.h:64

Member Data Documentation

BattlefieldMap BattlefieldMgr::_battlefieldMap
private
BattlefieldSet BattlefieldMgr::_battlefieldSet
private
uint32 BattlefieldMgr::_updateTimer
private

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