diff options
-rw-r--r-- | modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.cpp | 1 | ||||
-rw-r--r-- | modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.h | 1 | ||||
-rw-r--r-- | src/game/World/World.cpp | 17 | ||||
-rw-r--r-- | src/game/World/World.h | 1 |
4 files changed, 14 insertions, 6 deletions
diff --git a/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.cpp b/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.cpp index 38590704dd..216875bb7a 100644 --- a/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.cpp +++ b/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.cpp @@ -55,6 +55,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_UPD_MUTE_TIME_LOGIN, "UPDATE account SET mutetime = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_LAST_IP, "UPDATE account SET last_ip = ? WHERE username = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_ACCOUNT_ONLINE, "UPDATE account SET online = online | (1<<(?-1)) WHERE id = ?", CONNECTION_ASYNC); + PrepareStatement(LOGIN_DEL_OLD_LOGS, "DELETE FROM logs WHERE (time + ?) < ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_ACCOUNT_ACCESS, "DELETE FROM account_access WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM, "DELETE FROM account_access WHERE id = ? AND (RealmID = ? OR RealmID = -1)", CONNECTION_ASYNC); PrepareStatement(LOGIN_INS_ACCOUNT_ACCESS, "INSERT INTO account_access (id,gmlevel,RealmID) VALUES (?, ?, ?)", CONNECTION_ASYNC); diff --git a/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.h b/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.h index 6ba77531ac..904369fbb4 100644 --- a/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.h +++ b/modules/worldengine/nucleus/src/Database/Implementation/LoginDatabase.h @@ -75,6 +75,7 @@ enum LoginDatabaseStatements LOGIN_UPD_MUTE_TIME_LOGIN, LOGIN_UPD_LAST_IP, LOGIN_UPD_ACCOUNT_ONLINE, + LOGIN_DEL_OLD_LOGS, LOGIN_DEL_ACCOUNT_ACCESS, LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM, LOGIN_INS_ACCOUNT_ACCESS, diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 4650aec6a8..269f9786d5 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -920,6 +920,9 @@ void World::LoadConfigSettings(bool reload) m_timers[WUPDATE_CLEANDB].SetInterval(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILLISECONDS); m_timers[WUPDATE_CLEANDB].Reset(); } + m_int_configs[CONFIG_LOGDB_CLEARTIME] = sConfigMgr->GetIntDefault("LogDB.Opt.ClearTime", 1209600); // 14 days default + sLog->outString("Will clear `logs` table of entries older than %i seconds every %u minutes.", + m_int_configs[CONFIG_LOGDB_CLEARTIME], m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]); m_int_configs[CONFIG_TELEPORT_TIMEOUT_NEAR] = sConfigMgr->GetIntDefault("TeleportTimeoutNear", 25); // pussywizard m_int_configs[CONFIG_TELEPORT_TIMEOUT_FAR] = sConfigMgr->GetIntDefault("TeleportTimeoutFar", 45); // pussywizard @@ -2022,16 +2025,18 @@ void World::Update(uint32 diff) } /// <li> Clean logs table - if(getIntConfig(CONFIG_LOGDB_CLEARINTERVAL) > 0) // if not enabled, ignore the timer + if (sWorld->getIntConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer { if (m_timers[WUPDATE_CLEANDB].Passed()) { - uint32 tmpDiff = (m_gameTime - m_startTime); - uint32 maxClientsNum = GetMaxActiveSessionCount(); - m_timers[WUPDATE_CLEANDB].Reset(); - LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < " UI64FMTD ";", - getIntConfig(CONFIG_LOGDB_CLEARINTERVAL), uint64(time(0))); + + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_OLD_LOGS); + + stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_LOGDB_CLEARTIME)); + stmt->setUInt32(1, uint32(time(0))); + + LoginDatabase.Execute(stmt); } } diff --git a/src/game/World/World.h b/src/game/World/World.h index a12a64f491..ddb2e16733 100644 --- a/src/game/World/World.h +++ b/src/game/World/World.h @@ -288,6 +288,7 @@ enum WorldIntConfigs CONFIG_PLAYER_ALLOW_COMMANDS, CONFIG_NUMTHREADS, CONFIG_LOGDB_CLEARINTERVAL, + CONFIG_LOGDB_CLEARTIME, CONFIG_TELEPORT_TIMEOUT_NEAR, // pussywizard CONFIG_TELEPORT_TIMEOUT_FAR, // pussywizard CONFIG_MAX_ALLOWED_MMR_DROP, // pussywizard |