]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/_all.inc
Merge branch 'master' into Lyberta/KillSound
[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         bool _StartFrame_init;
186         void spawnfunc_worldspawn(entity);
187         void StartFrame() {
188                 if (!_StartFrame_init) {
189                         _StartFrame_init = true;
190                         float oldtime = time; time = 1;
191                         __spawnfunc_expecting = 2; NULL.__spawnfunc_constructor(NULL);
192                         time = oldtime;
193         }
194         if (_StartFrame) _StartFrame();
195         }
196         #define StartFrame _StartFrame
197
198         void _SetNewParms();
199         void SetNewParms() { if (_SetNewParms) _SetNewParms(); }
200         #define SetNewParms _SetNewParms
201
202         void _SetChangeParms(entity this);
203         void SetChangeParms() { ENGINE_EVENT(); if (_SetChangeParms) _SetChangeParms(this); }
204         #define SetChangeParms _SetChangeParms
205
206 #ifdef DP_EXT_PRECONNECT
207         void _ClientPreConnect(entity this);
208         void ClientPreConnect() { ENGINE_EVENT(); if (_ClientPreConnect) _ClientPreConnect(this); }
209         #define ClientPreConnect _ClientPreConnect
210 #endif
211
212         void _ClientConnect(entity this);
213         void ClientConnect() { ENGINE_EVENT(); if (_ClientConnect) _ClientConnect(this); }
214         #define ClientConnect _ClientConnect
215
216         void _ClientDisconnect(entity this);
217         void ClientDisconnect() { ENGINE_EVENT(); if (_ClientDisconnect) _ClientDisconnect(this); }
218         #define ClientDisconnect _ClientDisconnect
219
220         void _PutClientInServer(entity this);
221         void PutClientInServer() { ENGINE_EVENT(); if (_PutClientInServer) _PutClientInServer(this); }
222         #define PutClientInServer _PutClientInServer
223
224         void _ClientKill(entity this);
225         void ClientKill() { ENGINE_EVENT(); if (_ClientKill) _ClientKill(this); }
226         #define ClientKill _ClientKill
227
228         void _PlayerPreThink(entity this);
229         void PlayerPreThink() { ENGINE_EVENT(); if (_PlayerPreThink) _PlayerPreThink(this); }
230         #define PlayerPreThink _PlayerPreThink
231
232         void _PlayerPostThink(entity this);
233         void PlayerPostThink() { ENGINE_EVENT(); if (_PlayerPostThink) _PlayerPostThink(this); }
234         #define PlayerPostThink _PlayerPostThink
235
236         void _SV_PlayerPhysics(entity this);
237         void SV_PlayerPhysics() { ENGINE_EVENT(); if (_SV_PlayerPhysics) _SV_PlayerPhysics(this); }
238         #define SV_PlayerPhysics _SV_PlayerPhysics
239
240         void _SV_OnEntityPreSpawnFunction(entity this);
241         void SV_OnEntityPreSpawnFunction()
242         {
243                 ENGINE_EVENT();
244                 if (_SV_OnEntityPreSpawnFunction) _SV_OnEntityPreSpawnFunction(this);
245         }
246         #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction
247
248         void _SV_ChangeTeam(entity this, int _color);
249         void SV_ChangeTeam(int _color) { ENGINE_EVENT(); if (_SV_ChangeTeam) _SV_ChangeTeam(this, _color); }
250         #define SV_ChangeTeam _SV_ChangeTeam
251
252         void _SV_ParseClientCommand(entity this, string command);
253         void SV_ParseClientCommand(string command)
254         {
255                 ENGINE_EVENT();
256                 if (_SV_ParseClientCommand) _SV_ParseClientCommand(this, command);
257         }
258         #define SV_ParseClientCommand _SV_ParseClientCommand
259 #endif
260
261 #ifdef CSQC
262         void _CSQC_Init();
263         void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
264         #define CSQC_Init _CSQC_Init
265
266         void _CSQC_Shutdown();
267         void CSQC_Shutdown() { if (_CSQC_Shutdown) _CSQC_Shutdown(); }
268         #define CSQC_Shutdown _CSQC_Shutdown
269
270         void _CSQC_UpdateView(entity this, float w, float h);
271         void CSQC_UpdateView(float w, float h) { ENGINE_EVENT(); if (_CSQC_UpdateView) _CSQC_UpdateView(this, w, h); }
272         #define CSQC_UpdateView _CSQC_UpdateView
273
274         bool _CSQC_InputEvent(int inputType, float nPrimary, float nSecondary);
275         bool CSQC_InputEvent(int inputType, float nPrimary, float nSecondary)
276         {
277                 return _CSQC_InputEvent ? _CSQC_InputEvent(inputType, nPrimary, nSecondary) : false;
278         }
279         #define CSQC_InputEvent _CSQC_InputEvent
280
281         bool _CSQC_ConsoleCommand(string s);
282         bool CSQC_ConsoleCommand(string s) { return _CSQC_ConsoleCommand ? _CSQC_ConsoleCommand(s) : false; }
283         #define CSQC_ConsoleCommand _CSQC_ConsoleCommand
284
285         void _CSQC_Ent_Update(entity this, bool isNew);
286         void CSQC_Ent_Update(bool isNew) { ENGINE_EVENT(); if (_CSQC_Ent_Update) _CSQC_Ent_Update(this, isNew); }
287         #define CSQC_Ent_Update _CSQC_Ent_Update
288
289         void _CSQC_Ent_Remove(entity this);
290         void CSQC_Ent_Remove() { ENGINE_EVENT(); if (_CSQC_Ent_Remove) _CSQC_Ent_Remove(this); }
291         #define CSQC_Ent_Remove _CSQC_Ent_Remove
292 #endif
293 #undef ENGINE_EVENT
294
295 #if XONOTIC
296 #ifdef GAMEQC
297         #include <ecs/_mod.qh>
298 #endif
299 #endif