AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AddonMgr Namespace Reference

Namespaces

namespace  anonymous_namespace{AddonMgr.cpp}
 

Typedefs

typedef std::list< BannedAddonBannedAddonList
 

Functions

void LoadFromDB ()
 
void SaveAddon (AddonInfo const &addon)
 
SavedAddon const * GetAddonInfo (const std::string &name)
 
BannedAddonList const * GetBannedAddons ()
 

Typedef Documentation

◆ BannedAddonList

Function Documentation

◆ GetAddonInfo()

SavedAddon const * AddonMgr::GetAddonInfo ( const std::string &  name)
108 {
109 for (auto const& addon : m_knownAddons)
110 {
111 if (addon.Name == name)
112 {
113 return &addon;
114 }
115 }
116
117 return nullptr;
118 }

Referenced by WorldSession::ReadAddonsInfo().

◆ GetBannedAddons()

BannedAddonList const * AddonMgr::GetBannedAddons ( )
121 {
122 return &m_bannedAddons;
123 }

Referenced by WorldSession::SendAddonsInfo().

◆ LoadFromDB()

void AddonMgr::LoadFromDB ( )
40 {
41 uint32 oldMSTime = getMSTime();
42
43 QueryResult result = CharacterDatabase.Query("SELECT name, crc FROM addons");
44 if (!result)
45 {
46 LOG_WARN("server.loading", ">> Loaded 0 known addons. DB table `addons` is empty!");
47 LOG_INFO("server.loading", " ");
48 return;
49 }
50
51 uint32 count = 0;
52
53 do
54 {
55 Field* fields = result->Fetch();
56
57 std::string name = fields[0].Get<std::string>();
58 uint32 crc = fields[1].Get<uint32>();
59
60 m_knownAddons.emplace_back(name, crc);
61
62 ++count;
63 } while (result->NextRow());
64
65 LOG_INFO("server.loading", ">> Loaded {} known addons in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
66 LOG_INFO("server.loading", " ");
67
68 oldMSTime = getMSTime();
69 result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons");
70
71 if (result)
72 {
73 uint32 count2 = 0;
74 uint32 offset = 102;
75
76 do
77 {
78 Field* fields = result->Fetch();
79
80 uint32 Id = fields[0].Get<uint32>() + offset;
81 std::array<uint8, 16> NameMD5 = Acore::Crypto::MD5::GetDigestOf(fields[1].Get<std::string>());
82 std::array<uint8, 16> VersionMD5 = Acore::Crypto::MD5::GetDigestOf(fields[2].Get<std::string>());
83 uint32 Timestamp = uint32(fields[3].Get<uint64>());
84
85 m_bannedAddons.emplace_back(Id, NameMD5, VersionMD5, Timestamp);
86
87 ++count2;
88 } while (result->NextRow());
89
90 LOG_INFO("server.loading", ">> Loaded {} banned addons in {} ms", count2, GetMSTimeDiffToNow(oldMSTime));
91 LOG_INFO("server.loading", " ");
92 }
93 }
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::uint32_t uint32
Definition: Define.h:107
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:27
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
BannedAddonList m_bannedAddons
Definition: AddonMgr.cpp:36
static Digest GetDigestOf(uint8 const *data, std::size_t len)
Definition: CryptoHash.h:48
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112

References CharacterDatabase, Field::Get(), Acore::Impl::GenericHash< HashCreator, DigestLength >::GetDigestOf(), getMSTime(), GetMSTimeDiffToNow(), LOG_INFO, and LOG_WARN.

Referenced by World::SetInitialWorldSettings().

◆ SaveAddon()

void AddonMgr::SaveAddon ( AddonInfo const &  addon)
96 {
98
99 stmt->SetData(0, addon.Name);
100 stmt->SetData(1, addon.CRC);
101
102 CharacterDatabase.Execute(stmt);
103
104 m_knownAddons.emplace_back(addon.Name, addon.CRC);
105 }
@ CHAR_INS_ADDON
Definition: CharacterDatabase.h:299
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77

References CHAR_INS_ADDON, CharacterDatabase, AddonInfo::CRC, AddonInfo::Name, and PreparedStatementBase::SetData().

Referenced by WorldSession::ReadAddonsInfo().