Core/DBLayer: Remnant cleanups
This commit is contained in:
@@ -133,6 +133,7 @@ class DatabaseWorkerPool
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//! Enqueues a one-way SQL operation in string format that will be executed asynchronously.
|
//! Enqueues a one-way SQL operation in string format that will be executed asynchronously.
|
||||||
|
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||||
void Execute(const char* sql)
|
void Execute(const char* sql)
|
||||||
{
|
{
|
||||||
if (!sql)
|
if (!sql)
|
||||||
@@ -143,6 +144,7 @@ class DatabaseWorkerPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
|
//! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
|
||||||
|
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||||
void PExecute(const char* sql, ...)
|
void PExecute(const char* sql, ...)
|
||||||
{
|
{
|
||||||
if (!sql)
|
if (!sql)
|
||||||
@@ -166,10 +168,11 @@ class DatabaseWorkerPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Direct syncrhonous one-way statement methods.
|
Direct synchronous one-way statement methods.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! Directly executes a one-way SQL operation in string format, that will block the calling thread until finished.
|
//! Directly executes a one-way SQL operation in string format, that will block the calling thread until finished.
|
||||||
|
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||||
void DirectExecute(const char* sql)
|
void DirectExecute(const char* sql)
|
||||||
{
|
{
|
||||||
if (!sql)
|
if (!sql)
|
||||||
@@ -181,6 +184,7 @@ class DatabaseWorkerPool
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
|
//! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
|
||||||
|
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||||
void DirectPExecute(const char* sql, ...)
|
void DirectPExecute(const char* sql, ...)
|
||||||
{
|
{
|
||||||
if (!sql)
|
if (!sql)
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ int Master::Run()
|
|||||||
rar_thread.wait();
|
rar_thread.wait();
|
||||||
|
|
||||||
///- Clean database before leaving
|
///- Clean database before leaving
|
||||||
clearOnlineAccounts();
|
ClearOnlineAccounts();
|
||||||
|
|
||||||
_StopDB();
|
_StopDB();
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ bool Master::_StartDB()
|
|||||||
sLog->SetRealmID(realmID);
|
sLog->SetRealmID(realmID);
|
||||||
|
|
||||||
///- Clean the database before starting
|
///- Clean the database before starting
|
||||||
clearOnlineAccounts();
|
ClearOnlineAccounts();
|
||||||
|
|
||||||
///- Insert version info into DB
|
///- Insert version info into DB
|
||||||
WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH); // One-time query
|
WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH); // One-time query
|
||||||
@@ -475,14 +475,12 @@ void Master::_StopDB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Clear 'online' status for all accounts with characters in this realm
|
/// Clear 'online' status for all accounts with characters in this realm
|
||||||
void Master::clearOnlineAccounts()
|
void Master::ClearOnlineAccounts()
|
||||||
{
|
{
|
||||||
// Cleanup online status for characters hosted at current realm
|
// Reset online status for all accounts with characters on the current realm
|
||||||
/// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'?
|
LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = %d)", realmID);
|
||||||
LoginDatabase.DirectPExecute(
|
|
||||||
"UPDATE account SET online = 0 WHERE online > 0 "
|
|
||||||
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')", realmID);
|
|
||||||
|
|
||||||
|
// Reset online status for all characters
|
||||||
CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0");
|
CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0");
|
||||||
|
|
||||||
// Battleground instance ids reset at server restart
|
// Battleground instance ids reset at server restart
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Master
|
|||||||
bool _StartDB();
|
bool _StartDB();
|
||||||
void _StopDB();
|
void _StopDB();
|
||||||
|
|
||||||
void clearOnlineAccounts();
|
void ClearOnlineAccounts();
|
||||||
};
|
};
|
||||||
|
|
||||||
#define sMaster ACE_Singleton<Master, ACE_Null_Mutex>::instance()
|
#define sMaster ACE_Singleton<Master, ACE_Null_Mutex>::instance()
|
||||||
|
|||||||
Reference in New Issue
Block a user