diff options
author | Yehonal <yehonal.azeroth@gmail.com> | 2017-09-18 03:17:54 +0200 |
---|---|---|
committer | Yehonal <yehonal.azeroth@gmail.com> | 2017-09-18 03:17:54 +0200 |
commit | 627f8412d1ef03b83a9c66155cb3cdb2b59a871c (patch) | |
tree | 5a9dfd0bc345658f9328f762d42ceba2e5cbaa1b /modules | |
parent | bea6f6b9fb9c9a4cb1a86e2bd6124c272ce52a10 (diff) | |
parent | 2c9b2542d6f63332b89f650c3cc083b33f04574b (diff) |
Merge branch 'master' of https://github.com/azerothcore/azerothcore-wotlk
Diffstat (limited to 'modules')
-rw-r--r-- | modules/acore/game-framework/src/Addons/AddonMgr.cpp | 38 | ||||
-rw-r--r-- | modules/acore/game-framework/src/Addons/AddonMgr.h | 12 |
2 files changed, 49 insertions, 1 deletions
diff --git a/modules/acore/game-framework/src/Addons/AddonMgr.cpp b/modules/acore/game-framework/src/Addons/AddonMgr.cpp index 7951e9815a..a8bcdc875e 100644 --- a/modules/acore/game-framework/src/Addons/AddonMgr.cpp +++ b/modules/acore/game-framework/src/Addons/AddonMgr.cpp @@ -10,6 +10,7 @@ #include "Timer.h" #include <list> +#include <openssl/md5.h> namespace AddonMgr { @@ -22,6 +23,7 @@ namespace typedef std::list<SavedAddon> SavedAddonsList; SavedAddonsList m_knownAddons; + BannedAddonList m_bannedAddons; } void LoadFromDB() @@ -52,7 +54,36 @@ void LoadFromDB() while (result->NextRow()); sLog->outString(">> Loaded %u known addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); - sLog->outString(); + + oldMSTime = getMSTime(); + result = CharacterDatabase.Query("SELECT id, name, version, UNIX_TIMESTAMP(timestamp) FROM banned_addons"); + if (result) + { + uint32 count = 0; + uint32 offset = 102; + + do + { + Field* fields = result->Fetch(); + + BannedAddon addon; + addon.Id = fields[0].GetUInt32() + offset; + addon.Timestamp = uint32(fields[3].GetUInt64()); + + std::string name = fields[1].GetString(); + std::string version = fields[2].GetString(); + + MD5(reinterpret_cast<uint8 const*>(name.c_str()), name.length(), addon.NameMD5); + MD5(reinterpret_cast<uint8 const*>(version.c_str()), version.length(), addon.VersionMD5); + + m_bannedAddons.push_back(addon); + + ++count; + } while (result->NextRow()); + + sLog->outString(">> Loaded %u banned addons in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(); + } } void SaveAddon(AddonInfo const& addon) @@ -81,4 +112,9 @@ SavedAddon const* GetAddonInfo(const std::string& name) return NULL; } +BannedAddonList const* GetBannedAddons() +{ + return &m_bannedAddons; +} + } // Namespace diff --git a/modules/acore/game-framework/src/Addons/AddonMgr.h b/modules/acore/game-framework/src/Addons/AddonMgr.h index 04f190891f..24113ff8a5 100644 --- a/modules/acore/game-framework/src/Addons/AddonMgr.h +++ b/modules/acore/game-framework/src/Addons/AddonMgr.h @@ -9,6 +9,7 @@ #include "Define.h" #include <string> +#include <list> struct AddonInfo { @@ -33,6 +34,14 @@ struct SavedAddon uint32 CRC; }; +struct BannedAddon +{ + uint32 Id; + uint8 NameMD5[16]; + uint8 VersionMD5[16]; + uint32 Timestamp; +}; + #define STANDARD_ADDON_CRC 0x4c1c776d namespace AddonMgr @@ -40,6 +49,9 @@ namespace AddonMgr void LoadFromDB(); void SaveAddon(AddonInfo const& addon); SavedAddon const* GetAddonInfo(const std::string& name); + + typedef std::list<BannedAddon> BannedAddonList; + BannedAddonList const* GetBannedAddons(); } #endif |