mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 20:02:25 +01:00
Core/Shared: Include cleanup
This commit is contained in:
@@ -52,9 +52,11 @@
|
||||
#include <openssl/crypto.h>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <csignal>
|
||||
|
||||
using namespace boost::program_options;
|
||||
namespace fs = boost::filesystem;
|
||||
@@ -107,7 +109,7 @@ void StopDB();
|
||||
void WorldUpdateLoop();
|
||||
void ClearOnlineAccounts();
|
||||
void ShutdownCLIThread(std::thread* cliThread);
|
||||
bool LoadRealmInfo(boost::asio::io_service& ioService);
|
||||
bool LoadRealmInfo();
|
||||
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& cfg_service);
|
||||
|
||||
/// Launch the Trinity server
|
||||
@@ -226,7 +228,7 @@ extern int main(int argc, char** argv)
|
||||
|
||||
std::shared_ptr<void> sRealmListHandle(nullptr, [](void*) { sRealmList->Close(); });
|
||||
|
||||
LoadRealmInfo(*ioService);
|
||||
LoadRealmInfo();
|
||||
|
||||
sMetric->Initialize(realm.Name, *ioService, []()
|
||||
{
|
||||
@@ -509,59 +511,26 @@ AsyncAcceptor* StartRaSocketAcceptor(boost::asio::io_service& ioService)
|
||||
return acceptor;
|
||||
}
|
||||
|
||||
bool LoadRealmInfo(boost::asio::io_service& ioService)
|
||||
bool LoadRealmInfo()
|
||||
{
|
||||
boost::asio::ip::tcp::resolver resolver(ioService);
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
|
||||
QueryResult result = LoginDatabase.PQuery("SELECT id, name, address, localAddress, localSubnetMask, port, icon, flag, timezone, allowedSecurityLevel, population, gamebuild, Region, Battlegroup FROM realmlist WHERE id = %u", realm.Id.Realm);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
realm.Name = fields[1].GetString();
|
||||
boost::asio::ip::tcp::resolver::query externalAddressQuery(ip::tcp::v4(), fields[2].GetString(), "");
|
||||
|
||||
boost::system::error_code ec;
|
||||
boost::asio::ip::tcp::resolver::iterator endPoint = resolver.resolve(externalAddressQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
if (Realm const* realmListRealm = sRealmList->GetRealm(realm.Id))
|
||||
{
|
||||
TC_LOG_ERROR("server.worldserver", "Could not resolve address %s", fields[2].GetString().c_str());
|
||||
return false;
|
||||
realm.Id = realmListRealm->Id;
|
||||
realm.Build = realmListRealm->Build;
|
||||
realm.ExternalAddress = Trinity::make_unique<boost::asio::ip::address>(*realmListRealm->ExternalAddress);
|
||||
realm.LocalAddress = Trinity::make_unique<boost::asio::ip::address>(*realmListRealm->LocalAddress);
|
||||
realm.LocalSubnetMask = Trinity::make_unique<boost::asio::ip::address>(*realmListRealm->LocalSubnetMask);
|
||||
realm.Port = realmListRealm->Port;
|
||||
realm.Name = realmListRealm->Name;
|
||||
realm.Type = realmListRealm->Type;
|
||||
realm.Flags = realmListRealm->Flags;
|
||||
realm.Timezone = realmListRealm->Timezone;
|
||||
realm.AllowedSecurityLevel = realmListRealm->AllowedSecurityLevel;
|
||||
realm.PopulationLevel = realmListRealm->PopulationLevel;
|
||||
return true;
|
||||
}
|
||||
|
||||
realm.ExternalAddress = (*endPoint).endpoint().address();
|
||||
|
||||
boost::asio::ip::tcp::resolver::query localAddressQuery(ip::tcp::v4(), fields[3].GetString(), "");
|
||||
endPoint = resolver.resolve(localAddressQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
{
|
||||
TC_LOG_ERROR("server.worldserver", "Could not resolve address %s", fields[3].GetString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
realm.LocalAddress = (*endPoint).endpoint().address();
|
||||
|
||||
boost::asio::ip::tcp::resolver::query localSubmaskQuery(ip::tcp::v4(), fields[4].GetString(), "");
|
||||
endPoint = resolver.resolve(localSubmaskQuery, ec);
|
||||
if (endPoint == end || ec)
|
||||
{
|
||||
TC_LOG_ERROR("server.worldserver", "Could not resolve address %s", fields[4].GetString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
realm.LocalSubnetMask = (*endPoint).endpoint().address();
|
||||
|
||||
realm.Port = fields[5].GetUInt16();
|
||||
realm.Type = fields[6].GetUInt8();
|
||||
realm.Flags = RealmFlags(fields[7].GetUInt8());
|
||||
realm.Timezone = fields[8].GetUInt8();
|
||||
realm.AllowedSecurityLevel = AccountTypes(fields[9].GetUInt8());
|
||||
realm.PopulationLevel = fields[10].GetFloat();
|
||||
realm.Id.Region = fields[12].GetUInt8();
|
||||
realm.Id.Site = fields[13].GetUInt8();
|
||||
realm.Build = fields[11].GetUInt32();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Initialize connection to the databases
|
||||
|
||||
Reference in New Issue
Block a user