From fc63b871635e9eedfaeecf6dffbb59c1fc42c37c Mon Sep 17 00:00:00 2001 From: RickyRister Date: Wed, 12 Feb 2025 20:50:05 -0800 Subject: [PATCH] refactor OS checking code --- .../src/client/network/release_channel.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cockatrice/src/client/network/release_channel.cpp b/cockatrice/src/client/network/release_channel.cpp index bd492f8c9..108445f43 100644 --- a/cockatrice/src/client/network/release_channel.cpp +++ b/cockatrice/src/client/network/release_channel.cpp @@ -39,9 +39,9 @@ void ReleaseChannel::checkForUpdates() } // Different release channel checking functions for different operating systems -#if defined(Q_OS_MACOS) bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName) { +#if defined(Q_OS_MACOS) static QRegularExpression version_regex("macOS(\\d+)"); auto match = version_regex.match(fileName); if (!match.hasMatch()) { @@ -52,10 +52,8 @@ bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName) int sys_maj = QSysInfo::productVersion().split(".")[0].toInt(); int rel_maj = match.captured(1).toInt(); return rel_maj == sys_maj; -} + #elif defined(Q_OS_WIN) -bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName) -{ #if Q_PROCESSOR_WORDSIZE == 4 return fileName.contains("32bit"); #elif Q_PROCESSOR_WORDSIZE == 8 @@ -66,16 +64,15 @@ bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName) return fileName.contains("Win10"); } #else + Q_UNUSED(fileName); + return false; +#endif + +#else // If the OS doesn't fit one of the above #defines, then it will never match + Q_UNUSED(fileName); return false; #endif } -#else -bool ReleaseChannel::downloadMatchesCurrentOS(const QString &) -{ - // If the OS doesn't fit one of the above #defines, then it will never match - return false; -} -#endif QString StableReleaseChannel::getManualDownloadUrl() const {