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)
 
bool IsWintergraspAttackerVictory ()
 
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 ( )
23 : _updateTimer(0)
24{
25}
uint32 _updateTimer
Definition BattlefieldMgr.h:76

◆ ~BattlefieldMgr()

BattlefieldMgr::~BattlefieldMgr ( )
28{
30 delete bf;
31}
BattlefieldSet _battlefieldSet
Definition BattlefieldMgr.h:71
Definition Battlefield.h:196

References _battlefieldSet.

Member Function Documentation

◆ AddZone()

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

References _battlefieldMap.

◆ CanTalkTo()

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

◆ GetBattlefieldByBattleId()

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

References _battlefieldSet.

Referenced by IsWintergraspAttackerVictory().

◆ GetBattlefieldToZoneId()

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

References _battlefieldMap.

◆ GetZoneScript()

ZoneScript * BattlefieldMgr::GetZoneScript ( uint32  zoneId)
134{
135 auto itr = _battlefieldMap.find(zoneId);
136 if (itr != _battlefieldMap.end())
137 return itr->second;
138
139 return nullptr;
140}

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 
)
69{
70 auto itr = _battlefieldMap.find(zoneId);
71 if (itr == _battlefieldMap.end())
72 return;
73
74 if (itr->second->HasPlayer(player) || !itr->second->IsEnabled())
75 return;
76
77 itr->second->HandlePlayerEnterZone(player, zoneId);
78 LOG_DEBUG("bg.battlefield", "Player {} entered outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
79}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
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 
)
82{
83 auto itr = _battlefieldMap.find(zoneId);
84 if (itr == _battlefieldMap.end())
85 return;
86
87 // teleport: remove once in removefromworld, once in updatezone
88 if (!itr->second->HasPlayer(player))
89 return;
90 sScriptMgr->OnBattlefieldPlayerLeaveZone(itr->second, player);
91 itr->second->HandlePlayerLeaveZone(player, zoneId);
92 LOG_DEBUG("bg.battlefield", "Player {} left outdoorpvp id {}", player->GetGUID().ToString(), itr->second->GetTypeId());
93}
#define sScriptMgr
Definition ScriptMgr.h:740

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

◆ HandlePlayerResurrects()

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

◆ InitBattlefield()

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

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

◆ instance()

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

References instance().

Referenced by instance().

◆ IsWintergraspAttackerVictory()

bool BattlefieldMgr::IsWintergraspAttackerVictory ( )
116{
118 return static_cast<BattlefieldWG*>(bf)->IsLastBattleAttackerVictory();
119 return false;
120}
@ BATTLEFIELD_BATTLEID_WG
Definition Battlefield.h:36
Battlefield * GetBattlefieldByBattleId(uint32 battleId)
Definition BattlefieldMgr.cpp:106

References BATTLEFIELD_BATTLEID_WG, and GetBattlefieldByBattleId().

◆ Update()

void BattlefieldMgr::Update ( uint32  diff)
123{
124 _updateTimer += diff;
126 {
127 for (Battlefield* bf : _battlefieldSet)
128 bf->Update(_updateTimer);
129 _updateTimer = 0;
130 }
131}
constexpr auto BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL
Definition Battlefield.h:57
void Update(uint32 diff)
Definition BattlefieldMgr.cpp:122

References _battlefieldSet, _updateTimer, BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL, and BattlefieldWG::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: