aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver/Server/BattlenetManager.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-05-02 02:55:10 +0200
committerShauren <shauren.trinity@gmail.com>2014-05-02 02:55:10 +0200
commit6955d7c9ad0e55480aa97d9cafd878c6bc3dc426 (patch)
tree2a0b11c84a75607ac9db4c6f0d2382d7157230a7 /src/server/authserver/Server/BattlenetManager.cpp
parentfea9d275fa0ed8f5b43dc54979cdd5a58afc993b (diff)
Core/Battle.net
* Fixed AuthResult codes * Fixed BitStream::WriteBytes size check * Fixed comparison operator for packet header * Fixed channel for client packets without channel * Implemented loading modules from database
Diffstat (limited to 'src/server/authserver/Server/BattlenetManager.cpp')
-rw-r--r--src/server/authserver/Server/BattlenetManager.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/server/authserver/Server/BattlenetManager.cpp b/src/server/authserver/Server/BattlenetManager.cpp
index b7df889809e..a43512e612e 100644
--- a/src/server/authserver/Server/BattlenetManager.cpp
+++ b/src/server/authserver/Server/BattlenetManager.cpp
@@ -18,6 +18,15 @@
#include "BattlenetManager.h"
#include "DatabaseEnv.h"
+BattlenetMgr::~BattlenetMgr()
+{
+ for (Battlenet::Component* component : _components)
+ delete component;
+
+ for (auto const& m : _modules)
+ delete m.second;
+}
+
void BattlenetMgr::Load()
{
LoadComponents();
@@ -40,7 +49,6 @@ void BattlenetMgr::LoadComponents()
_components.insert(component);
_programs.insert(component->Program);
_platforms.insert(component->Platform);
- _builds.insert(component->Build);
} while (result->NextRow());
}
@@ -48,7 +56,27 @@ void BattlenetMgr::LoadComponents()
void BattlenetMgr::LoadModules()
{
+ QueryResult result = LoginDatabase.Query("SELECT `Hash`, `Name`, `Type`, `System`, `Data` FROM battlenet_modules");
+ if (result)
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ Battlenet::ModuleInfo* module = new Battlenet::ModuleInfo();
+ module->Type = fields[2].GetString();
+ module->Region.assign("\0\0EU", 4);
+ HexStrToByteArray(fields[0].GetString(), module->ModuleId);
+ std::string data = fields[4].GetString();
+ module->DataSize = data.length() / 2;
+ if (module->DataSize)
+ {
+ module->Data = new uint8[data.length() / 2];
+ HexStrToByteArray(data, module->Data);
+ }
+ _modules[{ fields[3].GetString(), fields[1].GetString() }] = module;
+ } while (result->NextRow());
+ }
}
bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const
@@ -59,3 +87,11 @@ bool BattlenetMgr::HasComponent(Battlenet::Component const* component) const
return false;
}
+
+Battlenet::ModuleInfo const* BattlenetMgr::GetModule(Battlenet::ModuleKey const& key) const
+{
+ if (_modules.count(key))
+ return _modules.at(key);
+
+ return NULL;
+}