summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/acore/game-framework/src/Addons/AddonMgr.cpp38
-rw-r--r--modules/acore/game-framework/src/Addons/AddonMgr.h12
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