2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-10-06 18:36:58 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
2015-09-22 22:45:03 +02:00
|
|
|
*
|
2016-05-04 19:24:41 +02:00
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
2015-09-22 22:45:03 +02:00
|
|
|
*
|
2014-10-06 18:36:58 +02:00
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
2014-10-06 18:36:58 +02:00
|
|
|
*****************************************************************************/
|
2016-05-04 19:24:41 +02:00
|
|
|
#pragma endregion
|
2015-09-22 22:45:03 +02:00
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#ifndef _COMMON_H_
|
|
|
|
#define _COMMON_H_
|
|
|
|
|
2014-11-21 19:39:56 +01:00
|
|
|
#include "diagnostic.h"
|
2014-10-06 18:36:58 +02:00
|
|
|
#include "rct2.h"
|
|
|
|
|
2015-09-22 22:45:03 +02:00
|
|
|
#define SafeFree(x) do { free(x); (x) = NULL; } while (0)
|
2015-02-16 23:47:11 +01:00
|
|
|
|
2015-09-22 22:45:03 +02:00
|
|
|
#define SafeDelete(x) do { delete (x); (x) = nullptr; } while (0)
|
|
|
|
#define SafeDeleteArray(x) do { delete[] (x); (x) = nullptr; } while (0)
|
2015-09-05 00:27:47 +02:00
|
|
|
|
2015-09-12 19:17:25 +02:00
|
|
|
#ifndef interface
|
|
|
|
#define interface struct
|
|
|
|
#endif
|
2015-09-05 00:27:47 +02:00
|
|
|
#define abstract = 0
|
2015-08-29 03:05:21 +02:00
|
|
|
|
2016-04-22 08:59:50 +02:00
|
|
|
#if defined(__i386__) || defined(_M_IX86)
|
2016-04-21 22:18:59 +02:00
|
|
|
#define PLATFORM_X86
|
2016-05-01 19:11:41 +02:00
|
|
|
#else
|
|
|
|
#define NO_RCT2 1
|
2016-04-21 22:18:59 +02:00
|
|
|
#endif
|
|
|
|
|
2016-06-03 00:18:20 +02:00
|
|
|
#if defined(__LP64__) || defined(_WIN64)
|
|
|
|
#define PLATFORM_64BIT
|
|
|
|
#else
|
|
|
|
#define PLATFORM_32BIT
|
|
|
|
#endif
|
|
|
|
|
2016-06-01 16:40:31 +02:00
|
|
|
// C99's restrict keywords guarantees the pointer in question, for the whole of its lifetime,
|
|
|
|
// will be the only way to access a given memory region. In other words: there is no other pointer
|
|
|
|
// aliasing the same memory area. Using it lets compiler generate better code. If your compiler
|
|
|
|
// does not support it, feel free to drop it, at some performance hit.
|
|
|
|
#ifdef __cplusplus
|
2016-07-09 10:05:12 +02:00
|
|
|
#ifdef _MSC_VER
|
2016-06-01 18:44:06 +02:00
|
|
|
#define RESTRICT __restrict
|
|
|
|
#else
|
2016-06-01 16:40:31 +02:00
|
|
|
#define RESTRICT __restrict__
|
|
|
|
#endif
|
|
|
|
#else
|
2016-07-09 10:05:12 +02:00
|
|
|
#ifdef _MSC_VER
|
2016-06-01 18:44:06 +02:00
|
|
|
#define RESTRICT __restrict
|
|
|
|
#else
|
2016-06-01 16:40:31 +02:00
|
|
|
#define RESTRICT restrict
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef RESTRICT
|
|
|
|
#define RESTRICT
|
|
|
|
#endif
|
|
|
|
|
2016-06-02 20:40:29 +02:00
|
|
|
#ifdef __cplusplus
|
2016-06-03 10:54:44 +02:00
|
|
|
#define assert_struct_size(x, y) static_assert(sizeof(x) == (y), "Improper struct size")
|
2016-06-02 20:40:29 +02:00
|
|
|
#else
|
|
|
|
// Visual Studio does not know _Static_assert
|
|
|
|
#if !defined(_MSC_VER)
|
2016-06-03 10:54:44 +02:00
|
|
|
#define assert_struct_size(x, y) _Static_assert(sizeof(x) == (y), "Improper struct size")
|
2016-06-02 20:40:29 +02:00
|
|
|
#else
|
2016-06-03 10:54:44 +02:00
|
|
|
#define assert_struct_size(x, y)
|
2016-06-02 20:40:29 +02:00
|
|
|
#endif // !defined(_MSC_VER)
|
|
|
|
#endif
|
|
|
|
|
2016-04-21 22:18:59 +02:00
|
|
|
#ifdef PLATFORM_X86
|
2016-05-28 22:37:54 +02:00
|
|
|
#ifndef FASTCALL
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define FASTCALL __attribute__((fastcall))
|
|
|
|
#elif _MSC_VER
|
|
|
|
#define FASTCALL __fastcall
|
|
|
|
#else
|
|
|
|
#pragma message "Not using fastcall calling convention, please check your compiler support"
|
|
|
|
#define FASTCALL
|
|
|
|
#endif
|
|
|
|
#endif // FASTCALL
|
2016-04-21 22:18:59 +02:00
|
|
|
#else // PLATFORM_X86
|
2016-05-28 22:37:54 +02:00
|
|
|
#define FASTCALL
|
2016-04-21 22:18:59 +02:00
|
|
|
#endif // PLATFORM_X86
|
2016-02-20 11:12:00 +01:00
|
|
|
|
2015-09-22 22:45:03 +02:00
|
|
|
#endif
|