diff --git a/src/addresses.h b/src/addresses.h
index a629e53679..35a90b3de1 100644
--- a/src/addresses.h
+++ b/src/addresses.h
@@ -21,13 +21,15 @@
#ifndef _ADDRESSES_H_
#define _ADDRESSES_H_
+#include "common.h"
+
#ifdef _MSC_VER
#pragma warning(disable : 4731)
#endif
#define RCT2_ADDRESS(address, type) ((type*)(address))
#define RCT2_GLOBAL(address, type) (*((type*)(address)))
-#ifdef _WIN32
+#ifdef __WINDOWS__
#define RCT2_CALLPROC(address) (((void(*)())(address))())
#define RCT2_CALLFUNC(address, returnType) (((returnType(*)())(address))())
@@ -46,7 +48,7 @@
#define RCT2_CALLFUNC_4(address, returnType, a1, a2, a3, a4, v1, v2, v3, v4)
#define RCT2_CALLFUNC_5(address, returnType, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5)
#define RCT2_CALLFUNC_6(address, returnType, a1, a2, a3, a4, a5, a6, v1, v2, v3, v4, v5, v6)
-#endif // _WIN32
+#endif // __WINDOWS__
#define RCT2_CALLPROC_1(address, a1, v1) RCT2_CALLFUNC_1(address, void, a1, v1)
#define RCT2_CALLPROC_2(address, a1, a2, v1, v2) RCT2_CALLFUNC_2(address, void, a1, a2, v1, v2)
diff --git a/src/audio/audio.c b/src/audio/audio.c
index 015c2e13b4..9238f70f9d 100644
--- a/src/audio/audio.c
+++ b/src/audio/audio.c
@@ -86,7 +86,7 @@ void audio_populate_devices()
safe_strncpy(systemAudioDevices[i].name, utf8Name, AUDIO_DEVICE_NAME_SIZE);
}
-#ifndef __linux__
+#ifndef __LINUX__
gAudioDeviceCount++;
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
safe_strncpy(gAudioDevices[0].name, language_get_string(5510), AUDIO_DEVICE_NAME_SIZE);
@@ -94,7 +94,7 @@ void audio_populate_devices()
#else
gAudioDevices = malloc(gAudioDeviceCount * sizeof(audio_device));
memcpy(gAudioDevices, systemAudioDevices, gAudioDeviceCount * sizeof(audio_device));
-#endif // __linux__
+#endif // __LINUX__
free(systemAudioDevices);
}
diff --git a/src/cmdline/CommandLine.cpp b/src/cmdline/CommandLine.cpp
index f985a87122..25cf06d449 100644
--- a/src/cmdline/CommandLine.cpp
+++ b/src/cmdline/CommandLine.cpp
@@ -510,7 +510,7 @@ namespace CommandLine
static bool HandleSpecialArgument(const char * argument)
{
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
if (String::Equals(argument, "-NSDocumentRevisionsDebugMode"))
{
return true;
diff --git a/src/config.c b/src/config.c
index 7782719945..a5c95af976 100644
--- a/src/config.c
+++ b/src/config.c
@@ -895,7 +895,7 @@ void config_apply_to_old_addresses()
#define CTRL 0x200
#define ALT 0x400
#define CMD 0x800
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
#define PLATFORM_MODIFIER CMD
#else
#define PLATFORM_MODIFIER CTRL
diff --git a/src/core/Path.cpp b/src/core/Path.cpp
index 8b4344d4da..016dac36ef 100644
--- a/src/core/Path.cpp
+++ b/src/core/Path.cpp
@@ -19,7 +19,7 @@ namespace Path
utf8 * GetAbsolute(utf8 *buffer, size_t bufferSize, const utf8 * relativePath)
{
-#if _WIN32
+#if __WINDOWS__
wchar_t * relativePathW = utf8_to_widechar(relativePath);
wchar_t absolutePathW[MAX_PATH];
DWORD length = GetFullPathNameW(relativePathW, Util::CountOf(absolutePathW), absolutePathW, NULL);
diff --git a/src/hook.c b/src/hook.c
index ebed9b189c..24b4b1278c 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -18,11 +18,14 @@
* along with this program. If not, see .
*****************************************************************************/
-#ifdef _WIN32
+#include "common.h"
+
+#ifdef __WINDOWS__
#include
#else
#include
-#endif // _WIN32
+#endif // __WINDOWS__
+
#include "hook.h"
#include "platform/platform.h"
@@ -200,19 +203,19 @@ void hookfunc(int address, int newaddress, int stacksize, int registerargs[], in
data[i++] = 0xC3; // retn
-#ifdef _WIN32
+#ifdef __WINDOWS__
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0);
#else
// We own the pages with PROT_WRITE | PROT_EXEC, we can simply just memcpy the data
memcpy((void *)address, data, i);
-#endif // _WIN32
+#endif // __WINDOWS__
}
void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister)
{
if (!g_hooktableaddress) {
size_t size = g_maxhooks * 100;
-#ifdef _WIN32
+#ifdef __WINDOWS__
g_hooktableaddress = VirtualAllocEx(GetCurrentProcess(), NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else
g_hooktableaddress = mmap(NULL, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@@ -221,7 +224,7 @@ void addhook(int address, int newaddress, int stacksize, int registerargs[], int
perror("mmap");
exit(1);
}
-#endif // _WIN32
+#endif // __WINDOWS__
}
if (g_hooktableoffset > g_maxhooks) {
return;
@@ -235,12 +238,12 @@ void addhook(int address, int newaddress, int stacksize, int registerargs[], int
i += 4;
data[i++] = 0xC3; // retn
-#ifdef _WIN32
+#ifdef __WINDOWS__
WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0);
#else
// We own the pages with PROT_WRITE | PROT_EXEC, we can simply just memcpy the data
memcpy((void *)address, data, i);
-#endif // _WIN32
+#endif // __WINDOWS__
hookfunc(hookaddress, newaddress, stacksize, registerargs, registersreturned, eaxDestinationRegister);
g_hooktableoffset++;
}
diff --git a/src/input.c b/src/input.c
index 34a4fc4e10..deaea3528d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1391,7 +1391,7 @@ void title_handle_keyboard_input()
gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT])
gInputPlaceObjectModifier |= 4;
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
gInputPlaceObjectModifier |= 8;
}
@@ -1456,7 +1456,7 @@ void game_handle_keyboard_input()
if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) {
gInputPlaceObjectModifier |= 4;
}
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) {
gInputPlaceObjectModifier |= 8;
}
@@ -1661,7 +1661,7 @@ void game_handle_key_scroll()
if (shortcutKey & ALT) {
if (!gKeysState[SDL_SCANCODE_LALT] && !gKeysState[SDL_SCANCODE_RALT]) continue;
}
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
if (shortcutKey & CMD) {
if (!gKeysState[SDL_SCANCODE_LGUI] && !gKeysState[SDL_SCANCODE_RGUI]) continue;
}
diff --git a/src/interface/keyboard_shortcut.c b/src/interface/keyboard_shortcut.c
index 5462b90311..bc454aef5d 100644
--- a/src/interface/keyboard_shortcut.c
+++ b/src/interface/keyboard_shortcut.c
@@ -97,7 +97,7 @@ void keyboard_shortcut_format_string(char *buffer, uint16 shortcutKey)
strcat(buffer, formatBuffer);
}
if (shortcutKey & 0x400) {
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
format_string(formatBuffer, STR_OPTION_PLUS, NULL);
#else
format_string(formatBuffer, STR_ALT_PLUS, NULL);
diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c
index c6c8566c73..768076a514 100644
--- a/src/localisation/localisation.c
+++ b/src/localisation/localisation.c
@@ -18,12 +18,15 @@
* along with this program. If not, see .
*****************************************************************************/
-#ifdef _WIN32
+#include "../common.h"
+
+#ifdef __WINDOWS__
#include
#else
#include
#include
-#endif // _WIN32
+#endif // __WINDOWS__
+
#include "../addresses.h"
#include "../config.h"
#include "../game.h"
@@ -936,7 +939,7 @@ int win1252_to_utf8(utf8string dst, const char *src, size_t maxBufferLength)
{
size_t srcLength = strlen(src);
-#ifdef _WIN32
+#ifdef __WINDOWS__
utf16 stackBuffer[256];
utf16 *heapBuffer = NULL;
utf16 *intermediateBuffer = stackBuffer;
@@ -1005,7 +1008,7 @@ int win1252_to_utf8(utf8string dst, const char *src, size_t maxBufferLength)
//log_warning("converted %s of size %d, %d", dst, byte_diff, strlen(dst));
int result = byte_diff;
free(buffer_orig);
-#endif // _WIN32
+#endif // __WINDOWS__
return result;
}
diff --git a/src/network/http.cpp b/src/network/http.cpp
index 80fc1672ca..530ab1a3bc 100644
--- a/src/network/http.cpp
+++ b/src/network/http.cpp
@@ -10,11 +10,12 @@ void http_dispose() { }
#else
-#include
#include "../core/Math.hpp"
-// cURL includes windows.h, but we don't need all of it.
-#define WIN32_LEAN_AND_MEAN
+#ifdef __WINDOWS__
+ // cURL includes windows.h, but we don't need all of it.
+ #define WIN32_LEAN_AND_MEAN
+#endif
#include
#define MIME_TYPE_APPLICATION_JSON "application/json"
@@ -117,7 +118,7 @@ http_json_response *http_request_json(const http_json_request *request)
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
-#ifdef _WIN32
+#ifdef __WINDOWS__
// On GNU/Linux (and OS X), curl will use the system certs by default
curl_easy_setopt(curl, CURLOPT_CAINFO, "curl-ca-bundle.crt");
#endif
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 1754518530..b9558c9f5f 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -306,7 +306,7 @@ bool NetworkConnection::SetNonBlocking(bool on)
bool NetworkConnection::SetNonBlocking(SOCKET socket, bool on)
{
-#ifdef _WIN32
+#ifdef __WINDOWS__
u_long nonblocking = on;
return ioctlsocket(socket, FIONBIO, &nonblocking) == 0;
#else
@@ -429,7 +429,7 @@ Network::~Network()
bool Network::Init()
{
-#ifdef _WIN32
+#ifdef __WINDOWS__
if (!wsa_initialized) {
log_verbose("Initialising WSA");
WSADATA wsa_data;
@@ -468,7 +468,7 @@ void Network::Close()
game_command_queue.clear();
player_list.clear();
-#ifdef _WIN32
+#ifdef __WINDOWS__
if (wsa_initialized) {
WSACleanup();
wsa_initialized = false;
@@ -1249,7 +1249,7 @@ NetworkPlayer* Network::AddPlayer(const char* name)
void Network::PrintError()
{
-#ifdef _WIN32
+#ifdef __WINDOWS__
wchar_t *s = NULL;
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, LAST_SOCKET_ERROR(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&s, 0, NULL);
fprintf(stderr, "%S\n", s);
diff --git a/src/network/network.h b/src/network/network.h
index 3eefa4f923..2c57c76c83 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -63,7 +63,7 @@ extern "C" {
#ifndef DISABLE_NETWORK
-#ifdef _WIN32
+#ifdef __WINDOWS__
#include
#include
#define LAST_SOCKET_ERROR() WSAGetLastError()
@@ -88,7 +88,7 @@ extern "C" {
#define LAST_SOCKET_ERROR() errno
#define closesocket close
#define ioctlsocket ioctl
-#endif // _WIN32
+#endif // __WINDOWS__
// Fixes issues on OS X
#if defined(_RCT2_H_) && !defined(_MSC_VER)
diff --git a/src/openrct2.c b/src/openrct2.c
index a02315f4ad..f519ea9863 100644
--- a/src/openrct2.c
+++ b/src/openrct2.c
@@ -517,7 +517,7 @@ bool openrct2_setup_rct2_segment()
if (err != 0)
{
err = errno;
-#ifdef __linux__
+#ifdef __LINUX__
// On Linux ENOMEM means all requested range is unmapped
if (err != ENOMEM)
{
@@ -527,7 +527,7 @@ bool openrct2_setup_rct2_segment()
#else
pagesMissing = true;
perror("mincore");
-#endif // __linux__
+#endif // __LINUX__
} else {
for (int i = 0; i < numPages; i++)
{
diff --git a/src/platform/linux.c b/src/platform/linux.c
index 98edb78e5e..85eced0d7b 100644
--- a/src/platform/linux.c
+++ b/src/platform/linux.c
@@ -18,13 +18,15 @@
* along with this program. If not, see .
*****************************************************************************/
-#if defined(__linux__)
+#include "../common.h"
+
+#ifdef __LINUX__
-#include "platform.h"
#include
-#include
+#include
+
#include "../util/util.h"
-#include "fontconfig/fontconfig.h"
+#include "platform.h"
// See http://syprog.blogspot.ru/2011/12/listing-loaded-shared-objects-in-linux.html
struct lmap {
diff --git a/src/platform/platform.h b/src/platform/platform.h
index baadd6a6e1..24717e007b 100644
--- a/src/platform/platform.h
+++ b/src/platform/platform.h
@@ -21,20 +21,21 @@
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
-#ifdef _WIN32
+#include "../common.h"
+
+#ifdef __WINDOWS__
#define HAVE_MATH_H
-#endif // _WIN32
+#endif // __WINDOWS__
#include
-#include "../common.h"
#include "../drawing/font.h"
#ifndef MAX_PATH
#define MAX_PATH 260
#endif
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
#define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI
#else
#define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL
@@ -171,7 +172,7 @@ bool platform_check_steam_overlay_attached();
datetime64 platform_get_datetime_now_utc();
// Windows specific definitions
-#ifdef _WIN32
+#ifdef __WINDOWS__
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
@@ -179,6 +180,6 @@ datetime64 platform_get_datetime_now_utc();
int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset);
HWND windows_get_window_handle();
-#endif // _WIN32
+#endif // __WINDOWS__
#endif
diff --git a/src/platform/shared.c b/src/platform/shared.c
index 2fb64c3220..e17af7bc71 100644
--- a/src/platform/shared.c
+++ b/src/platform/shared.c
@@ -902,7 +902,7 @@ void platform_set_cursor(char cursor)
static void platform_load_cursors()
{
RCT2_GLOBAL(0x14241BC, uint32) = 2;
-#ifdef _WIN32
+#ifdef __WINDOWS__
HINSTANCE hInst = RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE);
RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ARROW, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x74));
RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_BLANK, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA1));
@@ -933,7 +933,7 @@ static void platform_load_cursors()
RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_CLOSED, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA5));
#else
STUB();
-#endif // _WIN32
+#endif // __WINDOWS__
_cursors[0] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
_cursors[1] = SDL_CreateCursor(blank_cursor_data, blank_cursor_mask, 32, 32, BLANK_CURSOR_HOTX, BLANK_CURSOR_HOTY);
diff --git a/src/platform/windows.c b/src/platform/windows.c
index a70cc6c9e4..c0ff4ca093 100644
--- a/src/platform/windows.c
+++ b/src/platform/windows.c
@@ -18,7 +18,9 @@
* along with this program. If not, see .
*****************************************************************************/
-#ifdef _WIN32
+#include "../common.h"
+
+#ifdef __WINDOWS__
#include
#include
diff --git a/src/rct2.c b/src/rct2.c
index 358a1806fe..d7c016093c 100644
--- a/src/rct2.c
+++ b/src/rct2.c
@@ -498,7 +498,7 @@ const utf8 *get_file_path(int pathId)
*/
void get_system_info()
{
-#ifdef _WIN32
+#ifdef __WINDOWS__
OSVERSIONINFO versionInfo;
SYSTEM_INFO sysInfo;
MEMORYSTATUS memInfo;
@@ -510,12 +510,12 @@ void get_system_info()
RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = versionInfo.dwMinorVersion;
RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = versionInfo.dwBuildNumber;
} else {
-#endif // _WIN32
+#endif // __WINDOWS__
RCT2_GLOBAL(RCT2_ADDRESS_OS_PLATFORM_ID, uint32) = -1;
RCT2_GLOBAL(RCT2_ADDRESS_OS_MAJOR_VERSION, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = 0;
RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = 0;
-#ifdef _WIN32
+#ifdef __WINDOWS__
}
GetSystemInfo(&sysInfo);
@@ -558,7 +558,7 @@ void get_system_info()
RCT2_GLOBAL(0x01423C20, uint32) = (SDL_HasMMX() == SDL_TRUE);
#else
STUB();
-#endif // _WIN32
+#endif // __WINDOWS__
}
@@ -595,12 +595,12 @@ void get_local_time()
*/
void *rct2_malloc(size_t numBytes)
{
- #ifdef _WIN32
+ #ifdef __WINDOWS__
return RCT2_CALLFUNC_1(0x004068B2, void*, size_t, numBytes);
#else
//log_warning("call rct's function");
return malloc(numBytes);
- #endif // _WIN32
+ #endif // __WINDOWS__
}
/**
@@ -610,12 +610,12 @@ void *rct2_malloc(size_t numBytes)
*/
void *rct2_realloc(void *block, size_t numBytes)
{
- #ifdef _WIN32
+ #ifdef __WINDOWS__
return RCT2_CALLFUNC_2(0x004068BD, void*, void*, size_t, block, numBytes);
#else
//log_warning("call rct's function");
return realloc(block, numBytes);
- #endif // _WIN32
+ #endif // __WINDOWS__
}
/**
@@ -624,10 +624,10 @@ void *rct2_realloc(void *block, size_t numBytes)
*/
void rct2_free(void *block)
{
- #ifdef _WIN32
+ #ifdef __WINDOWS__
RCT2_CALLPROC_1(0x004068CD, void*, block);
#else
//log_warning("call rct's function");
free(block);
- #endif // _WIN32
+ #endif // __WINDOWS__
}
diff --git a/src/rct2.h b/src/rct2.h
index 5b949c3150..bfa1702c1a 100644
--- a/src/rct2.h
+++ b/src/rct2.h
@@ -21,6 +21,8 @@
#ifndef _RCT2_H_
#define _RCT2_H_
+#include
+
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
diff --git a/src/version.h b/src/version.h
index e3a3124ff5..054e208913 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,18 +1,20 @@
#ifndef _VERSION_H_
#define _VERSION_H_
+#include "common.h"
+
#define OPENRCT2_NAME "OpenRCT2"
#define OPENRCT2_VERSION "0.0.4"
#define OPENRCT2_ARCHITECTURE "x86"
// Platform
-#ifdef _WIN32
+#ifdef __WINDOWS__
#define OPENRCT2_PLATFORM "Windows"
-#endif // _WIN32
-#ifdef __linux__
+#endif
+#ifdef __LINUX__
#define OPENRCT2_PLATFORM "Linux"
#endif
-#if defined(__APPLE__) && defined(__MACH__)
+#ifdef __MACOSX__
#define OPENRCT2_PLATFORM "OS X"
#endif
#ifndef OPENRCT2_PLATFORM
diff --git a/src/windows/options.c b/src/windows/options.c
index 2e6158f6ee..d2e773806a 100644
--- a/src/windows/options.c
+++ b/src/windows/options.c
@@ -522,7 +522,7 @@ static void window_options_mouseup(rct_window *w, int widgetIndex)
break;
case WIDX_HARDWARE_DISPLAY_CHECKBOX:
gConfigGeneral.hardware_display ^= 1;
-#ifdef _WIN32
+#ifdef __WINDOWS__
// Windows is apparently able to switch to hardware rendering on the fly although
// using the same window in an unaccelerated and accelerated context is unsupported by SDL2
gHardwareDisplay = gConfigGeneral.hardware_display;
@@ -1316,11 +1316,11 @@ static void window_options_invalidate(rct_window *w)
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = STR_SOUND_NONE;
}
else {
-#ifndef __linux__
+#ifndef __LINUX__
if (currentSoundDevice == 0)
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 5510;
else
-#endif // __linux__
+#endif // __LINUX__
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, uint16) = 1170;
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS + 2, uint32) = (uint32)gAudioDevices[currentSoundDevice].name;