Leviathan  0.8.0.0
Leviathan game engine
Define.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2017 Henri Hyyryläinen
3 #pragma once
4 #include "Include.h"
5 
6 #include "ForwardDeclarations.h"
8 
14 #define NETWORK_USE_SNAPSHOTS
15 
16 #include <string>
17 
18 namespace Leviathan{
19 
21 constexpr auto TICKSPEED = 50;
22 
24 constexpr auto INTERPOLATION_TIME = 100;
25 
28 constexpr auto HEARTBEATS_MILLISECOND = 180;
29 
30 constexpr auto DEFAULT_MAXCONNECT_TRIES = 5;
31 
32 constexpr auto MAX_SERVERCOMMAND_LENGTH = 550;
33 
35 
36 constexpr auto PACKET_LOST_AFTER_MILLISECONDS = 1000;
37 
39 
40 constexpr auto CRITICAL_PACKET_MAX_TRIES = 8;
41 
43 constexpr float NORMALIZATION_TOLERANCE = 1e-6f;
44 
45 #ifdef LEVIATHAN_VERSION
46 constexpr double VERSION = LEVIATHAN_VERSION;
47 static const std::string VERSIONS = LEVIATHAN_VERSION_ANSIS;
48 
49 constexpr int VERSION_STABLE = LEVIATHAN_VERSION_STABLE;
50 constexpr int VERSION_MAJOR = LEVIATHAN_VERSION_MAJOR;
51 constexpr int VERSION_MINOR = LEVIATHAN_VERSION_MINOR;
52 constexpr int VERSION_PATCH = LEVIATHAN_VERSION_PATCH;
53 #endif //LEVIATHAN_VERSION
54 
55 constexpr auto MICROSECONDS_IN_SECOND = 1000000;
56 
57 #ifndef PI
58 constexpr float PI = 3.14159265f;
59 #endif //PI
60 constexpr float DEGREES_TO_RADIANS = PI/180.f;
61 constexpr float RADIANS_TO_DEGREES = 180.f/PI;
62 constexpr float EPSILON = 0.00000001f;
63 }
64 
65 // AngelScript type registration (that isn't ReferenceCounted)
66 #ifdef LEVIATHAN_USING_ANGELSCRIPT
67 #define REFERENCE_HANDLE_UNCOUNTED_TYPE(x) static constexpr auto ANGELSCRIPT_TYPE = #x "@";
68 // Appended @ because these are handle types
69 #define REFERENCE_HANDLE_UNCOUNTED_TYPE_NAMED(x, y) static constexpr auto ANGELSCRIPT_TYPE \
70  = #y "@";
71 #define VALUE_TYPE(x) static constexpr auto ANGELSCRIPT_TYPE = #x;
72 #define VALUE_TYPE_NAMED(x, y) static constexpr auto ANGELSCRIPT_TYPE = #y;
73 #else
74 #define REFERENCE_HANDLE_UNCOUNTED_TYPE(x)
75 #define REFERENCE_HANDLE_UNCOUNTED_TYPE_NAMED(x, y)
76 #define VALUE_TYPE(x)
77 #define VALUE_TYPE_NAMED(x)
78 #endif //LEVIATHAN_USING_ANGELSCRIPT
79 
80 // Logging macros //
81 #define LOG_INFO(x) Logger::Get()->Info(x);
82 #define LOG_WARNING(x) Logger::Get()->Warning(x);
83 #define LOG_ERROR(x) Logger::Get()->Error(x);
84 #define LOG_WRITE(x) Logger::Get()->Write(x);
85 #define LOG_FATAL(x) Logger::Get()->Fatal(x + (", at: " __FILE__ "(" + std::to_string(__LINE__) + ")"));
86 
87 // Assertions for controlled crashing
88 #ifndef LEVIATHAN_ASSERT
89 #include <stdlib.h>
90 #define LEVIATHAN_ASSERT(x, msg) {if(!(x)){ LOG_FATAL(msg); abort(); }};
91 #endif //LEVIATHAN_ASSERT
92 
93 #ifdef _MSC_VER
94 
95 #ifndef DEBUG_BREAK
96 #define DEBUG_BREAK __debugbreak();
97 #endif //DEBUG_BREAK
98 
99 #elif defined __linux
100 
101 // For making SIGINT work as debug break on linux //
102 #include <signal.h>
103 #ifndef DEBUG_BREAK
104 #define DEBUG_BREAK { LOG_WRITE("DEBUG_BREAK HIT! at:"); \
105  LOG_WRITE(__FILE__ "(" + std::to_string(__LINE__) + ")"); ::raise(SIGINT); }
106 #endif //DEBUG_BREAK
107 
108 #else
109 
110 #error "Debug break won't work"
111 
112 #endif
113 
114 #define SAFE_RELEASE( x ) {if(x){(x)->Release();(x)=NULL;}}
115 #define SAFE_RELEASEDEL( x ) {if(x){(x)->Release();delete (x);(x)=NULL;}}
116 #define SAFE_DELETE( x ) {if(x){delete (x);(x)=NULL;}}
117 #define SAFE_DELETE_ARRAY( x ) {if(x){delete[] (x);(x)=NULL;}}
118 
119 #define SAFE_RELEASE_VECTOR(x) {for(auto iter = x.begin(); iter != x.end(); ++iter) \
120  if(*iter){ (*iter)->Release(); } \
121  x.clear();}
122 
123 #define SAFE_DELETE_VECTOR(x) for(size_t vdind = 0; vdind < x.size(); ++vdind){ \
124  if(x[vdind]){delete x[vdind];}}; \
125  x.clear();
126 
127 #define UNUSED(x) ((void)x);
128 
129 #ifdef LEVIATHAN_FULL
130 #include "Logger.h"
131 #endif // LEVIATHAN_FULL
132 
#define LEVIATHAN_VERSION_MINOR
Definition: Include.h:91
#define LEVIATHAN_VERSION
Definition: Include.h:85
#define LEVIATHAN_VERSION_PATCH
Definition: Include.h:92
constexpr auto BASESENDABLE_STORED_RECEIVED_STATES
Definition: Define.h:34
constexpr auto CRITICAL_PACKET_MAX_TRIES
Definition: Define.h:40
#define LEVIATHAN_VERSION_MAJOR
Definition: Include.h:90
constexpr auto INTERPOLATION_TIME
Definition: Define.h:24
constexpr auto TICKSPEED
Number of milliseconds between engine and world ticks.
Definition: Define.h:21
#define LEVIATHAN_VERSION_ANSIS
Definition: Include.h:87
constexpr auto HEARTBEATS_MILLISECOND
Definition: Define.h:28
#define LEVIATHAN_VERSION_STABLE
Definition: Include.h:89
constexpr auto MAX_SERVERCOMMAND_LENGTH
Definition: Define.h:32
constexpr auto DEFAULT_MAXCONNECT_TRIES
Definition: Define.h:30
constexpr auto PACKET_LOST_AFTER_RECEIVED_NEWER
Definition: Define.h:38
constexpr float EPSILON
Definition: Define.h:62
constexpr float RADIANS_TO_DEGREES
Definition: Define.h:61
constexpr float PI
Definition: Define.h:58
constexpr float DEGREES_TO_RADIANS
Definition: Define.h:60
constexpr float NORMALIZATION_TOLERANCE
For checking vector normalization.
Definition: Define.h:43
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
constexpr auto MICROSECONDS_IN_SECOND
Definition: Define.h:55
constexpr auto PACKET_LOST_AFTER_MILLISECONDS
Definition: Define.h:36