[Server] Serve the server list through the database interface (#7855)

This commit is contained in:
BruebachL 2026-11-10 12:16:32 +01:00 • committed by GitHub
parent f8f8fffa6b
commit f1ee6bdc2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 7 deletions

View file

@ -3310,6 +3310,33 @@ bool Servatrice_DatabaseInterface::getLatestServerMessage(int serverId, QString
return true;
}
QList<Server_DatabaseInterface::ServerListEntryRecord> Servatrice_DatabaseInterface::getServerListEntries()
{
QList<ServerListEntryRecord> entries;
if (!checkSql()) {
return entries;
}
QSqlQuery *query = prepareQuery(
"select id, ssl_cert, hostname, address, game_port, control_port from {prefix}_servers order by id asc");
if (!execSqlQuery(query)) {
return entries;
}
while (query->next()) {
ServerListEntryRecord entry;
entry.id = query->value(0).toInt();
entry.sslCert = query->value(1).toString().toUtf8();
entry.hostname = query->value(2).toString();
entry.address = query->value(3).toString();
entry.gamePort = query->value(4).toInt();
entry.controlPort = query->value(5).toInt();
entries.append(entry);
}
return entries;
}
bool Servatrice_DatabaseInterface::removeUserAvatar(const QString &userName)
{
if (!checkSql()) {