diff options
Diffstat (limited to 'src/server/shared/Realm')
| -rw-r--r-- | src/server/shared/Realm/RealmList.cpp | 42 | ||||
| -rw-r--r-- | src/server/shared/Realm/RealmList.h | 16 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index ec0a707eb61..a8d7dab9337 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -46,6 +46,7 @@ void RealmList::Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInt _updateTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext); _resolver = Trinity::make_unique<boost::asio::ip::tcp::resolver>(ioContext); + LoadBuildInfo(); // Get the content of the realmlist table in the database UpdateRealms(boost::system::error_code()); } @@ -55,6 +56,38 @@ void RealmList::Close() _updateTimer->cancel(); } +void RealmList::LoadBuildInfo() +{ + // 0 1 2 3 4 5 6 + if (QueryResult result = LoginDatabase.Query("SELECT majorVersion, minorVersion, bugfixVersion, hotfixVersion, build, winChecksumSeed, macChecksumSeed FROM build_info ORDER BY build ASC")) + { + do + { + Field* fields = result->Fetch(); + _builds.emplace_back(); + RealmBuildInfo& build = _builds.back(); + build.MajorVersion = fields[0].GetUInt32(); + build.MinorVersion = fields[1].GetUInt32(); + build.BugfixVersion = fields[2].GetUInt32(); + std::string hotfixVersion = fields[3].GetString(); + if (hotfixVersion.length() < build.HotfixVersion.size()) + std::copy(hotfixVersion.begin(), hotfixVersion.end(), build.HotfixVersion.begin()); + else + std::fill(hotfixVersion.begin(), hotfixVersion.end(), '\0'); + + build.Build = fields[4].GetUInt32(); + std::string windowsHash = fields[5].GetString(); + if (windowsHash.length() == build.WindowsHash.size() * 2) + HexStrToByteArray(windowsHash, build.WindowsHash.data()); + + std::string macHash = fields[6].GetString(); + if (macHash.length() == build.MacHash.size() * 2) + HexStrToByteArray(macHash, build.MacHash.data()); + + } while (result->NextRow()); + } +} + void RealmList::UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population) @@ -181,3 +214,12 @@ Realm const* RealmList::GetRealm(RealmHandle const& id) const return nullptr; } + +RealmBuildInfo const* RealmList::GetBuildInfo(uint32 build) const +{ + for (RealmBuildInfo const& clientBuild : _builds) + if (clientBuild.Build == build) + return &clientBuild; + + return nullptr; +} diff --git a/src/server/shared/Realm/RealmList.h b/src/server/shared/Realm/RealmList.h index 62f615c0cae..b7358afa35a 100644 --- a/src/server/shared/Realm/RealmList.h +++ b/src/server/shared/Realm/RealmList.h @@ -21,10 +21,22 @@ #include "Define.h" #include "Realm.h" +#include <array> #include <map> #include <vector> #include <unordered_set> +struct RealmBuildInfo +{ + uint32 Build; + uint32 MajorVersion; + uint32 MinorVersion; + uint32 BugfixVersion; + std::array<char, 4> HotfixVersion; + std::array<uint8, 20> WindowsHash; + std::array<uint8, 20> MacHash; +}; + namespace boost { namespace system @@ -58,14 +70,18 @@ public: RealmMap const& GetRealms() const { return _realms; } Realm const* GetRealm(RealmHandle const& id) const; + RealmBuildInfo const* GetBuildInfo(uint32 build) const; + private: RealmList(); + void LoadBuildInfo(); void UpdateRealms(boost::system::error_code const& error); void UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population); + std::vector<RealmBuildInfo> _builds; RealmMap _realms; uint32 _updateInterval; std::unique_ptr<Trinity::Asio::DeadlineTimer> _updateTimer; |
