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