1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-27 06:04:25 +01:00

Fix 317dc71c6a: MacOS version detection was broken, and return a tuple instead of three out-params

This commit is contained in:
Rubidium
2026-01-22 20:45:43 +01:00
committed by rubidium42
parent 6b3eaba308
commit 0519f82a37
3 changed files with 8 additions and 25 deletions

View File

@@ -13,7 +13,7 @@
/** Helper function displaying a message the best possible way. */
void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label);
void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix);
std::tuple<int, int, int> GetMacOSVersion();
bool IsMonospaceFont(CFStringRef name);

View File

@@ -26,29 +26,13 @@ static NSAutoreleasePool *_ottd_autorelease_pool;
#endif
/**
* Get the version of the MacOS we are running under. Code adopted
* from http://www.cocoadev.com/index.pl?DeterminingOSVersion
* @param return_major major version of the os. This would be 10 in the case of 10.4.11
* @param return_minor minor version of the os. This would be 4 in the case of 10.4.11
* @param return_bugfix bugfix version of the os. This would be 11 in the case of 10.4.11
* A return value of -1 indicates that something went wrong and we don't know.
* Get the version of the MacOS we are running under.
* @return Tuple with major, minor and patch of the MacOS version.
*/
void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix)
std::tuple<int, int, int> GetMacOSVersion()
{
*return_major = -1;
*return_minor = -1;
*return_bugfix = -1;
if ([[ NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion) ]) {
IMP sel = [ [ NSProcessInfo processInfo] methodForSelector:@selector(operatingSystemVersion) ];
NSOperatingSystemVersion ver = ((NSOperatingSystemVersion (*)(id, SEL))sel)([ NSProcessInfo processInfo], @selector(operatingSystemVersion));
*return_major = (int)ver.majorVersion;
*return_minor = (int)ver.minorVersion;
*return_bugfix = (int)ver.patchVersion;
return;
}
NSOperatingSystemVersion ver = [ [ NSProcessInfo processInfo ] operatingSystemVersion ];
return { static_cast<int>(ver.majorVersion), static_cast<int>(ver.minorVersion), static_cast<int>(ver.patchVersion) };
}
#ifdef WITH_COCOA

View File

@@ -20,13 +20,12 @@
void SurveyOS(nlohmann::json &json)
{
int ver_maj, ver_min, ver_bug;
GetMacOSVersion(&ver_maj, &ver_min, &ver_bug);
auto [ver_major, ver_minor, ver_patch] = GetMacOSVersion();
const NXArchInfo *arch = NXGetLocalArchInfo();
json["os"] = "MacOS";
json["release"] = fmt::format("{}.{}.{}", ver_maj, ver_min, ver_bug);
json["release"] = fmt::format("{}.{}.{}", ver_major, ver_minor, ver_patch);
json["machine"] = arch != nullptr ? arch->description : "unknown";
json["min_ver"] = MAC_OS_X_VERSION_MIN_REQUIRED;
json["max_ver"] = MAC_OS_X_VERSION_MAX_ALLOWED;