From 54e622659d2f14ad0cc975dd88cd11b8990ba8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 30 Nov 2016 12:07:10 +0100 Subject: [PATCH] Extract common parts from rct2.h to common.h --- src/ScenarioRepository.cpp | 1 + src/audio/audio.c | 1 + src/audio/mixer.cpp | 1 + src/cmdline/ConvertCommand.cpp | 1 + src/common.h | 160 +++++++++++++++++- src/core/Console.hpp | 2 + src/core/Memory.hpp | 1 + src/drawing/NewDrawing.cpp | 1 + src/drawing/drawing.c | 1 + src/drawing/engines/SoftwareDrawingEngine.cpp | 1 + src/drawing/sprite.c | 1 + src/drawing/string.c | 1 + src/input.c | 1 + src/interface/chat.c | 1 + src/interface/console.c | 1 + src/interface/screenshot.c | 1 + src/interface/title_sequences.c | 1 + src/interface/viewport.c | 1 + src/intro.c | 1 + src/management/news_item.c | 1 + src/network/twitch.cpp | 1 + src/object/ObjectRepository.cpp | 1 + src/paint/map_element/surface.c | 1 + src/peep/peep.c | 1 + src/platform/platform.h | 1 + src/platform/shared.c | 1 + src/rct2.h | 160 +----------------- src/rct2/S6Exporter.cpp | 1 + src/rct2/S6Importer.cpp | 1 + src/ride/TrackDesignRepository.cpp | 1 + src/ride/ride_ratings.c | 1 + src/windows/changelog.c | 1 + src/windows/clear_scenery.c | 1 + src/windows/debug_paint.c | 1 + src/windows/dropdown.c | 1 + src/windows/editor_main.c | 1 + src/windows/editor_objective_options.c | 1 + src/windows/editor_scenario_options.c | 1 + src/windows/error.c | 1 + src/windows/footpath.c | 2 + src/windows/game_bottom_toolbar.c | 1 + src/windows/land.c | 1 + src/windows/land_rights.c | 1 + src/windows/main.c | 1 + src/windows/map.c | 1 + src/windows/options.c | 1 + src/windows/park.c | 1 + src/windows/ride.c | 1 + src/windows/save_prompt.c | 1 + src/windows/scenery.c | 1 + src/windows/staff_list.c | 1 + src/windows/title_command_editor.c | 1 + src/windows/title_editor.c | 1 + src/windows/title_exit.c | 1 + src/windows/title_options.c | 1 + src/windows/tooltip.c | 1 + src/windows/track_manage.c | 1 + src/windows/water.c | 1 + src/world/climate.c | 1 + src/world/footpath.c | 5 + src/world/map.c | 1 + src/world/park.c | 1 + 62 files changed, 226 insertions(+), 160 deletions(-) diff --git a/src/ScenarioRepository.cpp b/src/ScenarioRepository.cpp index 4a4d5b0b7b..39de3c989d 100644 --- a/src/ScenarioRepository.cpp +++ b/src/ScenarioRepository.cpp @@ -31,6 +31,7 @@ extern "C" #include "config.h" #include "localisation/localisation.h" #include "scenario.h" + #include "rct2.h" } static int ScenarioCategoryCompare(int categoryA, int categoryB) diff --git a/src/audio/audio.c b/src/audio/audio.c index 6d69d80285..b255e6532e 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -23,6 +23,7 @@ #include "../util/util.h" #include "../localisation/string_ids.h" #include "../intro.h" +#include "../rct2.h" typedef struct rct_audio_params { bool in_range; diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 2b03f1b9f4..859ae66a77 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -20,6 +20,7 @@ extern "C" { #include "../platform/platform.h" #include "../localisation/localisation.h" #include "../openrct2.h" + #include "../rct2.h" #include "audio.h" } #include "mixer.h" diff --git a/src/cmdline/ConvertCommand.cpp b/src/cmdline/ConvertCommand.cpp index a6ae65d4d4..b0a4bfde41 100644 --- a/src/cmdline/ConvertCommand.cpp +++ b/src/cmdline/ConvertCommand.cpp @@ -26,6 +26,7 @@ extern "C" { #include "../game.h" #include "../openrct2.h" + #include "../rct2.h" #include "../interface/window.h" } diff --git a/src/common.h b/src/common.h index 7de291a628..4172604263 100644 --- a/src/common.h +++ b/src/common.h @@ -17,8 +17,166 @@ #ifndef _COMMON_H_ #define _COMMON_H_ +#include + +#ifndef _USE_MATH_DEFINES +#define _USE_MATH_DEFINES +#endif +#undef M_PI + +#ifdef _MSC_VER +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + #include "diagnostic.h" -#include "rct2.h" + +typedef int8_t sint8; +typedef int16_t sint16; +typedef int32_t sint32; +typedef int64_t sint64; +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; + +typedef char utf8; +typedef utf8* utf8string; +typedef const utf8* const_utf8string; +#ifdef __WINDOWS__ +typedef wchar_t utf16; +typedef utf16* utf16string; +#endif + +typedef uint32 codepoint_t; +typedef uint8 colour_t; + +#define rol8(x, shift) (((uint8)(x) << (shift)) | ((uint8)(x) >> (8 - (shift)))) +#define ror8(x, shift) (((uint8)(x) >> (shift)) | ((uint8)(x) << (8 - (shift)))) +#define rol16(x, shift) (((uint16)(x) << (shift)) | ((uint16)(x) >> (16 - (shift)))) +#define ror16(x, shift) (((uint16)(x) >> (shift)) | ((uint16)(x) << (16 - (shift)))) +#define rol32(x, shift) (((uint32)(x) << (shift)) | ((uint32)(x) >> (32 - (shift)))) +#define ror32(x, shift) (((uint32)(x) >> (shift)) | ((uint32)(x) << (32 - (shift)))) +#define rol64(x, shift) (((uint64)(x) << (shift)) | ((uint32)(x) >> (64 - (shift)))) +#define ror64(x, shift) (((uint64)(x) >> (shift)) | ((uint32)(x) << (64 - (shift)))) + +#ifndef __cplusplus +// in C++ you should be using Math::Min and Math::Max +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#endif // __cplusplus + +#define sgn(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0)) +#define clamp(l, x, h) (min(h, max(l, x))) + +// Rounds an integer down to the given power of 2. y must be a power of 2. +#define floor2(x, y) ((x) & (~((y) - 1))) + +// Rounds an integer up to the given power of 2. y must be a power of 2. +#define ceil2(x, y) (((x) + (y) - 1) & (~((y) - 1))) + + +#ifndef __cplusplus +// in C++ you should be using Util::CountOf +#ifdef __GNUC__ +/** + * Force a compilation error if condition is true, but also produce a + * result (of value 0 and type size_t), so the expression can be used + * e.g. in a structure initializer (or where-ever else comma expressions + * aren't permitted). + */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) + +/* &a[0] degrades to a pointer: a different type from an array */ +#define __must_be_array(a) \ + BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) + +// based on http://lxr.free-electrons.com/source/include/linux/kernel.h#L54 +#define countof(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +#elif defined (_MSC_VER) +#define countof(arr) _countof(arr) +#else +#define countof(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif // __GNUC__ +#endif // __cplusplus + +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#include +#define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) +#define _strcmpi _stricmp +#define _stricmp(x, y) strcasecmp((x), (y)) +#define _strnicmp(x, y, n) strncasecmp((x), (y), (n)) +#define _strdup(x) strdup((x)) + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ +#define LOBYTE(w) ((uint8)(w)) +#define HIBYTE(w) ((uint8)(((uint16)(w)>>8)&0xFF)) +#endif // __BYTE_ORDER__ + +#ifndef RCT2_ENDIANESS +#error Unknown endianess! +#endif // RCT2_ENDIANESS + +#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + +#if !((defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700)) +char *strndup(const char *src, size_t size); +#endif // !(POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) + +// BSD and macOS have MAP_ANON instead of MAP_ANONYMOUS +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + +#include "version.h" + +#define OPENRCT2_MASTER_SERVER_URL "https://servers.openrct2.website" + +// Time (represented as number of 100-nanosecond intervals since 0001-01-01T00:00:00Z) +typedef uint64 datetime64; + +#define DATETIME64_MIN ((datetime64)0) + +// Represent fixed point numbers. dp = decimal point +typedef uint8 fixed8_1dp; +typedef uint8 fixed8_2dp; +typedef sint16 fixed16_1dp; +typedef sint16 fixed16_2dp; +typedef sint32 fixed32_1dp; +typedef sint32 fixed32_2dp; + +// Money is stored as a multiple of 0.10. +typedef fixed8_1dp money8; +typedef fixed16_1dp money16; +typedef fixed32_1dp money32; + +// Construct a fixed point number. For example, to create the value 3.65 you +// would write FIXED_2DP(3,65) +#define FIXED_XDP(x, whole, fraction) ((whole) * (10 * x) + (fraction)) +#define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction) +#define FIXED_2DP(whole, fraction) FIXED_XDP(10, whole, fraction) + +// Construct a money value in the format MONEY(10,70) to represent 10.70. Fractional part must be two digits. +#define MONEY(whole, fraction) ((whole) * 10 + ((fraction) / 10)) + +#define MONEY_FREE MONEY(0,00) +#define MONEY32_UNDEFINED ((money32)0x80000000) + +typedef void (EMPTY_ARGS_VOID_POINTER)(); +typedef unsigned short rct_string_id; #define SafeFree(x) do { free(x); (x) = NULL; } while (0) diff --git a/src/core/Console.hpp b/src/core/Console.hpp index 9b1d82f310..a763e6a056 100644 --- a/src/core/Console.hpp +++ b/src/core/Console.hpp @@ -21,6 +21,8 @@ extern "C" #include "../common.h" } +#include + namespace Console { void Write(char c); diff --git a/src/core/Memory.hpp b/src/core/Memory.hpp index 2a1c79f6b6..62b1e523ae 100644 --- a/src/core/Memory.hpp +++ b/src/core/Memory.hpp @@ -19,6 +19,7 @@ #include "../common.h" #include "Guard.hpp" #include +#include /** * Utility methods for memory management. Typically helpers and wrappers around the C standard library. diff --git a/src/drawing/NewDrawing.cpp b/src/drawing/NewDrawing.cpp index 4db7ea31fe..8046a3dc00 100644 --- a/src/drawing/NewDrawing.cpp +++ b/src/drawing/NewDrawing.cpp @@ -26,6 +26,7 @@ extern "C" #include "../interface/screenshot.h" #include "../localisation/string_ids.h" #include "../platform/platform.h" + #include "../rct2.h" } static sint32 _drawingEngineType = DRAWING_ENGINE_SOFTWARE; diff --git a/src/drawing/drawing.c b/src/drawing/drawing.c index 0d45490eaf..0e09782456 100644 --- a/src/drawing/drawing.c +++ b/src/drawing/drawing.c @@ -21,6 +21,7 @@ #include "../object.h" #include "../world/water.h" #include "drawing.h" +#include "../rct2.h" // HACK These were originally passed back through registers int gLastDrawStringX; diff --git a/src/drawing/engines/SoftwareDrawingEngine.cpp b/src/drawing/engines/SoftwareDrawingEngine.cpp index 433bf138ad..22d0cdd85a 100644 --- a/src/drawing/engines/SoftwareDrawingEngine.cpp +++ b/src/drawing/engines/SoftwareDrawingEngine.cpp @@ -31,6 +31,7 @@ extern "C" #include "../../intro.h" #include "../drawing.h" #include "../lightfx.h" + #include "../../rct2.h" } class SoftwareDrawingEngine; diff --git a/src/drawing/sprite.c b/src/drawing/sprite.c index 2298b1a875..a8a4593192 100644 --- a/src/drawing/sprite.c +++ b/src/drawing/sprite.c @@ -21,6 +21,7 @@ #include "../sprites.h" #include "../util/util.h" #include "drawing.h" +#include "../rct2.h" void *_g1Buffer = NULL; diff --git a/src/drawing/string.c b/src/drawing/string.c index ee029338f6..2ae44790de 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -23,6 +23,7 @@ #include "../util/util.h" #include "../world/map.h" #include "drawing.h" +#include "../rct2.h" enum { TEXT_DRAW_FLAG_INSET = 1 << 0, diff --git a/src/input.c b/src/input.c index a0f8ee802c..8409c7fac4 100644 --- a/src/input.c +++ b/src/input.c @@ -37,6 +37,7 @@ #include "world/sprite.h" #include "world/scenery.h" #include "openrct2.h" +#include "rct2.h" typedef struct rct_mouse_data { uint32 x; diff --git a/src/interface/chat.c b/src/interface/chat.c index aeebf1c37d..79c98f9e7b 100644 --- a/src/interface/chat.c +++ b/src/interface/chat.c @@ -22,6 +22,7 @@ #include "../network/network.h" #include "../platform/platform.h" #include "../util/util.h" +#include "../rct2.h" bool gChatOpen = false; char _chatCurrentLine[CHAT_MAX_MESSAGE_LENGTH]; diff --git a/src/interface/console.c b/src/interface/console.c index cfc2493072..54b4891bcf 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -31,6 +31,7 @@ #include "../object.h" #include "../object/ObjectManager.h" #include "../object/ObjectRepository.h" +#include "../rct2.h" #include "../world/banner.h" #include "../world/climate.h" #include "../world/scenery.h" diff --git a/src/interface/screenshot.c b/src/interface/screenshot.c index 7520da4404..bb26c32bc8 100644 --- a/src/interface/screenshot.c +++ b/src/interface/screenshot.c @@ -23,6 +23,7 @@ #include "../localisation/localisation.h" #include "../openrct2.h" #include "../platform/platform.h" +#include "../rct2.h" #include "../util/util.h" #include "../windows/error.h" #include "screenshot.h" diff --git a/src/interface/title_sequences.c b/src/interface/title_sequences.c index 622eebe698..a7d5978baa 100644 --- a/src/interface/title_sequences.c +++ b/src/interface/title_sequences.c @@ -19,6 +19,7 @@ #include "title_sequences.h" #include "../title.h" #include "../util/util.h" +#include "../rct2.h" uint16 gCurrentTitleSequence; diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 850c8c3aa1..8a715a3b82 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -21,6 +21,7 @@ #include "../input.h" #include "../localisation/localisation.h" #include "../peep/staff.h" +#include "../rct2.h" #include "../ride/ride_data.h" #include "../ride/track_data.h" #include "../sprites.h" diff --git a/src/intro.c b/src/intro.c index 58c21b9d7a..0c0b2007ae 100644 --- a/src/intro.c +++ b/src/intro.c @@ -19,6 +19,7 @@ #include "drawing/drawing.h" #include "intro.h" #include "sprites.h" +#include "rct2.h" #define BACKROUND_COLOUR_DARK 10 #define BACKROUND_COLOUR_LOGO 245 diff --git a/src/management/news_item.c b/src/management/news_item.c index de55f9a4e4..c723719ee9 100644 --- a/src/management/news_item.c +++ b/src/management/news_item.c @@ -19,6 +19,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../localisation/localisation.h" +#include "../rct2.h" #include "../ride/ride.h" #include "../world/sprite.h" #include "../util/util.h" diff --git a/src/network/twitch.cpp b/src/network/twitch.cpp index db2e45f0bb..22b5ccc848 100644 --- a/src/network/twitch.cpp +++ b/src/network/twitch.cpp @@ -42,6 +42,7 @@ extern "C" #include "../localisation/localisation.h" #include "../management/news_item.h" #include "../peep/peep.h" + #include "../rct2.h" #include "../world/sprite.h" #include "../util/util.h" #include "http.h" diff --git a/src/object/ObjectRepository.cpp b/src/object/ObjectRepository.cpp index eaca2cd2a6..9033a9c700 100644 --- a/src/object/ObjectRepository.cpp +++ b/src/object/ObjectRepository.cpp @@ -45,6 +45,7 @@ extern "C" #include "../object.h" #include "../object_list.h" #include "../platform/platform.h" + #include "../rct2.h" #include "../util/sawyercoding.h" #include "../util/util.h" } diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index 0d5ca840fa..0b11c1742a 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -20,6 +20,7 @@ #include "../../peep/staff.h" #include "map_element.h" #include "surface.h" +#include "../../rct2.h" const uint8 byte_97B444[] = { 0, 2, 1, 3, 8, 10, 9, 11, 4, 6, diff --git a/src/peep/peep.c b/src/peep/peep.c index 4f42005c54..a8c3ef515f 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -26,6 +26,7 @@ #include "../management/news_item.h" #include "../openrct2.h" #include "../network/network.h" +#include "../rct2.h" #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../ride/track.h" diff --git a/src/platform/platform.h b/src/platform/platform.h index 82cb99d65c..6d636bda19 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -20,6 +20,7 @@ #include "../common.h" #ifdef __WINDOWS__ +#include "../rct2.h" #ifndef HAVE_MATH_H #define HAVE_MATH_H #endif diff --git a/src/platform/shared.c b/src/platform/shared.c index ff75fbb520..ed1bf5b4db 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -28,6 +28,7 @@ #include "../localisation/currency.h" #include "../localisation/localisation.h" #include "../openrct2.h" +#include "../rct2.h" #include "../title.h" #include "../util/util.h" #include "../world/climate.h" diff --git a/src/rct2.h b/src/rct2.h index f9597746ba..3f450067e3 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -17,165 +17,7 @@ #ifndef _RCT2_H_ #define _RCT2_H_ -#include -#include - -#ifndef _USE_MATH_DEFINES - #define _USE_MATH_DEFINES -#endif -#undef M_PI - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER - #include -#endif - -typedef int8_t sint8; -typedef int16_t sint16; -typedef int32_t sint32; -typedef int64_t sint64; -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; - -typedef char utf8; -typedef utf8* utf8string; -typedef const utf8* const_utf8string; -typedef wchar_t utf16; -typedef utf16* utf16string; - -typedef uint32 codepoint_t; -typedef uint8 colour_t; - -#define rol8(x, shift) (((uint8)(x) << (shift)) | ((uint8)(x) >> (8 - (shift)))) -#define ror8(x, shift) (((uint8)(x) >> (shift)) | ((uint8)(x) << (8 - (shift)))) -#define rol16(x, shift) (((uint16)(x) << (shift)) | ((uint16)(x) >> (16 - (shift)))) -#define ror16(x, shift) (((uint16)(x) >> (shift)) | ((uint16)(x) << (16 - (shift)))) -#define rol32(x, shift) (((uint32)(x) << (shift)) | ((uint32)(x) >> (32 - (shift)))) -#define ror32(x, shift) (((uint32)(x) >> (shift)) | ((uint32)(x) << (32 - (shift)))) -#define rol64(x, shift) (((uint64)(x) << (shift)) | ((uint32)(x) >> (64 - (shift)))) -#define ror64(x, shift) (((uint64)(x) >> (shift)) | ((uint32)(x) << (64 - (shift)))) - -#ifndef __cplusplus -// in C++ you should be using Math::Min and Math::Max -#ifndef min - #define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max - #define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif -#endif // __cplusplus - -#define sgn(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0)) -#define clamp(l, x, h) (min(h, max(l, x))) - -// Rounds an integer down to the given power of 2. y must be a power of 2. -#define floor2(x, y) ((x) & (~((y) - 1))) - -// Rounds an integer up to the given power of 2. y must be a power of 2. -#define ceil2(x, y) (((x) + (y) - 1) & (~((y) - 1))) - - -#ifndef __cplusplus -// in C++ you should be using Util::CountOf -#ifdef __GNUC__ -/** - * Force a compilation error if condition is true, but also produce a - * result (of value 0 and type size_t), so the expression can be used - * e.g. in a structure initializer (or where-ever else comma expressions - * aren't permitted). - */ -#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) - -/* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) - -// based on http://lxr.free-electrons.com/source/include/linux/kernel.h#L54 -#define countof(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) -#elif defined (_MSC_VER) - #define countof(arr) _countof(arr) -#else - #define countof(arr) (sizeof(arr) / sizeof((arr)[0])) -#endif // __GNUC__ -#endif // __cplusplus - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -#include -#define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) -#define _strcmpi _stricmp -#define _stricmp(x, y) strcasecmp((x), (y)) -#define _strnicmp(x, y, n) strncasecmp((x), (y), (n)) -#define _strdup(x) strdup((x)) - -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ -#define LOBYTE(w) ((uint8)(w)) -#define HIBYTE(w) ((uint8)(((uint16)(w)>>8)&0xFF)) -#endif // __BYTE_ORDER__ - -#ifndef RCT2_ENDIANESS -#error Unknown endianess! -#endif // RCT2_ENDIANESS - -#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) - -#if !((defined (_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700)) - char *strndup(const char *src, size_t size); -#endif // !(POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) - -// BSD and macOS have MAP_ANON instead of MAP_ANONYMOUS -#ifndef MAP_ANONYMOUS - #define MAP_ANONYMOUS MAP_ANON -#endif - -#include "version.h" - -#define OPENRCT2_MASTER_SERVER_URL "https://servers.openrct2.website" - -// Time (represented as number of 100-nanosecond intervals since 0001-01-01T00:00:00Z) -typedef uint64 datetime64; - -#define DATETIME64_MIN ((datetime64)0) - -// Represent fixed point numbers. dp = decimal point -typedef uint8 fixed8_1dp; -typedef uint8 fixed8_2dp; -typedef sint16 fixed16_1dp; -typedef sint16 fixed16_2dp; -typedef sint32 fixed32_1dp; -typedef sint32 fixed32_2dp; - -// Money is stored as a multiple of 0.10. -typedef fixed8_1dp money8; -typedef fixed16_1dp money16; -typedef fixed32_1dp money32; - -// Construct a fixed point number. For example, to create the value 3.65 you -// would write FIXED_2DP(3,65) -#define FIXED_XDP(x, whole, fraction) ((whole) * (10 * x) + (fraction)) -#define FIXED_1DP(whole, fraction) FIXED_XDP(1, whole, fraction) -#define FIXED_2DP(whole, fraction) FIXED_XDP(10, whole, fraction) - -// Construct a money value in the format MONEY(10,70) to represent 10.70. Fractional part must be two digits. -#define MONEY(whole, fraction) ((whole) * 10 + ((fraction) / 10)) - -#define MONEY_FREE MONEY(0,00) -#define MONEY32_UNDEFINED ((money32)0x80000000) - -typedef void (EMPTY_ARGS_VOID_POINTER)(); -typedef unsigned short rct_string_id; +#include "common.h" typedef struct rct2_install_info { uint32 installLevel; diff --git a/src/rct2/S6Exporter.cpp b/src/rct2/S6Exporter.cpp index 7c8aa2d050..90100b16cb 100644 --- a/src/rct2/S6Exporter.cpp +++ b/src/rct2/S6Exporter.cpp @@ -36,6 +36,7 @@ extern "C" #include "../object.h" #include "../openrct2.h" #include "../peep/staff.h" + #include "../rct2.h" #include "../ride/ride.h" #include "../ride/ride_ratings.h" #include "../scenario.h" diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 1e79e75873..5a555d6fac 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -32,6 +32,7 @@ extern "C" #include "../management/research.h" #include "../openrct2.h" #include "../peep/staff.h" + #include "../rct2.h" #include "../ride/ride.h" #include "../ride/ride_ratings.h" #include "../scenario.h" diff --git a/src/ride/TrackDesignRepository.cpp b/src/ride/TrackDesignRepository.cpp index 28238be952..a288154204 100644 --- a/src/ride/TrackDesignRepository.cpp +++ b/src/ride/TrackDesignRepository.cpp @@ -27,6 +27,7 @@ extern "C" { #include "../platform/platform.h" + #include "../rct2.h" #include "track_design.h" } diff --git a/src/ride/ride_ratings.c b/src/ride/ride_ratings.c index 766c988cba..99750fb01e 100644 --- a/src/ride/ride_ratings.c +++ b/src/ride/ride_ratings.c @@ -17,6 +17,7 @@ #include "../interface/window.h" #include "../localisation/date.h" #include "../world/map.h" +#include "../rct2.h" #include "ride.h" #include "ride_data.h" #include "ride_ratings.h" diff --git a/src/windows/changelog.c b/src/windows/changelog.c index 7d392f3e22..f16e376611 100644 --- a/src/windows/changelog.c +++ b/src/windows/changelog.c @@ -21,6 +21,7 @@ #include "../localisation/localisation.h" #include "../openrct2.h" #include "../platform/platform.h" +#include "../rct2.h" #include "../util/util.h" #include "../world/footpath.h" #include "../world/map.h" diff --git a/src/windows/clear_scenery.c b/src/windows/clear_scenery.c index 0c6322a3ce..04fa0899dc 100644 --- a/src/windows/clear_scenery.c +++ b/src/windows/clear_scenery.c @@ -16,6 +16,7 @@ #include "../input.h" #include "../localisation/localisation.h" +#include "../rct2.h" #include "../sprites.h" #include "../interface/themes.h" #include "../interface/widget.h" diff --git a/src/windows/debug_paint.c b/src/windows/debug_paint.c index e894e3e5fe..8caab9b573 100644 --- a/src/windows/debug_paint.c +++ b/src/windows/debug_paint.c @@ -19,6 +19,7 @@ #include "../interface/window.h" #include "../localisation/localisation.h" #include "../sprites.h" +#include "../rct2.h" #include "../world/map.h" #include "../interface/themes.h" #include "../paint/map_element/map_element.h" diff --git a/src/windows/dropdown.c b/src/windows/dropdown.c index a1c742e62f..3c71fb35cb 100644 --- a/src/windows/dropdown.c +++ b/src/windows/dropdown.c @@ -20,6 +20,7 @@ #include "../localisation/localisation.h" #include "../scenario.h" #include "../sprites.h" +#include "../rct2.h" #include "dropdown.h" int gAppropriateImageDropdownItemsPerRow[] = { diff --git a/src/windows/editor_main.c b/src/windows/editor_main.c index e7d4a2a85e..3912b55237 100644 --- a/src/windows/editor_main.c +++ b/src/windows/editor_main.c @@ -17,6 +17,7 @@ #include "../interface/viewport.h" #include "../interface/widget.h" #include "../interface/window.h" +#include "../rct2.h" #include "../world/footpath.h" static void window_editor_main_paint(rct_window *w, rct_drawpixelinfo *dpi); diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index aacca5151b..4a753f966d 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -21,6 +21,7 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../scenario.h" +#include "../rct2.h" #include "../util/util.h" #include "../world/climate.h" #include "../world/park.h" diff --git a/src/windows/editor_scenario_options.c b/src/windows/editor_scenario_options.c index 8885707f99..3280610b60 100644 --- a/src/windows/editor_scenario_options.c +++ b/src/windows/editor_scenario_options.c @@ -19,6 +19,7 @@ #include "../interface/window.h" #include "../management/finance.h" #include "../sprites.h" +#include "../rct2.h" #include "error.h" #include "dropdown.h" #include "../interface/themes.h" diff --git a/src/windows/error.c b/src/windows/error.c index 8a2101203b..cc606344af 100644 --- a/src/windows/error.c +++ b/src/windows/error.c @@ -18,6 +18,7 @@ #include "../localisation/localisation.h" #include "../interface/widget.h" #include "../interface/window.h" +#include "../rct2.h" #include "error.h" bool gDisableErrorWindowSound = false; diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 7c8d9f2287..7c5ac0809f 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -24,6 +24,8 @@ #include "../world/footpath.h" #include "dropdown.h" #include "../interface/themes.h" +#include "../cheats.h" +#include "../rct2.h" enum { PATH_CONSTRUCTION_MODE_LAND, diff --git a/src/windows/game_bottom_toolbar.c b/src/windows/game_bottom_toolbar.c index be3e784fb3..38aa089a50 100644 --- a/src/windows/game_bottom_toolbar.c +++ b/src/windows/game_bottom_toolbar.c @@ -27,6 +27,7 @@ #include "../peep/peep.h" #include "../peep/staff.h" #include "../sprites.h" +#include "../rct2.h" #include "../world/climate.h" #include "../world/park.h" #include "../world/sprite.h" diff --git a/src/windows/land.c b/src/windows/land.c index 16fb3a0dcb..447b9eb7ef 100644 --- a/src/windows/land.c +++ b/src/windows/land.c @@ -19,6 +19,7 @@ #include "../interface/window.h" #include "../localisation/localisation.h" #include "../sprites.h" +#include "../rct2.h" #include "../world/map.h" #include "dropdown.h" #include "../interface/themes.h" diff --git a/src/windows/land_rights.c b/src/windows/land_rights.c index 1e08ce48a7..1fb8d451e7 100644 --- a/src/windows/land_rights.c +++ b/src/windows/land_rights.c @@ -20,6 +20,7 @@ #include "../interface/viewport.h" #include "../localisation/localisation.h" #include "../sprites.h" +#include "../rct2.h" #include "../world/map.h" #include "../game.h" #include "../interface/themes.h" diff --git a/src/windows/main.c b/src/windows/main.c index 5f1a6209b7..908fd5b4c0 100644 --- a/src/windows/main.c +++ b/src/windows/main.c @@ -17,6 +17,7 @@ #include "../interface/viewport.h" #include "../interface/widget.h" #include "../interface/window.h" +#include "../rct2.h" #include "../world/footpath.h" rct_widget window_main_widgets[] = { diff --git a/src/windows/map.c b/src/windows/map.c index 807e98bde4..7fb7b827c6 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -24,6 +24,7 @@ #include "../interface/viewport.h" #include "../interface/window.h" #include "../sprites.h" +#include "../rct2.h" #include "../world/footpath.h" #include "../world/scenery.h" #include "error.h" diff --git a/src/windows/options.c b/src/windows/options.c index 242cf81a1a..9f17664749 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -35,6 +35,7 @@ #include "../localisation/date.h" #include "../localisation/localisation.h" #include "../platform/platform.h" +#include "../rct2.h" #include "../sprites.h" #include "../title.h" #include "dropdown.h" diff --git a/src/windows/park.c b/src/windows/park.c index 1ecaac51fa..6c1552f924 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -25,6 +25,7 @@ #include "../interface/window.h" #include "../management/award.h" #include "../peep/peep.h" +#include "../rct2.h" #include "../ride/ride.h" #include "../scenario.h" #include "../sprites.h" diff --git a/src/windows/ride.c b/src/windows/ride.c index 7b4e3ed284..4e0778a10f 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -28,6 +28,7 @@ #include "../object/ObjectManager.h" #include "../object/ObjectRepository.h" #include "../peep/staff.h" +#include "../rct2.h" #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../ride/track.h" diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index 8935708b62..ab90d39346 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -22,6 +22,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "../openrct2.h" +#include "../rct2.h" #include "../sprites.h" enum WINDOW_SAVE_PROMPT_WIDGET_IDX { diff --git a/src/windows/scenery.c b/src/windows/scenery.c index d8afcd98e6..583c3b8a82 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -23,6 +23,7 @@ #include "../interface/window.h" #include "../localisation/localisation.h" #include "../peep/peep.h" +#include "../rct2.h" #include "../world/map.h" #include "../world/scenery.h" #include "../world/sprite.h" diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index 7c6ae12ac2..b64db4772b 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -25,6 +25,7 @@ #include "../localisation/localisation.h" #include "../peep/peep.h" #include "../peep/staff.h" +#include "../rct2.h" #include "../sprites.h" #include "../world/footpath.h" #include "../world/sprite.h" diff --git a/src/windows/title_command_editor.c b/src/windows/title_command_editor.c index 4c0ad9a6de..50cd0e8460 100644 --- a/src/windows/title_command_editor.c +++ b/src/windows/title_command_editor.c @@ -19,6 +19,7 @@ #include "../interface/window.h" #include "../interface/viewport.h" #include "../localisation/localisation.h" +#include "../rct2.h" #include "../sprites.h" #include "../world/map.h" #include "../game.h" diff --git a/src/windows/title_editor.c b/src/windows/title_editor.c index c1b0db1e1e..003d846652 100644 --- a/src/windows/title_editor.c +++ b/src/windows/title_editor.c @@ -24,6 +24,7 @@ #include "../localisation/localisation.h" #include "../peep/peep.h" #include "../peep/staff.h" +#include "../rct2.h" #include "../world/sprite.h" #include "dropdown.h" #include "../interface/themes.h" diff --git a/src/windows/title_exit.c b/src/windows/title_exit.c index ed09619fa1..66360bd3ee 100644 --- a/src/windows/title_exit.c +++ b/src/windows/title_exit.c @@ -22,6 +22,7 @@ #include "../interface/window.h" #include "../interface/themes.h" #include "../intro.h" +#include "../rct2.h" static rct_widget window_title_exit_widgets[] = { { WWT_IMGBTN, 2, 0, 39, 0, 63, SPR_MENU_EXIT, STR_EXIT }, diff --git a/src/windows/title_options.c b/src/windows/title_options.c index 7b42f89125..a6992a7d39 100644 --- a/src/windows/title_options.c +++ b/src/windows/title_options.c @@ -21,6 +21,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "../interface/themes.h" +#include "../rct2.h" static rct_widget window_title_options_widgets[] = { { WWT_DROPDOWN_BUTTON, 2, 0, 79, 0, 11, STR_OPTIONS, STR_OPTIONS_TIP }, diff --git a/src/windows/tooltip.c b/src/windows/tooltip.c index 90621ce4cf..b9f1d8d821 100644 --- a/src/windows/tooltip.c +++ b/src/windows/tooltip.c @@ -19,6 +19,7 @@ #include "../input.h" #include "../interface/widget.h" #include "../interface/window.h" +#include "../rct2.h" #include "tooltip.h" enum { diff --git a/src/windows/track_manage.c b/src/windows/track_manage.c index 6de27798e5..5862da15d6 100644 --- a/src/windows/track_manage.c +++ b/src/windows/track_manage.c @@ -19,6 +19,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "../localisation/localisation.h" +#include "../rct2.h" #include "../ride/track.h" #include "../ride/track_design.h" #include "../ride/TrackDesignRepository.h" diff --git a/src/windows/water.c b/src/windows/water.c index dda15563b1..a20edcfb54 100644 --- a/src/windows/water.c +++ b/src/windows/water.c @@ -18,6 +18,7 @@ #include "../interface/widget.h" #include "../interface/window.h" #include "../localisation/localisation.h" +#include "../rct2.h" #include "../sprites.h" #include "../world/map.h" #include "../interface/themes.h" diff --git a/src/world/climate.c b/src/world/climate.c index 550f5c9a91..47266902f7 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -25,6 +25,7 @@ #include "../scenario.h" #include "../util/util.h" #include "climate.h" +#include "../rct2.h" #include "../sprites.h" enum { diff --git a/src/world/footpath.c b/src/world/footpath.c index c30166656f..a037d823b8 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -16,12 +16,17 @@ #include "../cheats.h" #include "../game.h" +#include "footpath.h" #include "../localisation/localisation.h" +#include "map.h" +#include "map_animation.h" #include "../network/network.h" #include "../util/util.h" #include "../object_list.h" +#include "../rct2.h" #include "../ride/track.h" #include "../ride/track_data.h" +#include "scenery.h" void footpath_interrupt_peeps(int x, int y, int z); void sub_6A7642(int x, int y, rct_map_element *mapElement); diff --git a/src/world/map.c b/src/world/map.c index 35b40a2442..ba7ecae200 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -26,6 +26,7 @@ #include "../management/finance.h" #include "../network/network.h" #include "../openrct2.h" +#include "../rct2.h" #include "../ride/ride_data.h" #include "../ride/track.h" #include "../ride/track_data.h" diff --git a/src/world/park.c b/src/world/park.c index a33d644e55..8e2fd71933 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -27,6 +27,7 @@ #include "../management/research.h" #include "../peep/peep.h" #include "../peep/staff.h" +#include "../rct2.h" #include "../ride/ride.h" #include "../ride/ride_data.h" #include "../scenario.h"