TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ArenaTeamMgr Class Reference

#include <ArenaTeamMgr.h>

Public Types

typedef std::unordered_map
< uint32, ArenaTeam * > 
ArenaTeamContainer
 

Public Member Functions

ArenaTeamGetArenaTeamById (uint32 arenaTeamId) const
 
ArenaTeamGetArenaTeamByName (std::string const &arenaTeamName) const
 
ArenaTeamGetArenaTeamByCaptain (ObjectGuid guid) const
 
void LoadArenaTeams ()
 
void AddArenaTeam (ArenaTeam *arenaTeam)
 
void RemoveArenaTeam (uint32 Id)
 
ArenaTeamContainer::iterator GetArenaTeamMapBegin ()
 
ArenaTeamContainer::iterator GetArenaTeamMapEnd ()
 
uint32 GenerateArenaTeamId ()
 
void SetNextArenaTeamId (uint32 Id)
 

Static Public Member Functions

static ArenaTeamMgrinstance ()
 

Protected Attributes

uint32 NextArenaTeamId
 
ArenaTeamContainer ArenaTeamStore
 

Private Member Functions

 ArenaTeamMgr ()
 
 ~ArenaTeamMgr ()
 

Member Typedef Documentation

typedef std::unordered_map<uint32, ArenaTeam*> ArenaTeamMgr::ArenaTeamContainer

Constructor & Destructor Documentation

ArenaTeamMgr::ArenaTeamMgr ( )
private
26 {
27  NextArenaTeamId = 1;
28 }
uint32 NextArenaTeamId
Definition: ArenaTeamMgr.h:49
ArenaTeamMgr::~ArenaTeamMgr ( )
private
31 {
32  for (ArenaTeamContainer::iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
33  delete itr->second;
34 }
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50

Member Function Documentation

void ArenaTeamMgr::AddArenaTeam ( ArenaTeam arenaTeam)
76 {
77  ArenaTeamStore[arenaTeam->GetId()] = arenaTeam;
78 }
uint32 GetId() const
Definition: ArenaTeam.h:124
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 ArenaTeamMgr::GenerateArenaTeamId ( )
86 {
87  if (NextArenaTeamId >= 0xFFFFFFFE)
88  {
89  TC_LOG_ERROR("bg.battleground", "Arena team ids overflow!! Can't continue, shutting down server. ");
91  }
92  return NextArenaTeamId++;
93 }
uint32 NextArenaTeamId
Definition: ArenaTeamMgr.h:49
Definition: World.h:74
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
static void StopNow(uint8 exitcode)
Definition: World.h:662

+ Here is the call graph for this function:

ArenaTeam * ArenaTeamMgr::GetArenaTeamByCaptain ( ObjectGuid  guid) const
67 {
68  for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
69  if (itr->second->GetCaptain() == guid)
70  return itr->second;
71 
72  return NULL;
73 }
arena_t NULL
Definition: jemalloc_internal.h:624
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50
ArenaTeam * ArenaTeamMgr::GetArenaTeamById ( uint32  arenaTeamId) const
44 {
45  ArenaTeamContainer::const_iterator itr = ArenaTeamStore.find(arenaTeamId);
46  if (itr != ArenaTeamStore.end())
47  return itr->second;
48 
49  return NULL;
50 }
arena_t NULL
Definition: jemalloc_internal.h:624
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50
ArenaTeam * ArenaTeamMgr::GetArenaTeamByName ( std::string const arenaTeamName) const
53 {
54  std::string search = arenaTeamName;
55  std::transform(search.begin(), search.end(), search.begin(), ::toupper);
56  for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
57  {
58  std::string teamName = itr->second->GetName();
59  std::transform(teamName.begin(), teamName.end(), teamName.begin(), ::toupper);
60  if (search == teamName)
61  return itr->second;
62  }
63  return NULL;
64 }
arena_t NULL
Definition: jemalloc_internal.h:624
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50

+ Here is the call graph for this function:

ArenaTeamContainer::iterator ArenaTeamMgr::GetArenaTeamMapBegin ( )
inline
42 { return ArenaTeamStore.begin(); }
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50
ArenaTeamContainer::iterator ArenaTeamMgr::GetArenaTeamMapEnd ( )
inline
43 { return ArenaTeamStore.end(); }
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50
ArenaTeamMgr * ArenaTeamMgr::instance ( )
static
37 {
38  static ArenaTeamMgr instance;
39  return &instance;
40 }
static ArenaTeamMgr * instance()
Definition: ArenaTeamMgr.cpp:36
Definition: ArenaTeamMgr.h:23
void ArenaTeamMgr::LoadArenaTeams ( )
96 {
97  uint32 oldMSTime = getMSTime();
98 
99  // Clean out the trash before loading anything
100  CharacterDatabase.Execute("DELETE FROM arena_team_member WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team)"); // One-time query
101 
102  // 0 1 2 3 4 5 6 7 8
103  QueryResult result = CharacterDatabase.Query("SELECT arenaTeamId, name, captainGuid, type, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor, "
104  // 9 10 11 12 13 14
105  "rating, weekGames, weekWins, seasonGames, seasonWins, rank FROM arena_team ORDER BY arenaTeamId ASC");
106 
107  if (!result)
108  {
109  TC_LOG_INFO("server.loading", ">> Loaded 0 arena teams. DB table `arena_team` is empty!");
110  return;
111  }
112 
114  // 0 1 2 3 4 5 6 7 8 9
115  "SELECT arenaTeamId, atm.guid, atm.weekGames, atm.weekWins, atm.seasonGames, atm.seasonWins, c.name, class, personalRating, matchMakerRating FROM arena_team_member atm"
116  " INNER JOIN arena_team ate USING (arenaTeamId)"
117  " LEFT JOIN characters AS c ON atm.guid = c.guid"
118  " LEFT JOIN character_arena_stats AS cas ON c.guid = cas.guid AND (cas.slot = 0 AND ate.type = 2 OR cas.slot = 1 AND ate.type = 3 OR cas.slot = 2 AND ate.type = 5)"
119  " ORDER BY atm.arenateamid ASC");
120 
121  uint32 count = 0;
122  do
123  {
124  ArenaTeam* newArenaTeam = new ArenaTeam;
125 
126  if (!newArenaTeam->LoadArenaTeamFromDB(result) || !newArenaTeam->LoadMembersFromDB(result2))
127  {
128  newArenaTeam->Disband(NULL);
129  delete newArenaTeam;
130  continue;
131  }
132 
133  AddArenaTeam(newArenaTeam);
134 
135  ++count;
136  }
137  while (result->NextRow());
138 
139  TC_LOG_INFO("server.loading", ">> Loaded %u arena teams in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
140 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void Disband(WorldSession *session)
Definition: ArenaTeam.cpp:336
bool LoadMembersFromDB(QueryResult arenaTeamMembersResult)
Definition: ArenaTeam.cpp:206
uint32 getMSTime()
Definition: Timer.h:24
arena_t NULL
Definition: jemalloc_internal.h:624
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
void AddArenaTeam(ArenaTeam *arenaTeam)
Definition: ArenaTeamMgr.cpp:75
Definition: ArenaTeam.h:112
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
bool LoadArenaTeamFromDB(QueryResult arenaTeamDataResult)
Definition: ArenaTeam.cpp:180
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the call graph for this function:

void ArenaTeamMgr::RemoveArenaTeam ( uint32  Id)
81 {
82  ArenaTeamStore.erase(arenaTeamId);
83 }
ArenaTeamContainer ArenaTeamStore
Definition: ArenaTeamMgr.h:50
void ArenaTeamMgr::SetNextArenaTeamId ( uint32  Id)
inline
46 { NextArenaTeamId = Id; }
uint32 NextArenaTeamId
Definition: ArenaTeamMgr.h:49

Member Data Documentation

ArenaTeamContainer ArenaTeamMgr::ArenaTeamStore
protected
uint32 ArenaTeamMgr::NextArenaTeamId
protected

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