feat(core): Increased limit of realms (#1664)

This commit is contained in:
Pondaveia
2019-04-13 17:07:26 +01:00
committed by Francesco Borzì
parent 135b4470ce
commit c1ebc70b58
4 changed files with 18 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
INSERT INTO `version_db_auth` (`sql_rev`) VALUES ('1554142988374631100');
ALTER TABLE `account` CHANGE COLUMN `online` `online` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `last_login`;

View File

@@ -56,7 +56,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_LAST_ATTEMPT_IP, "UPDATE account SET last_attempt_ip = ? WHERE username = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_ACCOUNT_ONLINE, "UPDATE account SET online = online | (1<<(?-1)) WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_ACCOUNT_ONLINE, "UPDATE account SET online = ? 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);

View File

@@ -126,7 +126,7 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8
m_Address = sock->GetRemoteAddress();
sock->AddReference();
ResetTimeOutTime(false);
LoginDatabase.PExecute("UPDATE account SET online = online | (1<<(%u-1)) WHERE id = %u;", realmID, GetAccountId());
LoginDatabase.PExecute("UPDATE account SET online = %u WHERE id = %u;", realmID, GetAccountId());
}
InitializeQueryCallbackParameters();
@@ -161,7 +161,7 @@ WorldSession::~WorldSession()
delete packet;
if (GetShouldSetOfflineInDB())
LoginDatabase.PExecute("UPDATE account SET online = online & ~(1<<(%u-1)) WHERE id = %u;", realmID, GetAccountId()); // One-time query
LoginDatabase.PExecute("UPDATE account SET online = %u WHERE id = %u;", realmID, GetAccountId()); // One-time query
}
std::string const & WorldSession::GetPlayerName() const

View File

@@ -471,11 +471,21 @@ bool Master::_StartDB()
///- Get the realm Id from the configuration file
realmID = sConfigMgr->GetIntDefault("RealmID", 0);
if (!realmID || realmID > 8) // pussywizard: above 8 spoils 8-bit online mask for the accounts
if (!realmID)
{
sLog->outError("Realm ID not defined in configuration file");
return false;
}
else if (realmID > 255)
{
/*
* Due to the client only being able to read a realmID
* with a size of uint8 we can "only" store up to 255 realms
* anything further the client will behave anormaly
*/
sLog->outError("Realm ID must range from 1 to 255");
return false;
}
sLog->outString("Realm running as realm ID %d", realmID);
///- Initialize the DB logging system
@@ -507,7 +517,7 @@ void Master::ClearOnlineAccounts()
{
// Reset online status for all accounts with characters on the current realm
// pussywizard: tc query would set online=0 even if logged in on another realm >_>
LoginDatabase.DirectPExecute("UPDATE account SET online = online & ~(1<<(%u-1)) WHERE online & (1<<(%u-1))", realmID, realmID);
LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online = %u", realmID);
// Reset online status for all characters
CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0");