Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Core/DBLayer: Remnant cleanups

  • Loading branch information...
commit 4665d5bfc456a49b10b0817db5473c3ee5c86603 1 parent 178c658
leak leak authored
6 src/server/shared/Database/DatabaseWorkerPool.h
@@ -133,6 +133,7 @@ class DatabaseWorkerPool
133 133 */
134 134
135 135 //! Enqueues a one-way SQL operation in string format that will be executed asynchronously.
  136 + //! This method should only be used for queries that are only executed once, e.g during startup.
136 137 void Execute(const char* sql)
137 138 {
138 139 if (!sql)
@@ -143,6 +144,7 @@ class DatabaseWorkerPool
143 144 }
144 145
145 146 //! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
  147 + //! This method should only be used for queries that are only executed once, e.g during startup.
146 148 void PExecute(const char* sql, ...)
147 149 {
148 150 if (!sql)
@@ -166,10 +168,11 @@ class DatabaseWorkerPool
166 168 }
167 169
168 170 /**
169   - Direct syncrhonous one-way statement methods.
  171 + Direct synchronous one-way statement methods.
170 172 */
171 173
172 174 //! Directly executes a one-way SQL operation in string format, that will block the calling thread until finished.
  175 + //! This method should only be used for queries that are only executed once, e.g during startup.
173 176 void DirectExecute(const char* sql)
174 177 {
175 178 if (!sql)
@@ -181,6 +184,7 @@ class DatabaseWorkerPool
181 184 }
182 185
183 186 //! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
  187 + //! This method should only be used for queries that are only executed once, e.g during startup.
184 188 void DirectPExecute(const char* sql, ...)
185 189 {
186 190 if (!sql)
14 src/server/worldserver/Master.cpp
@@ -294,7 +294,7 @@ int Master::Run()
294 294 rar_thread.wait();
295 295
296 296 ///- Clean database before leaving
297   - clearOnlineAccounts();
  297 + ClearOnlineAccounts();
298 298
299 299 _StopDB();
300 300
@@ -454,7 +454,7 @@ bool Master::_StartDB()
454 454 sLog->SetRealmID(realmID);
455 455
456 456 ///- Clean the database before starting
457   - clearOnlineAccounts();
  457 + ClearOnlineAccounts();
458 458
459 459 ///- Insert version info into DB
460 460 WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", _FULLVERSION, _HASH); // One-time query
@@ -475,14 +475,12 @@ void Master::_StopDB()
475 475 }
476 476
477 477 /// Clear 'online' status for all accounts with characters in this realm
478   -void Master::clearOnlineAccounts()
  478 +void Master::ClearOnlineAccounts()
479 479 {
480   - // Cleanup online status for characters hosted at current realm
481   - /// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'?
482   - LoginDatabase.DirectPExecute(
483   - "UPDATE account SET online = 0 WHERE online > 0 "
484   - "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')", realmID);
  480 + // Reset online status for all accounts with characters on the current realm
  481 + LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = %d)", realmID);
485 482
  483 + // Reset online status for all characters
486 484 CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0");
487 485
488 486 // Battleground instance ids reset at server restart
2  src/server/worldserver/Master.h
@@ -37,7 +37,7 @@ class Master
37 37 bool _StartDB();
38 38 void _StopDB();
39 39
40   - void clearOnlineAccounts();
  40 + void ClearOnlineAccounts();
41 41 };
42 42
43 43 #define sMaster ACE_Singleton<Master, ACE_Null_Mutex>::instance()

0 comments on commit 4665d5b

Please sign in to comment.
Something went wrong with that request. Please try again.