]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/_all.inc
Wrap engine events
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / _all.inc
1 #ifndef NOCOMPAT
2         #define COMPAT_NO_MOD_IS_XONOTIC
3 #endif
4
5 #include "compiler.qh"
6
7 #ifndef QCC_SUPPORT_INT
8         #define int float
9 #endif
10
11 #ifndef QCC_SUPPORT_BOOL
12         #define bool float
13 #endif
14
15 #include <dpdefs/pre.qh>
16
17 #if defined(CSQC)
18         #include <dpdefs/csprogsdefs.qh>
19         #include <dpdefs/keycodes.qh>
20 #elif defined(SVQC)
21         #include <server/sys-pre.qh>
22         #include <dpdefs/progsdefs.qh>
23         #include <dpdefs/dpextensions.qh>
24         #include <server/sys-post.qh>
25 #elif defined(MENUQC)
26         #include <dpdefs/menudefs.qh>
27         #include <dpdefs/keycodes.qh>
28 #endif
29
30 #include <dpdefs/post.qh>
31
32 #include "self.qh"
33
34 #define USING(name, T) typedef T name
35
36 #include "bool.qh"
37 #include "int.qh"
38
39 #include "macro.qh"
40
41 #if NDEBUG
42         #define TC(T, sym) MACRO_BEGIN MACRO_END
43 #else
44         #define TC(T, sym) MACRO_BEGIN \
45                 if (!is_##T(sym)) { \
46                         LOG_WARNINGF("Type check failed: " #sym " :: " #T); \
47                         isnt_##T(sym); \
48                 } \
49         MACRO_END
50 #endif
51
52 #define   is_float(this) (true || ftoe(this))
53 #define isnt_float(this)
54 #define   is_vector(this) (true || vtos(this))
55 #define isnt_vector(this)
56 #define   is_string(this) (true || stof(this))
57 #define isnt_string(this)
58 #define   is_entity(this) (true || etof(this))
59 #define isnt_entity(this)
60 bool      is_int(float this) { return this == floor(this); }
61 void    isnt_int(float this) { print(ftos(this)); }
62 bool      is_bool(float this) { return this == true || this == false; }
63 void    isnt_bool(float this) { print(ftos(this)); }
64
65 #include "warpzone/mathlib.qc"
66
67 #include "accumulate.qh"
68 #include "angle.qc"
69 #include "arraylist.qh"
70 #include "bits.qh"
71 #include "color.qh"
72 #include "counting.qh"
73 #include "cvar.qh"
74 #include "defer.qh"
75 #include "draw.qh"
76 #include "enumclass.qh"
77 #include "file.qh"
78 #include "functional.qh"
79 #include "i18n.qh"
80 #include "iter.qh"
81 #include "json.qc"
82 #include "lazy.qh"
83 #include "linkedlist.qh"
84 #include "log.qh"
85 #include "map.qh"
86 #include "markdown.qh"
87 #include "math.qh"
88 #include "misc.qh"
89 #include "net.qh"
90 #include "nil.qh"
91 #include "noise.qh"
92 #include "oo.qh"
93 #include "p2mathlib.qc"
94 #include "progname.qh"
95 #include "random.qc"
96 #include "registry.qh"
97 #include "registry_net.qh"
98 #include "replicate.qh"
99 #include "sortlist.qc"
100 #include "sort.qh"
101 #include "spawnfunc.qh"
102 #include "static.qh"
103 #include "stats.qh"
104 #include "string.qh"
105 #include "struct.qh"
106 #include "test.qc"
107 #include "unsafe.qh"
108 #include "urllib.qc"
109 #include "vector.qh"
110 #include "yenc.qh"
111
112 #include "matrix/_mod.inc"
113
114 #ifdef MENUQC
115         void _m_init();
116         void m_init() { if (_m_init) _m_init(); }
117         #define m_init _m_init
118
119         void _m_shutdown();
120         void m_shutdown() { if (_m_shutdown) _m_shutdown(); }
121         #define m_shutdown _m_shutdown
122
123         void _m_draw(float width, float height);
124         void m_draw(float width, float height) { if (_m_draw) _m_draw(width, height); }
125         #define m_draw _m_draw
126
127         void _m_keydown(int keynr, int ascii);
128         void m_keydown(int keynr, int ascii) { if (_m_keydown) _m_keydown(keynr, ascii); }
129         #define m_keydown _m_keydown
130
131         void _m_toggle(int mode);
132         void m_toggle(int mode) { if (_m_toggle) _m_toggle(mode); }
133         #define m_toggle _m_toggle
134 #endif
135
136 #ifdef SVQC
137         void _main();
138         void main() { if (_main) _main(); }
139         #define main _main
140
141         void _SV_Shutdown();
142         void SV_Shutdown() { if (_SV_Shutdown) _SV_Shutdown(); }
143         #define SV_Shutdown _SV_Shutdown
144
145         void _StartFrame();
146         void StartFrame() { if (_StartFrame) _StartFrame(); }
147         #define StartFrame _StartFrame
148
149         void _SetNewParms();
150         void SetNewParms() { if (_SetNewParms) _SetNewParms(); }
151         #define SetNewParms _SetNewParms
152
153         void _SetChangeParms(entity this);
154         void SetChangeParms() { ENGINE_EVENT(); if (_SetChangeParms) _SetChangeParms(this); }
155         #define SetChangeParms _SetChangeParms
156
157         void _ClientConnect(entity this);
158         void ClientConnect() { ENGINE_EVENT(); if (_ClientConnect) _ClientConnect(this); }
159         #define ClientConnect _ClientConnect
160
161         void _ClientDisconnect(entity this);
162         void ClientDisconnect() { ENGINE_EVENT(); if (_ClientDisconnect) _ClientDisconnect(this); }
163         #define ClientDisconnect _ClientDisconnect
164
165         void _PutClientInServer(entity this);
166         void PutClientInServer() { ENGINE_EVENT(); if (_PutClientInServer) _PutClientInServer(this); }
167         #define PutClientInServer _PutClientInServer
168
169         void _ClientKill(entity this);
170         void ClientKill() { ENGINE_EVENT(); if (_ClientKill) _ClientKill(this); }
171         #define ClientKill _ClientKill
172
173         void _PlayerPreThink(entity this);
174         void PlayerPreThink() { ENGINE_EVENT(); if (_PlayerPreThink) _PlayerPreThink(this); }
175         #define PlayerPreThink _PlayerPreThink
176
177         void _PlayerPostThink(entity this);
178         void PlayerPostThink() { ENGINE_EVENT(); if (_PlayerPostThink) _PlayerPostThink(this); }
179         #define PlayerPostThink _PlayerPostThink
180
181         void _SV_PlayerPhysics(entity this);
182         void SV_PlayerPhysics() { ENGINE_EVENT(); if (_SV_PlayerPhysics) _SV_PlayerPhysics(this); }
183         #define SV_PlayerPhysics _SV_PlayerPhysics
184
185         void _SV_OnEntityPreSpawnFunction(entity this);
186         void SV_OnEntityPreSpawnFunction()
187         {
188                 ENGINE_EVENT();
189                 if (_SV_OnEntityPreSpawnFunction) _SV_OnEntityPreSpawnFunction(this);
190         }
191         #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction
192
193         void _SV_ChangeTeam(entity this, int _color);
194         void SV_ChangeTeam(int _color) { ENGINE_EVENT(); if (_SV_ChangeTeam) _SV_ChangeTeam(this, _color); }
195         #define SV_ChangeTeam _SV_ChangeTeam
196
197         void _SV_ParseClientCommand(entity this, string command);
198         void SV_ParseClientCommand(string command)
199         {
200                 ENGINE_EVENT();
201                 if (_SV_ParseClientCommand) _SV_ParseClientCommand(this, command);
202         }
203         #define SV_ParseClientCommand _SV_ParseClientCommand
204 #endif
205
206 #ifdef CSQC
207         void _CSQC_Init();
208         void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
209         #define CSQC_Init _CSQC_Init
210
211         void _CSQC_Shutdown();
212         void CSQC_Shutdown() { if (_CSQC_Shutdown) _CSQC_Shutdown(); }
213         #define CSQC_Shutdown _CSQC_Shutdown
214
215         void _CSQC_UpdateView(entity this, float w, float h);
216         void CSQC_UpdateView(float w, float h) { ENGINE_EVENT(); if (_CSQC_UpdateView) _CSQC_UpdateView(this, w, h); }
217         #define CSQC_UpdateView _CSQC_UpdateView
218
219         bool _CSQC_InputEvent(int inputType, float nPrimary, float nSecondary);
220         bool CSQC_InputEvent(int inputType, float nPrimary, float nSecondary)
221         {
222                 return _CSQC_InputEvent ? _CSQC_InputEvent(inputType, nPrimary, nSecondary) : false;
223         }
224         #define CSQC_InputEvent _CSQC_InputEvent
225
226         bool _CSQC_ConsoleCommand(string s);
227         bool CSQC_ConsoleCommand(string s) { return _CSQC_ConsoleCommand ? _CSQC_ConsoleCommand(s) : false; }
228         #define CSQC_ConsoleCommand _CSQC_ConsoleCommand
229
230         void _CSQC_Ent_Update(entity this, bool isNew);
231         void CSQC_Ent_Update(bool isNew) { ENGINE_EVENT(); if (_CSQC_Ent_Update) _CSQC_Ent_Update(this, isNew); }
232         #define CSQC_Ent_Update _CSQC_Ent_Update
233
234         void _CSQC_Ent_Remove(entity this);
235         void CSQC_Ent_Remove() { ENGINE_EVENT(); if (_CSQC_Ent_Remove) _CSQC_Ent_Remove(this); }
236         #define CSQC_Ent_Remove _CSQC_Ent_Remove
237 #endif
238 #undef ENGINE_EVENT