TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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::map< uint32,
OutdoorPvP * > 
OutdoorPvPMap
 
typedef std::map
< OutdoorPvPTypes,
OutdoorPvPData * > 
OutdoorPvPDataMap
 

Private Member Functions

 OutdoorPvPMgr ()
 
 ~OutdoorPvPMgr ()
 

Private Attributes

OutdoorPvPSet m_OutdoorPvPSet
 
OutdoorPvPMap m_OutdoorPvPMap
 
OutdoorPvPDataMap m_OutdoorPvPDatas
 
uint32 m_UpdateTimer
 

Member Typedef Documentation

typedef std::map<uint32 , OutdoorPvP*> OutdoorPvPMgr::OutdoorPvPMap
private
typedef std::vector<OutdoorPvP*> OutdoorPvPMgr::OutdoorPvPSet
private

Constructor & Destructor Documentation

OutdoorPvPMgr::OutdoorPvPMgr ( )
private
25 {
26  m_UpdateTimer = 0;
27  //TC_LOG_DEBUG("outdoorpvp", "Instantiating OutdoorPvPMgr");
28 }
uint32 m_UpdateTimer
Definition: OutdoorPvPMgr.h:102
OutdoorPvPMgr::~OutdoorPvPMgr ( )
inlineprivate
42 { };

Member Function Documentation

void OutdoorPvPMgr::AddZone ( uint32  zoneid,
OutdoorPvP handle 
)
118 {
119  m_OutdoorPvPMap[zoneid] = handle;
120 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
bool OutdoorPvPMgr::CanTalkTo ( Player player,
Creature creature,
GossipMenuItems const gso 
)
210 {
211  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
212  {
213  if ((*itr)->CanTalkTo(player, creature, gso))
214  return true;
215  }
216  return false;
217 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
void OutdoorPvPMgr::Die ( )
31 {
32  //TC_LOG_DEBUG("outdoorpvp", "Deleting OutdoorPvPMgr");
33  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
34  delete *itr;
35 
36  for (OutdoorPvPDataMap::iterator itr = m_OutdoorPvPDatas.begin(); itr != m_OutdoorPvPDatas.end(); ++itr)
37  delete itr->second;
38 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
OutdoorPvPDataMap m_OutdoorPvPDatas
Definition: OutdoorPvPMgr.h:99
std::string OutdoorPvPMgr::GetDefenseMessage ( uint32  zoneId,
uint32  id,
LocaleConstant  locale 
) const
239 {
240  if (BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(id))
241  return DB2Manager::GetBroadcastTextValue(bct, locale);
242 
243  TC_LOG_ERROR("outdoorpvp", "Can not find DefenseMessage (Zone: %u, Id: %u). BroadcastText (Id: %u) does not exist.", zoneId, id, id);
244  return "";
245 }
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", BroadcastTextFormat, HOTFIX_SEL_BROADCAST_TEXT)
static char const * GetBroadcastTextValue(BroadcastTextEntry const *broadcastText, LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false)
Definition: DB2Stores.cpp:610
Definition: DB2Structure.h:112
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

OutdoorPvP * OutdoorPvPMgr::GetOutdoorPvPToZoneId ( uint32  zoneid)
150 {
151  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
152  if (itr == m_OutdoorPvPMap.end())
153  {
154  // no handle for this zone, return
155  return NULL;
156  }
157  return itr->second;
158 }
arena_t NULL
Definition: jemalloc_internal.h:624
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
ZoneScript * OutdoorPvPMgr::GetZoneScript ( uint32  zoneId)
182 {
183  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneId);
184  if (itr != m_OutdoorPvPMap.end())
185  return itr->second;
186  else
187  return NULL;
188 }
arena_t NULL
Definition: jemalloc_internal.h:624
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
bool OutdoorPvPMgr::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
172 {
173  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
174  {
175  if ((*itr)->HandleCustomSpell(player, spellId, go))
176  return true;
177  }
178  return false;
179 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
void OutdoorPvPMgr::HandleDropFlag ( Player player,
uint32  spellId 
)
220 {
221  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
222  {
223  if ((*itr)->HandleDropFlag(player, spellId))
224  return;
225  }
226 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
void OutdoorPvPMgr::HandleGossipOption ( Player player,
Creature creature,
uint32  gossipid 
)
201 {
202  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
203  {
204  if ((*itr)->HandleGossipOption(player, creature, gossipid))
205  return;
206  }
207 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
bool OutdoorPvPMgr::HandleOpenGo ( Player player,
GameObject go 
)
191 {
192  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
193  {
194  if ((*itr)->HandleOpenGo(player, go))
195  return true;
196  }
197  return false;
198 }
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
void OutdoorPvPMgr::HandlePlayerEnterZone ( Player player,
uint32  areaflag 
)
123 {
124  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
125  if (itr == m_OutdoorPvPMap.end())
126  return;
127 
128  if (itr->second->HasPlayer(player))
129  return;
130 
131  itr->second->HandlePlayerEnterZone(player, zoneid);
132  TC_LOG_DEBUG("outdoorpvp", "%s entered outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
133 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
void OutdoorPvPMgr::HandlePlayerLeaveZone ( Player player,
uint32  areaflag 
)
136 {
137  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
138  if (itr == m_OutdoorPvPMap.end())
139  return;
140 
141  // teleport: remove once in removefromworld, once in updatezone
142  if (!itr->second->HasPlayer(player))
143  return;
144 
145  itr->second->HandlePlayerLeaveZone(player, zoneid);
146  TC_LOG_DEBUG("outdoorpvp", "%s left outdoorpvp id %u", player->GetGUID().ToString().c_str(), itr->second->GetTypeId());
147 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
void OutdoorPvPMgr::HandlePlayerResurrects ( Player player,
uint32  areaflag 
)
229 {
230  OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
231  if (itr == m_OutdoorPvPMap.end())
232  return;
233 
234  if (itr->second->HasPlayer(player))
235  itr->second->HandlePlayerResurrects(player, zoneid);
236 }
OutdoorPvPMap m_OutdoorPvPMap
Definition: OutdoorPvPMgr.h:96
void OutdoorPvPMgr::InitOutdoorPvP ( )
47 {
48  uint32 oldMSTime = getMSTime();
49 
50  // 0 1
51  QueryResult result = WorldDatabase.Query("SELECT TypeId, ScriptName FROM outdoorpvp_template");
52 
53  if (!result)
54  {
55  TC_LOG_ERROR("server.loading", ">> Loaded 0 outdoor PvP definitions. DB table `outdoorpvp_template` is empty.");
56  return;
57  }
58 
59  uint32 count = 0;
60  uint32 typeId = 0;
61 
62  do
63  {
64  Field* fields = result->Fetch();
65 
66  typeId = fields[0].GetUInt8();
67 
69  continue;
70 
71  if (typeId >= MAX_OUTDOORPVP_TYPES)
72  {
73  TC_LOG_ERROR("sql.sql", "Invalid OutdoorPvPTypes value %u in outdoorpvp_template; skipped.", typeId);
74  continue;
75  }
76 
77  OutdoorPvPData* data = new OutdoorPvPData();
78  OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
79  data->TypeId = realTypeId;
80  data->ScriptId = sObjectMgr->GetScriptId(fields[1].GetString());
81  m_OutdoorPvPDatas[realTypeId] = data;
82 
83  ++count;
84  }
85  while (result->NextRow());
86 
87  OutdoorPvP* pvp;
88  for (uint8 i = 1; i < MAX_OUTDOORPVP_TYPES; ++i)
89  {
90  OutdoorPvPDataMap::iterator iter = m_OutdoorPvPDatas.find(OutdoorPvPTypes(i));
91  if (iter == m_OutdoorPvPDatas.end())
92  {
93  TC_LOG_ERROR("sql.sql", "Could not initialize OutdoorPvP object for type ID %u; no entry in database.", uint32(i));
94  continue;
95  }
96 
97  pvp = sScriptMgr->CreateOutdoorPvP(iter->second);
98  if (!pvp)
99  {
100  TC_LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID %u; got NULL pointer from script.", uint32(i));
101  continue;
102  }
103 
104  if (!pvp->SetupOutdoorPvP())
105  {
106  TC_LOG_ERROR("outdoorpvp", "Could not initialize OutdoorPvP object for type ID %u; SetupOutdoorPvP failed.", uint32(i));
107  delete pvp;
108  continue;
109  }
110 
111  m_OutdoorPvPSet.push_back(pvp);
112  }
113 
114  TC_LOG_INFO("server.loading", ">> Loaded %u outdoor PvP definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
115 }
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 getMSTime()
Definition: Timer.h:24
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: OutdoorPvPMgr.h:31
#define sObjectMgr
Definition: ObjectMgr.h:1567
OutdoorPvPDataMap m_OutdoorPvPDatas
Definition: OutdoorPvPMgr.h:99
uint8 GetUInt8() const
Definition: Field.h:70
OutdoorPvPTypes TypeId
Definition: OutdoorPvPMgr.h:33
#define MAX_OUTDOORPVP_TYPES
Definition: OutdoorPvP.h:37
OutdoorPvPTypes
Definition: OutdoorPvP.h:28
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
Definition: OutdoorPvP.h:188
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint8_t uint8
Definition: Define.h:152
virtual bool SetupOutdoorPvP()
Definition: OutdoorPvP.h:217
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: DisableMgr.h:34
uint32_t uint32
Definition: g3dmath.h:168
uint32 ScriptId
Definition: OutdoorPvPMgr.h:34

+ Here is the call graph for this function:

OutdoorPvPMgr * OutdoorPvPMgr::instance ( )
static
41 {
42  static OutdoorPvPMgr instance;
43  return &instance;
44 }
Definition: OutdoorPvPMgr.h:38
static OutdoorPvPMgr * instance()
Definition: OutdoorPvPMgr.cpp:40
void OutdoorPvPMgr::Update ( uint32  diff)
161 {
162  m_UpdateTimer += diff;
164  {
165  for (OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
166  (*itr)->Update(m_UpdateTimer);
167  m_UpdateTimer = 0;
168  }
169 }
uint32 m_UpdateTimer
Definition: OutdoorPvPMgr.h:102
OutdoorPvPSet m_OutdoorPvPSet
Definition: OutdoorPvPMgr.h:92
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21

Member Data Documentation

OutdoorPvPDataMap OutdoorPvPMgr::m_OutdoorPvPDatas
private
OutdoorPvPMap OutdoorPvPMgr::m_OutdoorPvPMap
private
OutdoorPvPSet OutdoorPvPMgr::m_OutdoorPvPSet
private
uint32 OutdoorPvPMgr::m_UpdateTimer
private

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