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