TrinityCore
OutdoorPvPMgr Class Reference

#include <OutdoorPvPMgr.h>

Public Member Functions

void InitOutdoorPvP ()
 
void Die ()
 
void HandlePlayerEnterZone (Player *player, uint32 areaflag)
 
void HandlePlayerLeaveZone (Player *player, uint32 areaflag)
 
void HandlePlayerResurrects (Player *player, uint32 areaflag)
 
OutdoorPvPGetOutdoorPvPToZoneId (uint32 zoneid)
 
bool HandleCustomSpell (Player *player, uint32 spellId, GameObject *go)
 
bool HandleOpenGo (Player *player, GameObject *go)
 
ZoneScriptGetZoneScript (uint32 zoneId)
 
void AddZone (uint32 zoneid, OutdoorPvP *handle)
 
void Update (uint32 diff)
 
void HandleGossipOption (Player *player, Creature *creature, uint32 gossipid)
 
bool CanTalkTo (Player *player, Creature *creature, GossipMenuItems const &gso)
 
void HandleDropFlag (Player *player, uint32 spellId)
 
std::string GetDefenseMessage (uint32 zoneId, uint32 id, LocaleConstant locale) const
 

Static Public Member Functions

static OutdoorPvPMgrinstance ()
 

Private Types

typedef std::vector< OutdoorPvP * > OutdoorPvPSet
 
typedef std::unordered_map< uint32, OutdoorPvP * > OutdoorPvPMap
 
typedef std::array< uint32, MAX_OUTDOORPVP_TYPESOutdoorPvPScriptIds
 

Private Member Functions

 OutdoorPvPMgr ()
 
 ~OutdoorPvPMgr ()
 

Private Attributes

OutdoorPvPSet m_OutdoorPvPSet
 
OutdoorPvPMap m_OutdoorPvPMap
 
OutdoorPvPScriptIds m_OutdoorPvPDatas
 
uint32 m_UpdateTimer
 

Member Typedef Documentation

◆ OutdoorPvPMap

typedef std::unordered_map<uint32 , OutdoorPvP*> OutdoorPvPMgr::OutdoorPvPMap
private

◆ OutdoorPvPScriptIds

◆ OutdoorPvPSet

typedef std::vector<OutdoorPvP*> OutdoorPvPMgr::OutdoorPvPSet
private

Constructor & Destructor Documentation

◆ OutdoorPvPMgr()

OutdoorPvPMgr::OutdoorPvPMgr ( )
private
28 {
29  m_UpdateTimer = 0;
30 }
uint32 m_UpdateTimer
Definition: OutdoorPvPMgr.h:99

◆ ~OutdoorPvPMgr()

OutdoorPvPMgr::~OutdoorPvPMgr ( )
inlineprivate
39 { };

Member Function Documentation

◆ AddZone()

void OutdoorPvPMgr::AddZone ( uint32  zoneid,
OutdoorPvP handle 
)
117 {
118  m_OutdoorPvPMap[zoneid] = handle;
119 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93

◆ CanTalkTo()

bool OutdoorPvPMgr::CanTalkTo ( Player player,
Creature creature,
GossipMenuItems const &  gso 
)
209 {
210  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
211  {
212  if ((*itr)->CanTalkTo(player, creature, gso))
213  return true;
214  }
215  return false;
216 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
+ Here is the caller graph for this function:

◆ Die()

void OutdoorPvPMgr::Die ( )
33 {
34  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
35  delete *itr;
36 
37  m_OutdoorPvPSet.clear();
38 
39  m_OutdoorPvPDatas.fill(0);
40 
41  m_OutdoorPvPMap.clear();
42 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93
OutdoorPvPScriptIds m_OutdoorPvPDatas
Definition: OutdoorPvPMgr.h:96

◆ GetDefenseMessage()

std::string OutdoorPvPMgr::GetDefenseMessage ( uint32  zoneId,
uint32  id,
LocaleConstant  locale 
) const
238 {
239  if (BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(id))
240  return DB2Manager::GetBroadcastTextValue(bct, locale);
241 
242  TC_LOG_ERROR("outdoorpvp", "Can not find DefenseMessage (Zone: %u, Id: %u). BroadcastText (Id: %u) does not exist.", zoneId, id, id);
243  return "";
244 }
static char const * GetBroadcastTextValue(BroadcastTextEntry const *broadcastText, LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false)
Definition: DB2Stores.cpp:1829
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Definition: DB2Structure.h:518
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", BroadcastTextLoadInfo::Instance())
+ Here is the call graph for this function:

◆ GetOutdoorPvPToZoneId()

OutdoorPvP * OutdoorPvPMgr::GetOutdoorPvPToZoneId ( uint32  zoneid)
149 {
150  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
151  if (itr == m_OutdoorPvPMap.end())
152  {
153  // no handle for this zone, return
154  return nullptr;
155  }
156  return itr->second;
157 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93

◆ GetZoneScript()

ZoneScript * OutdoorPvPMgr::GetZoneScript ( uint32  zoneId)
181 {
182  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneId);
183  if (itr != m_OutdoorPvPMap.end())
184  return itr->second;
185  else
186  return nullptr;
187 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93

◆ HandleCustomSpell()

bool OutdoorPvPMgr::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
171 {
172  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
173  {
174  if ((*itr)->HandleCustomSpell(player, spellId, go))
175  return true;
176  }
177  return false;
178 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
+ Here is the caller graph for this function:

◆ HandleDropFlag()

void OutdoorPvPMgr::HandleDropFlag ( Player player,
uint32  spellId 
)
219 {
220  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
221  {
222  if ((*itr)->HandleDropFlag(player, spellId))
223  return;
224  }
225 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
+ Here is the caller graph for this function:

◆ HandleGossipOption()

void OutdoorPvPMgr::HandleGossipOption ( Player player,
Creature creature,
uint32  gossipid 
)
200 {
201  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
202  {
203  if ((*itr)->HandleGossipOption(player, creature, gossipid))
204  return;
205  }
206 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
+ Here is the caller graph for this function:

◆ HandleOpenGo()

bool OutdoorPvPMgr::HandleOpenGo ( Player player,
GameObject go 
)
190 {
191  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
192  {
193  if ((*itr)->HandleOpenGo(player, go))
194  return true;
195  }
196  return false;
197 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
+ Here is the caller graph for this function:

◆ HandlePlayerEnterZone()

void OutdoorPvPMgr::HandlePlayerEnterZone ( Player player,
uint32  areaflag 
)
122 {
123  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
124  if (itr == m_OutdoorPvPMap.end())
125  return;
126 
127  if (itr->second->HasPlayer(player))
128  return;
129 
130  itr->second->HandlePlayerEnterZone(player, zoneid);
131  TC_LOG_DEBUG("outdoorpvp", "%s entered outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
132 }
std::string ToString() const
Definition: ObjectGuid.cpp:238
ObjectGuid const & GetGUID() const
Definition: Object.h:154
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlePlayerLeaveZone()

void OutdoorPvPMgr::HandlePlayerLeaveZone ( Player player,
uint32  areaflag 
)
135 {
136  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
137  if (itr == m_OutdoorPvPMap.end())
138  return;
139 
140  // teleport: remove once in removefromworld, once in updatezone
141  if (!itr->second->HasPlayer(player))
142  return;
143 
144  itr->second->HandlePlayerLeaveZone(player, zoneid);
145  TC_LOG_DEBUG("outdoorpvp", "%s left outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
146 }
std::string ToString() const
Definition: ObjectGuid.cpp:238
ObjectGuid const & GetGUID() const
Definition: Object.h:154
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:177
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlePlayerResurrects()

void OutdoorPvPMgr::HandlePlayerResurrects ( Player player,
uint32  areaflag 
)
228 {
229  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
230  if (itr == m_OutdoorPvPMap.end())
231  return;
232 
233  if (itr->second->HasPlayer(player))
234  itr->second->HandlePlayerResurrects(player, zoneid);
235 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:93
+ Here is the caller graph for this function:

◆ InitOutdoorPvP()

void OutdoorPvPMgr::InitOutdoorPvP ( )
51 {
52  uint32 oldMSTime = getMSTime();
53 
54  // 0 1
55  QueryResult result = WorldDatabase.Query("SELECT TypeId, ScriptName FROM outdoorpvp_template");
56  if (!result)
57  {
58  TC_LOG_INFO("server.loading", ">> Loaded 0 outdoor PvP definitions. DB table `outdoorpvp_template` is empty.");
59  return;
60  }
61 
62  uint32 count = 0;
63  uint32 typeId = 0;
64 
65  do
66  {
67  Field* fields = result->Fetch();
68 
69  typeId = fields[0].GetUInt8();
70 
72  continue;
73 
74  if (typeId >= MAX_OUTDOORPVP_TYPES)
75  {
76  TC_LOG_ERROR("sql.sql", "Invalid OutdoorPvPTypes value %u in outdoorpvp_template; skipped.", typeId);
77  continue;
78  }
79 
80  OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
81  m_OutdoorPvPDatas[realTypeId] = sObjectMgr->GetScriptId(fields[1].GetString());
82 
83  ++count;
84  }
85  while (result->NextRow());
86 
87  OutdoorPvP* pvp;
88  for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
89  {
90  if (!m_OutdoorPvPDatas[i])
91  {
92  TC_LOG_ERROR("sql.sql", "Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(i));
93  continue;
94  }
95 
96  pvp = sScriptMgr->CreateOutdoorPvP(m_OutdoorPvPDatas[i]);
97  if (!pvp)
98  {
99  TC_LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(i));
100  continue;
101  }
102 
103  if (!pvp->SetupOutdoorPvP())
104  {
105  TC_LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID %u; SetupOutdoorPvP failed.", uint32(i));
106  delete pvp;
107  continue;
108  }
109 
110  m_OutdoorPvPSet.push_back(pvp);
111  }
112 
113  TC_LOG_INFO("server.loading", ">> Loaded %u outdoor PvP definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
114 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
Class used to access individual fields of database query result.
Definition: Field.h:81
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
uint32 getMSTime()
Definition: Timer.h:24
#define sObjectMgr
Definition: ObjectMgr.h:1847
Definition: OutdoorPvP.h:35
OutdoorPvPTypes
Definition: OutdoorPvP.h:27
uint32_t uint32
Definition: Define.h:152
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:180
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
Definition: OutdoorPvP.h:184
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
uint8 GetUInt8() const
Definition: Field.cpp:33
uint8_t uint8
Definition: Define.h:154
virtual bool SetupOutdoorPvP()
Definition: OutdoorPvP.h:213
bool IsDisabledFor(DisableType type, uint32 entry, WorldObject const *ref, uint8 flags)
Definition: DisableMgr.cpp:275
#define sScriptMgr
Definition: ScriptMgr.h:1221
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: DisableMgr.h:32
OutdoorPvPScriptIds m_OutdoorPvPDatas
Definition: OutdoorPvPMgr.h:96
+ Here is the call graph for this function:

◆ instance()

OutdoorPvPMgr * OutdoorPvPMgr::instance ( )
static
45 {
46  static OutdoorPvPMgr instance;
47  return &instance;
48 }
Definition: OutdoorPvPMgr.h:35
static OutdoorPvPMgr * instance()
Definition: OutdoorPvPMgr.cpp:44

◆ Update()

void OutdoorPvPMgr::Update ( uint32  diff)
160 {
161  m_UpdateTimer += diff;
163  {
164  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
165  (*itr)->Update(m_UpdateTimer);
166  m_UpdateTimer = 0;
167  }
168 }
uint32 m_UpdateTimer
Definition: OutdoorPvPMgr.h:99
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:89
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_OutdoorPvPDatas

OutdoorPvPScriptIds OutdoorPvPMgr::m_OutdoorPvPDatas
private

◆ m_OutdoorPvPMap

OutdoorPvPMap OutdoorPvPMgr::m_OutdoorPvPMap
private

◆ m_OutdoorPvPSet

OutdoorPvPSet OutdoorPvPMgr::m_OutdoorPvPSet
private

◆ m_UpdateTimer

uint32 OutdoorPvPMgr::m_UpdateTimer
private

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