From dec5421ca2cb5ac9e77ce96507d0285a6b0fcfee Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 15 Nov 2020 21:55:34 +0100 Subject: rbutil: Rework server info data handling. Return status as int, not as string, and provide a separate function for converting to string. This allows to filter based on the actual status, not a (localized) status string, which is more robust. Fix a regression that made players with missing status value show up as retired. Change-Id: I15f83ae0df484199b1b3b5b95069db8b4d425987 --- rbutil/rbutilqt/base/serverinfo.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'rbutil/rbutilqt/base/serverinfo.cpp') diff --git a/rbutil/rbutilqt/base/serverinfo.cpp b/rbutil/rbutilqt/base/serverinfo.cpp index 84aa89039d..88c8d955fe 100644 --- a/rbutil/rbutilqt/base/serverinfo.cpp +++ b/rbutil/rbutilqt/base/serverinfo.cpp @@ -27,18 +27,19 @@ static QSettings* serverSettings = nullptr; const static struct { ServerInfo::ServerInfos info; const char* name; + const char* def; } ServerInfoList[] = { - { ServerInfo::CurReleaseVersion, "release/:platform:" }, - { ServerInfo::CurReleaseUrl, "release/:platform:" }, - { ServerInfo::RelCandidateVersion, "release-candidate/:platform:" }, - { ServerInfo::RelCandidateUrl, "release-candidate/:platform:" }, - { ServerInfo::CurStatus, "status/:platform:" }, - { ServerInfo::ManualPdfUrl, "" }, - { ServerInfo::ManualHtmlUrl, "" }, - { ServerInfo::ManualZipUrl, "" }, - { ServerInfo::BleedingRevision, "bleeding/rev" }, - { ServerInfo::BleedingDate, "bleeding/timestamp" }, - { ServerInfo::CurDevelUrl, "" }, + { ServerInfo::CurReleaseVersion, "release/:platform:", "" }, + { ServerInfo::CurReleaseUrl, "release/:platform:", "" }, + { ServerInfo::RelCandidateVersion, "release-candidate/:platform:", "" }, + { ServerInfo::RelCandidateUrl, "release-candidate/:platform:", "" }, + { ServerInfo::CurStatus, "status/:platform:", "-1" }, + { ServerInfo::ManualPdfUrl, "", "" }, + { ServerInfo::ManualHtmlUrl, "", "" }, + { ServerInfo::ManualZipUrl, "", "" }, + { ServerInfo::BleedingRevision, "bleeding/rev", "" }, + { ServerInfo::BleedingDate, "bleeding/timestamp", "" }, + { ServerInfo::CurDevelUrl, "", "" }, }; QMap ServerInfo::serverInfos; @@ -73,13 +74,10 @@ QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform) // get value QVariant value = QString(); if(!s.isEmpty() && serverSettings) - value = serverSettings->value(s, ""); + value = serverSettings->value(s, ServerInfoList[i].def); // depending on the actual value we need more replacements. switch(info) { - case ServerInfo::CurStatus: - value = ServerInfo::statusToString(value.toInt()); - break; case CurReleaseVersion: case RelCandidateVersion: value = value.toStringList().at(0); -- cgit v1.2.3