mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 07:36:23 +00:00
feat(Core/Database): implement db loader (#4431)
This commit is contained in:
@@ -12,21 +12,22 @@
|
||||
* authentication server
|
||||
*/
|
||||
|
||||
#include <ace/Dev_Poll_Reactor.h>
|
||||
#include <ace/TP_Reactor.h>
|
||||
#include <ace/ACE.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
#include "Configuration/Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "GitRevision.h"
|
||||
#include "Util.h"
|
||||
#include "SignalHandler.h"
|
||||
#include "RealmList.h"
|
||||
#include "RealmAcceptor.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include <ace/Dev_Poll_Reactor.h>
|
||||
#include <ace/TP_Reactor.h>
|
||||
#include <ace/ACE.h>
|
||||
#include <ace/Sig_Handler.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sched.h>
|
||||
@@ -43,8 +44,6 @@ void StopDB();
|
||||
|
||||
bool stopEvent = false; // Setting it to true stops the server
|
||||
|
||||
LoginDatabaseWorkerPool LoginDatabase; // Accessor to the authserver database
|
||||
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char* prog)
|
||||
{
|
||||
@@ -281,33 +280,15 @@ bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = sConfigMgr->GetOption<std::string>("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
sLog->outError("Database not specified");
|
||||
// Load databases
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1.
|
||||
// Increasing it is just silly since only 1 will be used ever.
|
||||
DatabaseLoader loader;
|
||||
loader
|
||||
.AddDatabase(LoginDatabase, "Login");
|
||||
|
||||
if (!loader.Load())
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = sConfigMgr->GetOption<int32>("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
sLog->outError("Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = sConfigMgr->GetOption<int32>("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
sLog->outError("Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
synch_threads = 1;
|
||||
}
|
||||
|
||||
// NOTE: While authserver is singlethreaded you should keep synch_threads == 1. Increasing it is just silly since only 1 will be used ever.
|
||||
if (!LoginDatabase.Open(dbstring.c_str(), uint8(worker_threads), uint8(synch_threads)))
|
||||
{
|
||||
sLog->outError("Cannot connect to database");
|
||||
return false;
|
||||
}
|
||||
|
||||
sLog->outString("Started auth database connection pool.");
|
||||
return true;
|
||||
|
||||
@@ -19852,7 +19852,6 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Difficulty target_difficulty = GetDifficulty(mapEntry->IsRaid());
|
||||
MapDifficulty const* mapDiff = GetDownscaledMapDifficultyData(target_map, target_difficulty);
|
||||
if (LevelMin || LevelMax || ilvlRequirementNotMet
|
||||
|
||||
@@ -6342,7 +6342,6 @@ void ObjectMgr::LoadAccessRequirements()
|
||||
currentRequirementsList->push_back(progression_requirement);
|
||||
}
|
||||
|
||||
|
||||
} while (progression_requirements_results->NextRow());
|
||||
}
|
||||
|
||||
@@ -6360,7 +6359,6 @@ void ObjectMgr::LoadAccessRequirements()
|
||||
_accessRequirementStore[mapid][difficulty] = ar;
|
||||
} while (access_template_result->NextRow());
|
||||
|
||||
|
||||
sLog->outString(">> Loaded %u rows from dungeon_access_template and %u rows from dungeon_access_requirements in %u ms", count, countProgressionRequirements, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
@@ -53,5 +53,4 @@ inline AI* GetAhnkahetAI(T* obj)
|
||||
return GetInstanceAI<AI>(obj, AhnahetScriptName);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "WorldRunnable.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "WorldSocketMgr.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include <ace/Sig_Handler.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -388,80 +389,16 @@ bool Master::_StartDB()
|
||||
MySQL::Library_Init();
|
||||
|
||||
sLog->SetLogDB(false);
|
||||
std::string dbstring;
|
||||
uint8 async_threads, synch_threads;
|
||||
|
||||
dbstring = sConfigMgr->GetOption<std::string>("WorldDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
sLog->outError("World database not specified in configuration file");
|
||||
// Load databases
|
||||
DatabaseLoader loader;
|
||||
loader
|
||||
.AddDatabase(LoginDatabase, "Login")
|
||||
.AddDatabase(CharacterDatabase, "Character")
|
||||
.AddDatabase(WorldDatabase, "World");
|
||||
|
||||
if (!loader.Load())
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(sConfigMgr->GetOption<int32>("WorldDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("World database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(sConfigMgr->GetOption<int32>("WorldDatabase.SynchThreads", 1));
|
||||
///- Initialise the world database
|
||||
if (!WorldDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
{
|
||||
sLog->outError("Cannot connect to world database %s", dbstring.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
///- Get character database info from configuration file
|
||||
dbstring = sConfigMgr->GetOption<std::string>("CharacterDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
sLog->outError("Character database not specified in configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(sConfigMgr->GetOption<int32>("CharacterDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("Character database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(sConfigMgr->GetOption<int32>("CharacterDatabase.SynchThreads", 2));
|
||||
|
||||
///- Initialise the Character database
|
||||
if (!CharacterDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
{
|
||||
sLog->outError("Cannot connect to Character database %s", dbstring.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
///- Get login database info from configuration file
|
||||
dbstring = sConfigMgr->GetOption<std::string>("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
sLog->outError("Login database not specified in configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(sConfigMgr->GetOption<int32>("LoginDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
sLog->outError("Login database: invalid number of worker threads specified. "
|
||||
"Please pick a value between 1 and 32.");
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(sConfigMgr->GetOption<int32>("LoginDatabase.SynchThreads", 1));
|
||||
///- Initialise the login database
|
||||
if (!LoginDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
{
|
||||
sLog->outError("Cannot connect to login database %s", dbstring.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
///- Get the realm Id from the configuration file
|
||||
realmID = sConfigMgr->GetOption<int32>("RealmID", 0);
|
||||
|
||||
Reference in New Issue
Block a user