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