AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
BattlefieldMgr Class Reference

#include "BattlefieldMgr.h"

Public Types

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

Public Member Functions

 BattlefieldMgr ()
 
 ~BattlefieldMgr ()
 
void InitBattlefield ()
 
void HandlePlayerEnterZone (Player *player, uint32 areaflag)
 
void HandlePlayerLeaveZone (Player *player, uint32 areaflag)
 
void HandlePlayerResurrects (Player *player, uint32 areaflag)
 
BattlefieldGetBattlefieldToZoneId (uint32 zoneid)
 
BattlefieldGetBattlefieldByBattleId (uint32 battleid)
 
ZoneScriptGetZoneScript (uint32 zoneId)
 
void AddZone (uint32 zoneid, Battlefield *handle)
 
void Update (uint32 diff)
 
void HandleGossipOption (Player *player, ObjectGuid guid, uint32 gossipid)
 
bool CanTalkTo (Player *player, Creature *creature, GossipMenuItems gso)
 
void HandleDropFlag (Player *player, uint32 spellId)
 

Static Public Member Functions

static BattlefieldMgrinstance ()
 

Private Attributes

BattlefieldSet m_BattlefieldSet
 
BattlefieldMap m_BattlefieldMap
 
uint32 m_UpdateTimer
 

Detailed Description

Member Typedef Documentation

◆ BattlefieldMap

◆ BattlefieldSet

Constructor & Destructor Documentation

◆ BattlefieldMgr()

BattlefieldMgr::BattlefieldMgr ( )
23{
24 m_UpdateTimer = 0;
25 //LOG_DEBUG("bg.battlefield", "Instantiating BattlefieldMgr");
26}
uint32 m_UpdateTimer
Definition: BattlefieldMgr.h:74

References m_UpdateTimer.

◆ ~BattlefieldMgr()

BattlefieldMgr::~BattlefieldMgr ( )
29{
30 //LOG_DEBUG("bg.battlefield", "Deleting BattlefieldMgr");
31 for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
32 delete *itr;
33}
BattlefieldSet m_BattlefieldSet
Definition: BattlefieldMgr.h:69

References m_BattlefieldSet.

Member Function Documentation

◆ AddZone()

void BattlefieldMgr::AddZone ( uint32  zoneid,
Battlefield handle 
)
80{
81 m_BattlefieldMap[zoneid] = handle;
82}
BattlefieldMap m_BattlefieldMap
Definition: BattlefieldMgr.h:72

References m_BattlefieldMap.

◆ CanTalkTo()

bool BattlefieldMgr::CanTalkTo ( Player player,
Creature creature,
GossipMenuItems  gso 
)

◆ GetBattlefieldByBattleId()

Battlefield * BattlefieldMgr::GetBattlefieldByBattleId ( uint32  battleid)
124{
125 for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
126 {
127 if ((*itr)->GetBattleId() == battleid)
128 return (*itr);
129 }
130 return nullptr;
131}

References m_BattlefieldSet.

◆ GetBattlefieldToZoneId()

Battlefield * BattlefieldMgr::GetBattlefieldToZoneId ( uint32  zoneid)
111{
112 BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
113 if (itr == m_BattlefieldMap.end())
114 {
115 // no handle for this zone, return
116 return nullptr;
117 }
118 if (!itr->second->IsEnabled())
119 return nullptr;
120 return itr->second;
121}

References m_BattlefieldMap.

◆ GetZoneScript()

ZoneScript * BattlefieldMgr::GetZoneScript ( uint32  zoneId)
146{
147 BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneId);
148 if (itr != m_BattlefieldMap.end())
149 return itr->second;
150 else
151 return nullptr;
152}

References m_BattlefieldMap.

◆ HandleDropFlag()

void BattlefieldMgr::HandleDropFlag ( Player player,
uint32  spellId 
)

◆ HandleGossipOption()

void BattlefieldMgr::HandleGossipOption ( Player player,
ObjectGuid  guid,
uint32  gossipid 
)

◆ HandlePlayerEnterZone()

void BattlefieldMgr::HandlePlayerEnterZone ( Player player,
uint32  areaflag 
)
85{
86 BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
87 if (itr == m_BattlefieldMap.end())
88 return;
89
90 if (itr->second->HasPlayer(player) || !itr->second->IsEnabled())
91 return;
92
93 itr->second->HandlePlayerEnterZone(player, zoneid);
94 LOG_DEBUG("bg.battlefield", "Player {} entered outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
95}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
std::string ToString() const
Definition: ObjectGuid.cpp:47

References Object::GetGUID(), LOG_DEBUG, m_BattlefieldMap, and ObjectGuid::ToString().

◆ HandlePlayerLeaveZone()

void BattlefieldMgr::HandlePlayerLeaveZone ( Player player,
uint32  areaflag 
)
98{
99 BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
100 if (itr == m_BattlefieldMap.end())
101 return;
102
103 // teleport: remove once in removefromworld, once in updatezone
104 if (!itr->second->HasPlayer(player))
105 return;
106 itr->second->HandlePlayerLeaveZone(player, zoneid);
107 LOG_DEBUG("bg.battlefield", "Player {} left outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
108}

References Object::GetGUID(), LOG_DEBUG, m_BattlefieldMap, and ObjectGuid::ToString().

◆ HandlePlayerResurrects()

void BattlefieldMgr::HandlePlayerResurrects ( Player player,
uint32  areaflag 
)

◆ InitBattlefield()

void BattlefieldMgr::InitBattlefield ( )
42{
43 if (sWorld->getIntConfig(CONFIG_WINTERGRASP_ENABLE) == 2)
44 {
45 LOG_INFO("server.loading", "Battlefield: Wintergrasp is disabled.");
46 LOG_INFO("server.loading", " ");
47 return;
48 }
49 Battlefield* pBf = new BattlefieldWG;
50 // respawn, init variables
51 if (!pBf->SetupBattlefield())
52 {
53 LOG_ERROR("server.loading", "Battlefield: Wintergrasp init failed.");
54 LOG_INFO("server.loading", " ");
55 delete pBf;
56 }
57 else
58 {
59 m_BattlefieldSet.push_back(pBf);
60 LOG_INFO("server.loading", "Battlefield: Wintergrasp successfully initiated.");
61 LOG_INFO("server.loading", " ");
62 }
63
64 /* For Cataclysm: Tol Barad
65 pBf = new BattlefieldTB;
66 // respawn, init variables
67 if(!pBf->SetupBattlefield())
68 {
69 LOG_DEBUG("bg.battlefield", "Battlefield : Tol Barad init failed.");
70 delete pBf;
71 }
72 else
73 {
74 m_BattlefieldSet.push_back(pBf);
75 LOG_DEBUG("bg.battlefield", "Battlefield : Tol Barad successfully initiated.");
76 } */
77}
#define LOG_INFO(filterType__,...)
Definition: Log.h:167
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
@ CONFIG_WINTERGRASP_ENABLE
Definition: IWorld.h:319
#define sWorld
Definition: World.h:451
Definition: Battlefield.h:205
virtual bool SetupBattlefield()
Call this to init the Battlefield.
Definition: Battlefield.h:218
Definition: BattlefieldWG.h:277

References CONFIG_WINTERGRASP_ENABLE, LOG_ERROR, LOG_INFO, m_BattlefieldSet, Battlefield::SetupBattlefield(), and sWorld.

◆ instance()

BattlefieldMgr * BattlefieldMgr::instance ( )
static
36{
38 return &instance;
39}
Definition: BattlefieldMgr.h:31
static BattlefieldMgr * instance()
Definition: BattlefieldMgr.cpp:35

References instance().

Referenced by instance().

◆ Update()

void BattlefieldMgr::Update ( uint32  diff)
134{
135 m_UpdateTimer += diff;
137 {
138 for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
139 //if ((*itr)->IsEnabled())
140 (*itr)->Update(m_UpdateTimer);
141 m_UpdateTimer = 0;
142 }
143}
constexpr auto BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL
Definition: Battlefield.h:58

References BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL, m_BattlefieldSet, and m_UpdateTimer.

Member Data Documentation

◆ m_BattlefieldMap

◆ m_BattlefieldSet

BattlefieldSet BattlefieldMgr::m_BattlefieldSet
private

◆ m_UpdateTimer

uint32 BattlefieldMgr::m_UpdateTimer
private

Referenced by BattlefieldMgr(), and Update().