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

#include "BattlefieldMgr.h"

Public Types

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

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 _battlefieldSet
 
BattlefieldMap _battlefieldMap
 
uint32 _updateTimer
 

Detailed Description

Member Typedef Documentation

◆ BattlefieldMap

◆ BattlefieldSet

Constructor & Destructor Documentation

◆ BattlefieldMgr()

BattlefieldMgr::BattlefieldMgr ( )
22 : _updateTimer(0)
23{
24}
uint32 _updateTimer
Definition BattlefieldMgr.h:73

◆ ~BattlefieldMgr()

BattlefieldMgr::~BattlefieldMgr ( )
27{
29 delete bf;
30}
BattlefieldSet _battlefieldSet
Definition BattlefieldMgr.h:68
Definition Battlefield.h:208

References _battlefieldSet.

Member Function Documentation

◆ AddZone()

void BattlefieldMgr::AddZone ( uint32  zoneId,
Battlefield handle 
)
63{
64 _battlefieldMap[zoneId] = handle;
65}
BattlefieldMap _battlefieldMap
Definition BattlefieldMgr.h:71

References _battlefieldMap.

◆ CanTalkTo()

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

◆ GetBattlefieldByBattleId()

Battlefield * BattlefieldMgr::GetBattlefieldByBattleId ( uint32  battleId)
105{
106 for (Battlefield* bf : _battlefieldSet)
107 if (bf->GetBattleId() == battleId)
108 return bf;
109
110 return nullptr;
111}

References _battlefieldSet.

◆ GetBattlefieldToZoneId()

Battlefield * BattlefieldMgr::GetBattlefieldToZoneId ( uint32  zoneId)
94{
95 auto itr = _battlefieldMap.find(zoneId);
96 if (itr == _battlefieldMap.end())
97 return nullptr;
98
99 if (!itr->second->IsEnabled())
100 return nullptr;
101 return itr->second;
102}

References _battlefieldMap.

◆ GetZoneScript()

ZoneScript * BattlefieldMgr::GetZoneScript ( uint32  zoneId)
125{
126 auto itr = _battlefieldMap.find(zoneId);
127 if (itr != _battlefieldMap.end())
128 return itr->second;
129
130 return nullptr;
131}

References _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 
)
68{
69 auto itr = _battlefieldMap.find(zoneId);
70 if (itr == _battlefieldMap.end())
71 return;
72
73 if (itr->second->HasPlayer(player) || !itr->second->IsEnabled())
74 return;
75
76 itr->second->HandlePlayerEnterZone(player, zoneId);
77 LOG_DEBUG("bg.battlefield", "Player {} entered outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
78}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
std::string ToString() const
Definition ObjectGuid.cpp:47
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114

References _battlefieldMap, Object::GetGUID(), Battlefield::HandlePlayerEnterZone(), LOG_DEBUG, and ObjectGuid::ToString().

◆ HandlePlayerLeaveZone()

void BattlefieldMgr::HandlePlayerLeaveZone ( Player player,
uint32  areaflag 
)
81{
82 auto itr = _battlefieldMap.find(zoneId);
83 if (itr == _battlefieldMap.end())
84 return;
85
86 // teleport: remove once in removefromworld, once in updatezone
87 if (!itr->second->HasPlayer(player))
88 return;
89 itr->second->HandlePlayerLeaveZone(player, zoneId);
90 LOG_DEBUG("bg.battlefield", "Player {} left outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
91}

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

◆ HandlePlayerResurrects()

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

◆ InitBattlefield()

void BattlefieldMgr::InitBattlefield ( )
39{
40 if (sWorld->getIntConfig(CONFIG_WINTERGRASP_ENABLE) == 2)
41 {
42 LOG_INFO("server.loading", "Battlefield: Wintergrasp is disabled.");
43 LOG_INFO("server.loading", " ");
44 return;
45 }
46 Battlefield* bf = new BattlefieldWG;
47 // respawn, init variables
48 if (!bf->SetupBattlefield())
49 {
50 LOG_ERROR("server.loading", "Battlefield: Wintergrasp init failed.");
51 LOG_INFO("server.loading", " ");
52 delete bf;
53 }
54 else
55 {
56 _battlefieldSet.push_back(bf);
57 LOG_INFO("server.loading", "Battlefield: Wintergrasp successfully initiated.");
58 LOG_INFO("server.loading", " ");
59 }
60}
#define LOG_INFO(filterType__,...)
Definition Log.h:166
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
@ CONFIG_WINTERGRASP_ENABLE
Definition WorldConfig.h:284
Definition BattlefieldWG.h:253
virtual bool SetupBattlefield()
Call this to init the Battlefield.
Definition Battlefield.h:221
#define sWorld
Definition World.h:316

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

◆ instance()

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

References instance().

Referenced by instance().

◆ Update()

void BattlefieldMgr::Update ( uint32  diff)
114{
115 _updateTimer += diff;
117 {
118 for (Battlefield* bf : _battlefieldSet)
119 bf->Update(_updateTimer);
120 _updateTimer = 0;
121 }
122}
constexpr auto BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL
Definition Battlefield.h:57
void Update(uint32 diff)
Definition BattlefieldMgr.cpp:113

References _battlefieldSet, _updateTimer, BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL, and Battlefield::Update().

Member Data Documentation

◆ _battlefieldMap

◆ _battlefieldSet

BattlefieldSet BattlefieldMgr::_battlefieldSet
private

◆ _updateTimer

uint32 BattlefieldMgr::_updateTimer
private

Referenced by Update().


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