From 53023eb65bdcde43e341c1ecb7cf0c7f8ee524fb Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 7 Jul 2019 13:09:11 +0200 Subject: the great reorganization --- src/core/common.h | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 src/core/common.h (limited to 'src/core/common.h') diff --git a/src/core/common.h b/src/core/common.h new file mode 100644 index 00000000..79626acb --- /dev/null +++ b/src/core/common.h @@ -0,0 +1,178 @@ +#pragma once + +#define _CRT_SECURE_NO_WARNINGS +#define _USE_MATH_DEFINES +#pragma warning(disable: 4244) // int to float +#pragma warning(disable: 4800) // int to bool +#pragma warning(disable: 4305) // double to float +#pragma warning(disable: 4838) // narrowing conversion +#pragma warning(disable: 4996) // POSIX names + +#include +#include +//#include +#include + +#ifdef WITHD3D +#include +#include +#endif + +#include +#include + +#define rwVENDORID_ROCKSTAR 0x0253F2 + +// Get rid of bullshit windows definitions, we're not running on an 8086 +#ifdef far +#undef far +#endif +#ifdef near +#undef near +#endif + +typedef uint8_t uint8; +typedef int8_t int8; +typedef uint16_t uint16; +typedef int16_t int16; +typedef uint32_t uint32; +typedef int32_t int32; +typedef uintptr_t uintptr; +typedef uint64_t uint64; +typedef int64_t int64; +// hardcode ucs-2 +typedef uint16_t wchar; + +#define nil nullptr + +#include "config.h" + +#define ALIGNPTR(p) (void*)((((uintptr)(void*)p) + sizeof(void*)-1) & ~(sizeof(void*)-1)) + +// PDP-10 like byte functions +#define MASK(p, s) (((1<<(s))-1) << (p)) +inline uint32 dpb(uint32 b, uint32 p, uint32 s, uint32 w) +{ + uint32 m = MASK(p,s); + return w & ~m | b<

>p & (1<(high) ? (high) : (v)) + +inline float sq(float x) { return x*x; } +#define SQR(x) ((x) * (x)) + +#define PI M_PI +#define DEGTORAD(x) ((x) * PI / 180.0f) +#define RADTODEG(x) ((x) * 180.0f / PI) + +#ifdef USE_PS2_RAND +#define MYRAND_MAX 65535 +#else +#define MYRAND_MAX 32767 +#endif + +int myrand(void); +void mysrand(unsigned int seed); + +void re3_debug(char *format, ...); +void re3_trace(const char *filename, unsigned int lineno, const char *func, char *format, ...); +void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func); + +#define DEBUGBREAK() __debugbreak(); + +#define debug(f, ...) re3_debug("[DBG]: " f, __VA_ARGS__) +#define DEV(f, ...) re3_debug("[DEV]: " f, __VA_ARGS__) +#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, __VA_ARGS__) +#define Error(f, ...) re3_debug("[ERROR]: " f, __VA_ARGS__) + +#define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) ) +#define ASSERT assert + +#define _TODO(x) +#define _TODOCONST(x) (x) + +#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc) +#define VALIDATE_OFFSET(struc, member, offset) static_assert(offsetof(struc, member) == offset, "The offset of " #member " in " #struc " is not " #offset "...") + +#define PERCENT(x, p) ((float(x) * (float(p) / 100.0f))) +#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) +#define BIT(num) (1<<(num)) + +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) -- cgit v1.2.3