mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
Import uptime table and feature from TC (#717)
This commit is contained in:
11
data/sql/updates/pending_db_auth/rev_1511238042597856200.sql
Normal file
11
data/sql/updates/pending_db_auth/rev_1511238042597856200.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
INSERT INTO version_db_auth (`sql_rev`) VALUES ('1511238042597856200');
|
||||
DROP TABLE IF EXISTS `uptime`;
|
||||
|
||||
CREATE TABLE `uptime` (
|
||||
`realmid` int(10) unsigned NOT NULL,
|
||||
`starttime` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`uptime` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`maxplayers` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`revision` varchar(255) NOT NULL DEFAULT 'AzerothCore',
|
||||
PRIMARY KEY (`realmid`,`starttime`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Uptime system';
|
||||
@@ -57,6 +57,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_UPD_UPTIME_PLAYERS, "UPDATE uptime SET uptime = ?, maxplayers = ? WHERE realmid = ? AND starttime = ?", 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);
|
||||
|
||||
@@ -77,6 +77,7 @@ enum LoginDatabaseStatements
|
||||
LOGIN_UPD_MUTE_TIME_LOGIN,
|
||||
LOGIN_UPD_LAST_IP,
|
||||
LOGIN_UPD_ACCOUNT_ONLINE,
|
||||
LOGIN_UPD_UPTIME_PLAYERS,
|
||||
LOGIN_DEL_OLD_LOGS,
|
||||
LOGIN_DEL_ACCOUNT_ACCESS,
|
||||
LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM,
|
||||
|
||||
@@ -910,6 +910,12 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_int_configs[CONFIG_UPTIME_UPDATE] = 1;
|
||||
}
|
||||
|
||||
if (reload)
|
||||
{
|
||||
m_timers[WUPDATE_UPTIME].SetInterval(m_int_configs[CONFIG_UPTIME_UPDATE]*MINUTE*IN_MILLISECONDS);
|
||||
m_timers[WUPDATE_UPTIME].Reset();
|
||||
}
|
||||
|
||||
// log db cleanup interval
|
||||
m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] = sConfigMgr->GetIntDefault("LogDB.Opt.ClearInterval", 10);
|
||||
if (int32(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0)
|
||||
@@ -1760,11 +1766,16 @@ void World::SetInitialWorldSettings()
|
||||
m_gameTime = time(NULL);
|
||||
m_startTime = m_gameTime;
|
||||
|
||||
LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, %u, 0, '%s')",
|
||||
realmID, uint32(m_startTime), _FULLVERSION); // One-time query
|
||||
|
||||
|
||||
|
||||
m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS);
|
||||
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS);
|
||||
m_timers[WUPDATE_AUCTIONS].SetCurrent(MINUTE*IN_MILLISECONDS);
|
||||
m_timers[WUPDATE_UPTIME].SetInterval(m_int_configs[CONFIG_UPTIME_UPDATE]*MINUTE*IN_MILLISECONDS);
|
||||
//Update "uptime" table based on configuration entry in minutes.
|
||||
|
||||
m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS);
|
||||
//erase corpses every 20 minutes
|
||||
@@ -2085,7 +2096,25 @@ void World::Update(uint32 diff)
|
||||
|
||||
// execute callbacks from sql queries that were queued recently
|
||||
ProcessQueryCallbacks();
|
||||
|
||||
|
||||
/// <li> Update uptime table
|
||||
if (m_timers[WUPDATE_UPTIME].Passed())
|
||||
{
|
||||
uint32 tmpDiff = uint32(m_gameTime - m_startTime);
|
||||
uint32 maxOnlinePlayers = GetMaxPlayerCount();
|
||||
|
||||
m_timers[WUPDATE_UPTIME].Reset();
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_UPTIME_PLAYERS);
|
||||
|
||||
stmt->setUInt32(0, tmpDiff);
|
||||
stmt->setUInt16(1, uint16(maxOnlinePlayers));
|
||||
stmt->setUInt32(2, realmID);
|
||||
stmt->setUInt32(3, uint32(m_startTime));
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
///- Erase corpses once every 20 minutes
|
||||
if (m_timers[WUPDATE_CORPSES].Passed())
|
||||
{
|
||||
|
||||
@@ -60,6 +60,7 @@ enum WorldTimers
|
||||
{
|
||||
WUPDATE_AUCTIONS,
|
||||
WUPDATE_WEATHERS,
|
||||
WUPDATE_UPTIME,
|
||||
WUPDATE_CORPSES,
|
||||
WUPDATE_EVENTS,
|
||||
WUPDATE_CLEANDB,
|
||||
|
||||
Reference in New Issue
Block a user