TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AddonMgr Namespace Reference

Typedefs

typedef std::list< BannedAddonBannedAddonList
 

Functions

void LoadFromDB ()
 
void SaveAddon (AddonInfo const &addon)
 
SavedAddon constGetAddonInfo (const std::string &name)
 
BannedAddonList constGetBannedAddons ()
 

Typedef Documentation

Function Documentation

SavedAddon const * AddonMgr::GetAddonInfo ( const std::string &  name)
113 {
114  for (SavedAddonsList::const_iterator it = m_knownAddons.begin(); it != m_knownAddons.end(); ++it)
115  {
116  SavedAddon const& addon = (*it);
117  if (addon.Name == name)
118  return &addon;
119  }
120 
121  return NULL;
122 }
Definition: AddonMgr.h:40
arena_t NULL
Definition: jemalloc_internal.h:624
std::string Name
Definition: AddonMgr.h:47

+ Here is the caller graph for this function:

BannedAddonList const * AddonMgr::GetBannedAddons ( )
125 {
126  return &m_bannedAddons;
127 }

+ Here is the caller graph for this function:

void AddonMgr::LoadFromDB ( )
41 {
42  uint32 oldMSTime = getMSTime();
43 
44  QueryResult result = CharacterDatabase.Query("SELECT name, crc FROM addons");
45  if (result)
46  {
47  uint32 count = 0;
48 
49  do
50  {
51  Field* fields = result->Fetch();
52 
53  std::string name = fields[0].GetString();
54  uint32 crc = fields[1].GetUInt32();
55 
56  m_knownAddons.push_back(SavedAddon(name, crc));
57 
58  ++count;
59  }
60  while (result->NextRow());
61 
62  TC_LOG_INFO("server.loading", ">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
63  }
64  else
65  TC_LOG_INFO("server.loading", ">> Loaded 0 known addons. DB table `addons` is empty!");
66 
67  oldMSTime = getMSTime();
68  result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons");
69  if (result)
70  {
71  uint32 count = 0;
72  uint32 dbcMaxBannedAddon = sBannedAddOnsStore.GetNumRows();
73 
74  do
75  {
76  Field* fields = result->Fetch();
77 
78  BannedAddon addon;
79  addon.Id = fields[0].GetUInt32() + dbcMaxBannedAddon;
80  addon.Timestamp = uint32(fields[3].GetUInt64());
81 
82  std::string name = fields[1].GetString();
83  std::string version = fields[2].GetString();
84 
85  MD5(reinterpret_cast<uint8 const*>(name.c_str()), name.length(), addon.NameMD5);
86  MD5(reinterpret_cast<uint8 const*>(version.c_str()), version.length(), addon.VersionMD5);
87 
88  m_bannedAddons.push_back(addon);
89 
90  ++count;
91  }
92  while (result->NextRow());
93 
94  TC_LOG_INFO("server.loading", ">> Loaded %u banned addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
95  }
96 }
uint8 VersionMD5[MD5_DIGEST_LENGTH]
Definition: AddonMgr.h:55
Definition: AddonMgr.h:40
uint32 Timestamp
Definition: AddonMgr.h:56
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 getMSTime()
Definition: Timer.h:24
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint8 NameMD5[MD5_DIGEST_LENGTH]
Definition: AddonMgr.h:54
uint32 GetUInt32() const
Definition: Field.h:146
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
uint32_t uint32
Definition: g3dmath.h:168
DBCStorage< BannedAddOnsEntry > sBannedAddOnsStore(BannedAddOnsfmt)
uint32 Id
Definition: AddonMgr.h:53
std::string GetString() const
Definition: Field.h:276
Definition: AddonMgr.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AddonMgr::SaveAddon ( AddonInfo const addon)
99 {
100  std::string name = addon.Name;
101 
103 
104  stmt->setString(0, name);
105  stmt->setUInt32(1, addon.CRC);
106 
108 
109  m_knownAddons.push_back(SavedAddon(addon.Name, addon.CRC));
110 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: AddonMgr.h:40
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: CharacterDatabase.h:349
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function: