fix(Core/Realms): show realms as offline when no worldserver is running (#26658)

This commit is contained in:
Kitzunu
2026-07-17 08:45:27 +02:00
committed by GitHub
parent 448f07f06e
commit ea96cb4b4d
4 changed files with 12 additions and 0 deletions

View File

@@ -129,6 +129,10 @@ int main(int argc, char** argv)
std::shared_ptr<void> dbHandle(nullptr, [](void*) { StopDB(); });
// Mark every realm offline on startup; each worldserver clears this flag for its own realm once it is ready.
// This prevents realms from appearing online in the realm list when no worldserver is actually running.
LoginDatabase.DirectExecute("UPDATE realmlist SET flag = flag | {}", REALM_FLAG_OFFLINE);
std::shared_ptr<Acore::Asio::IoContext> ioContext = std::make_shared<Acore::Asio::IoContext>();
// Get the list of realms for the server

View File

@@ -91,6 +91,7 @@ void LoginDatabaseConnection::DoPrepareStatements()
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 = ? WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_UPTIME_PLAYERS, "UPDATE uptime SET uptime = ?, maxplayers = ? WHERE realmid = ? AND starttime = ?", CONNECTION_ASYNC);
PrepareStatement(LOGIN_UPD_REALM_ONLINE, "UPDATE realmlist SET flag = flag & ~? 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);

View File

@@ -75,6 +75,7 @@ enum LoginDatabaseStatements : uint32
LOGIN_UPD_LAST_ATTEMPT_IP,
LOGIN_UPD_ACCOUNT_ONLINE,
LOGIN_UPD_UPTIME_PLAYERS,
LOGIN_UPD_REALM_ONLINE,
LOGIN_DEL_OLD_LOGS,
LOGIN_DEL_ACCOUNT_ACCESS,
LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM,

View File

@@ -1286,6 +1286,12 @@ void World::Update(uint32 diff)
stmt->SetData(2, realm.Id.Realm);
stmt->SetData(3, uint32(GameTime::GetStartTime().count()));
LoginDatabase.Execute(stmt);
// Re-assert this realm as online in case the offline flag was set externally (e.g. an authserver restart).
LoginDatabasePreparedStatement* onlineStmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_REALM_ONLINE);
onlineStmt->SetData(0, uint8(REALM_FLAG_OFFLINE));
onlineStmt->SetData(1, realm.Id.Realm);
LoginDatabase.Execute(onlineStmt);
}
///- Process Game events when necessary