summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2018-01-28 23:02:22 +0100
committerMichael Lutz <michi@icosahedron.de>2018-04-10 23:30:01 +0200
commit4971678f521f945b9f6f47042d33d610db43962d (patch)
tree90740feda00609be59472b5dc530d771872e679f
parent74b7f0a9aa7658857714db365853db8f6c8512bd (diff)
downloadopenttd-4971678f521f945b9f6f47042d33d610db43962d.tar.xz
Codechange: [OSX] Use 10.10+ API to get the OSX version when available.
-rw-r--r--src/os/macosx/macos.mm24
-rw-r--r--src/os/macosx/osx_stdafx.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm
index 087630332..1d388d393 100644
--- a/src/os/macosx/macos.mm
+++ b/src/os/macosx/macos.mm
@@ -31,6 +31,16 @@
*/
+#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10)
+typedef struct {
+ NSInteger majorVersion;
+ NSInteger minorVersion;
+ NSInteger patchVersion;
+} OTTDOperatingSystemVersion;
+
+#define NSOperatingSystemVersion OTTDOperatingSystemVersion
+#endif
+
/**
* Get the version of the MacOS we are running under. Code adopted
* from http://www.cocoadev.com/index.pl?DeterminingOSVersion
@@ -44,6 +54,19 @@ void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix)
*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;
+ }
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10)
SInt32 systemVersion, version_major, version_minor, version_bugfix;
if (Gestalt(gestaltSystemVersion, &systemVersion) == noErr) {
if (systemVersion >= 0x1040) {
@@ -56,6 +79,7 @@ void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix)
*return_bugfix = (int)GB(systemVersion, 0, 4);
}
}
+#endif
}
#ifdef WITH_SDL
diff --git a/src/os/macosx/osx_stdafx.h b/src/os/macosx/osx_stdafx.h
index 4e16b5e63..70fff822f 100644
--- a/src/os/macosx/osx_stdafx.h
+++ b/src/os/macosx/osx_stdafx.h
@@ -53,6 +53,9 @@
#define MAC_OS_X_VERSION_10_9 1090
#endif
+#ifndef MAC_OS_X_VERSION_10_10
+#define MAC_OS_X_VERSION_10_10 101000
+#endif
#define __STDC_LIMIT_MACROS
#include <stdint.h>