]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/_all.inc
Merge branch 'master' into martin-t/globals
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / _all.inc
1 #ifndef NOCOMPAT
2         #define COMPAT_NO_MOD_IS_XONOTIC
3 #endif
4
5 #ifdef CSQC
6 #define IS_CSQC 1
7 #else
8 #define IS_CSQC 0
9 #endif
10
11 #ifdef SVQC
12 #define IS_SVQC 1
13 #else
14 #define IS_SVQC 0
15 #endif
16
17 #include "compiler.qh"
18
19 #ifndef QCC_SUPPORT_INT
20         #define int float
21 #endif
22
23 #ifndef QCC_SUPPORT_BOOL
24         #define bool float
25 #endif
26
27 #ifndef QCC_SUPPORT_ACCUMULATE
28         #warning "QCC does not support accumulate, may not compile correctly"
29         #define ACCUMULATE
30 #else
31         #define ACCUMULATE [[accumulate]]
32 #endif
33
34 #ifndef QCC_SUPPORT_ERASEABLE
35         #define ERASEABLE
36 #else
37         #define ERASEABLE [[eraseable]]
38 #endif
39
40 #ifndef QCC_SUPPORT_ALIAS
41     #warning "QCC does not support alias, may not compile correctly"
42     #define ALIAS(var)
43 #else
44     #define ALIAS(var) [[alias(var)]]
45 #endif
46
47 #include <dpdefs/pre.qh>
48
49 #if defined(CSQC)
50         #include <dpdefs/csprogsdefs.qh>
51         #include <dpdefs/keycodes.qh>
52 #elif defined(SVQC)
53         #include <server/sys-pre.qh>
54         #include <dpdefs/progsdefs.qh>
55         #include <dpdefs/dpextensions.qh>
56         #include <server/sys-post.qh>
57 #elif defined(MENUQC)
58         #include <dpdefs/menudefs.qh>
59         #include <dpdefs/keycodes.qh>
60 #endif
61
62 #include <dpdefs/post.qh>
63
64 #ifndef QCC_SUPPORT_POW
65     #define pow(a, b) pow(a, b)
66 #else
67     #define pow(a, b) ((a) ** (b))
68 #endif
69
70 #include "self.qh"
71
72 #define USING(name, T) typedef T name
73
74 #include "bool.qh"
75 #include "int.qh"
76
77 #include "macro.qh"
78
79 #if NDEBUG
80         #define TC(T, sym) MACRO_BEGIN MACRO_END
81 #else
82         #define TC(T, sym) MACRO_BEGIN \
83                 if (!is_##T(sym)) { \
84                         LOG_WARNF("Type check failed: " #sym " :: " #T); \
85                         isnt_##T(sym); \
86                 } \
87         MACRO_END
88 #endif
89
90 #if !(NDEBUG)
91         #define   is_float(this) (true || ftoe(this))
92         #define isnt_float(this)
93         #define   is_vector(this) (true || vtos(this))
94         #define isnt_vector(this)
95         #define   is_string(this) (true || stof(this))
96         #define isnt_string(this)
97         #define   is_entity(this) (true || etof(this))
98         #define isnt_entity(this)
99         bool      is_int(float this) { return this == floor(this); }
100         void    isnt_int(float this) { print(ftos(this)); }
101         bool      is_bool(float this) { return this == true || this == false; }
102         void    isnt_bool(float this) { print(ftos(this)); }
103 #endif
104
105 #include "warpzone/mathlib.qc"
106
107 #include "accumulate.qh"
108 #include "angle.qc"
109 #include "arraylist.qh"
110 #include "bits.qh"
111 #include "color.qh"
112 #include "counting.qh"
113 #include "cvar.qh"
114 #include "defer.qh"
115 #include "deglobalization.qh"
116 #include "draw.qh"
117 #include "enumclass.qh"
118 #include "file.qh"
119 #include "float.qh"
120 #include "functional.qh"
121 #include "i18n.qh"
122 #include "intrusivelist.qh"
123 #include "iter.qh"
124 #include "json.qc"
125 #include "lazy.qh"
126 #include "linkedlist.qh"
127 #include "log.qh"
128 #include "map.qh"
129 #include "markdown.qh"
130 #include "math.qh"
131 #include "misc.qh"
132 #include "net.qh"
133 #include "nil.qh"
134 #include "noise.qh"
135 #include "oo.qh"
136 #include "p2mathlib.qc"
137 #include "progname.qh"
138 #include "promise.qc"
139 #include "random.qc"
140 #include "registry.qh"
141 #include "registry_net.qh"
142 #include "replicate.qh"
143 #include "sortlist.qc"
144 #include "sort.qh"
145 #include "spawnfunc.qh"
146 #include "static.qh"
147 #include "stats.qh"
148 #include "string.qh"
149 #include "struct.qh"
150 #include "test.qc"
151 #include "unsafe.qh"
152 #include "urllib.qc"
153 #include "vector.qh"
154 #include "yenc.qh"
155
156 #if XONOTIC
157         #include "matrix/_mod.inc"
158 #endif
159
160 #ifndef SVQC
161 #define objerror_safe(e)
162 #else
163 void make_safe_for_remove(entity this);
164     #define objerror_safe(e) make_safe_for_remove(e)
165 #endif
166
167 #define objerror(this, msg) MACRO_BEGIN { \
168         LOG_WARN("======OBJECT ERROR======"); \
169         entity _e = (this); \
170         eprint(_e); \
171         objerror_safe(_e); \
172         delete(_e); \
173         LOG_WARNF("%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information", PROGNAME, __FUNC__, msg); \
174 } MACRO_END
175
176 #ifdef MENUQC
177         void _m_init();
178         void m_init() { if (_m_init) _m_init(); }
179         #define m_init _m_init
180
181         void _m_shutdown();
182         void m_shutdown() { if (_m_shutdown) _m_shutdown(); }
183         #define m_shutdown _m_shutdown
184
185         void _m_draw(float width, float height);
186         void m_draw(float width, float height) { if (_m_draw) _m_draw(width, height); }
187         #define m_draw _m_draw
188
189         void _m_keydown(int keynr, int ascii);
190         void m_keydown(int keynr, int ascii) { if (_m_keydown) _m_keydown(keynr, ascii); }
191         #define m_keydown _m_keydown
192
193         void _m_toggle(int mode);
194         void m_toggle(int mode) { if (_m_toggle) _m_toggle(mode); }
195         #define m_toggle _m_toggle
196 #endif
197
198 #ifdef SVQC
199         void _main();
200         void main() { if (_main) _main(); }
201         #define main _main
202
203         void _SV_Shutdown();
204         void SV_Shutdown() { if (_SV_Shutdown) _SV_Shutdown(); }
205         #define SV_Shutdown _SV_Shutdown
206
207         void _StartFrame();
208         bool _StartFrame_init;
209         void spawnfunc_worldspawn(entity);
210         void StartFrame() {
211                 if (!_StartFrame_init) {
212                         _StartFrame_init = true;
213                         float oldtime = time; time = 1;
214                         __spawnfunc_expecting = 2; NULL.__spawnfunc_constructor(NULL);
215                         time = oldtime;
216         }
217         if (_StartFrame) _StartFrame();
218         }
219         #define StartFrame _StartFrame
220
221         void _SetNewParms();
222         void SetNewParms() { if (_SetNewParms) _SetNewParms(); }
223         #define SetNewParms _SetNewParms
224
225         void _SetChangeParms(entity this);
226         void SetChangeParms() { ENGINE_EVENT(); if (_SetChangeParms) _SetChangeParms(this); }
227         #define SetChangeParms _SetChangeParms
228
229 #ifdef DP_EXT_PRECONNECT
230         void _ClientPreConnect(entity this);
231         void ClientPreConnect() { ENGINE_EVENT(); if (_ClientPreConnect) _ClientPreConnect(this); }
232         #define ClientPreConnect _ClientPreConnect
233 #endif
234
235         void _ClientConnect(entity this);
236         void ClientConnect() { ENGINE_EVENT(); if (_ClientConnect) _ClientConnect(this); }
237         #define ClientConnect _ClientConnect
238
239         void _ClientDisconnect(entity this);
240         void ClientDisconnect() { ENGINE_EVENT(); if (_ClientDisconnect) _ClientDisconnect(this); }
241         #define ClientDisconnect _ClientDisconnect
242
243         void _PutClientInServer(entity this);
244         void PutClientInServer() { ENGINE_EVENT(); if (_PutClientInServer) _PutClientInServer(this); }
245         #define PutClientInServer _PutClientInServer
246
247         void _ClientKill(entity this);
248         void ClientKill() { ENGINE_EVENT(); if (_ClientKill) _ClientKill(this); }
249         #define ClientKill _ClientKill
250
251         void _PlayerPreThink(entity this);
252         void PlayerPreThink() { ENGINE_EVENT(); if (_PlayerPreThink) _PlayerPreThink(this); }
253         #define PlayerPreThink _PlayerPreThink
254
255         void _PlayerPostThink(entity this);
256         void PlayerPostThink() { ENGINE_EVENT(); if (_PlayerPostThink) _PlayerPostThink(this); }
257         #define PlayerPostThink _PlayerPostThink
258
259         void _SV_PlayerPhysics(entity this);
260         void SV_PlayerPhysics() { ENGINE_EVENT(); if (_SV_PlayerPhysics) _SV_PlayerPhysics(this); }
261         #define SV_PlayerPhysics _SV_PlayerPhysics
262
263         void _SV_OnEntityPreSpawnFunction(entity this);
264         void SV_OnEntityPreSpawnFunction()
265         {
266                 ENGINE_EVENT();
267                 __spawnfunc_expecting = true;
268                 __spawnfunc_expect = this;
269         }
270         #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction
271
272         void _SV_ChangeTeam(entity this, int _color);
273         void SV_ChangeTeam(int _color) { ENGINE_EVENT(); if (_SV_ChangeTeam) _SV_ChangeTeam(this, _color); }
274         #define SV_ChangeTeam _SV_ChangeTeam
275
276         void _SV_ParseClientCommand(entity this, string command);
277         void SV_ParseClientCommand(string command)
278         {
279                 ENGINE_EVENT();
280                 if (_SV_ParseClientCommand) _SV_ParseClientCommand(this, command);
281         }
282         #define SV_ParseClientCommand _SV_ParseClientCommand
283 #endif
284
285 #ifdef CSQC
286         void _CSQC_Init();
287         void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
288         #define CSQC_Init _CSQC_Init
289
290         void _CSQC_Shutdown();
291         void CSQC_Shutdown() { if (_CSQC_Shutdown) _CSQC_Shutdown(); }
292         #define CSQC_Shutdown _CSQC_Shutdown
293
294         void _CSQC_UpdateView(entity this, float w, float h);
295         void CSQC_UpdateView(float w, float h) { ENGINE_EVENT(); if (_CSQC_UpdateView) _CSQC_UpdateView(this, w, h); }
296         #define CSQC_UpdateView _CSQC_UpdateView
297
298         bool _CSQC_InputEvent(int inputType, float nPrimary, float nSecondary);
299         bool CSQC_InputEvent(int inputType, float nPrimary, float nSecondary)
300         {
301                 return _CSQC_InputEvent ? _CSQC_InputEvent(inputType, nPrimary, nSecondary) : false;
302         }
303         #define CSQC_InputEvent _CSQC_InputEvent
304
305         bool _CSQC_ConsoleCommand(string s);
306         bool CSQC_ConsoleCommand(string s) { return _CSQC_ConsoleCommand ? _CSQC_ConsoleCommand(s) : false; }
307         #define CSQC_ConsoleCommand _CSQC_ConsoleCommand
308
309         void _CSQC_Ent_Update(entity this, bool isNew);
310         void CSQC_Ent_Update(bool isNew) { ENGINE_EVENT(); if (_CSQC_Ent_Update) _CSQC_Ent_Update(this, isNew); }
311         #define CSQC_Ent_Update _CSQC_Ent_Update
312
313         void _CSQC_Ent_Remove(entity this);
314         void CSQC_Ent_Remove() { ENGINE_EVENT(); if (_CSQC_Ent_Remove) _CSQC_Ent_Remove(this); }
315         #define CSQC_Ent_Remove _CSQC_Ent_Remove
316 #endif
317 #undef ENGINE_EVENT
318
319 #if XONOTIC
320 #ifdef GAMEQC
321         #include <ecs/_mod.qh>
322 #endif
323 #endif