diff --git a/data/sql/updates/pending_db_auth/rev_1554142988374631100.sql b/data/sql/updates/pending_db_auth/rev_1554142988374631100.sql new file mode 100644 index 000000000..f84e9c0ff --- /dev/null +++ b/data/sql/updates/pending_db_auth/rev_1554142988374631100.sql @@ -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`; diff --git a/src/common/Database/Implementation/LoginDatabase.cpp b/src/common/Database/Implementation/LoginDatabase.cpp index a2548d0a3..47fdcba3a 100644 --- a/src/common/Database/Implementation/LoginDatabase.cpp +++ b/src/common/Database/Implementation/LoginDatabase.cpp @@ -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); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index a337fb4ad..80a2af2af 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -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 diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index 4b76a8172..bb0f24bd5 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -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");