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