]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/_all.inc
Move objerror to qc
[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 "intrusivelist.qh"
81 #include "iter.qh"
82 #include "json.qc"
83 #include "lazy.qh"
84 #include "linkedlist.qh"
85 #include "log.qh"
86 #include "map.qh"
87 #include "markdown.qh"
88 #include "math.qh"
89 #include "misc.qh"
90 #include "net.qh"
91 #include "nil.qh"
92 #include "noise.qh"
93 #include "oo.qh"
94 #include "p2mathlib.qc"
95 #include "progname.qh"
96 #include "random.qc"
97 #include "registry.qh"
98 #include "registry_net.qh"
99 #include "replicate.qh"
100 #include "sortlist.qc"
101 #include "sort.qh"
102 #include "spawnfunc.qh"
103 #include "static.qh"
104 #include "stats.qh"
105 #include "string.qh"
106 #include "struct.qh"
107 #include "test.qc"
108 #include "unsafe.qh"
109 #include "urllib.qc"
110 #include "vector.qh"
111 #include "yenc.qh"
112
113 #include "matrix/_mod.inc"
114
115 #ifndef SVQC
116 #define objerror_safe(e)
117 #else
118 void make_safe_for_remove(entity this);
119     #define objerror_safe(e) make_safe_for_remove(e)
120 #endif
121
122 #define objerror(this, msg) MACRO_BEGIN { \
123         LOG_WARNING("======OBJECT ERROR======"); \
124         entity _e = (this); \
125         eprint(_e); \
126         objerror_safe(_e); \
127         delete(_e); \
128         LOG_WARNINGF("%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information", PROGNAME, __FUNC__, msg); \
129 } MACRO_END
130
131 #ifdef MENUQC
132         void _m_init();
133         void m_init() { if (_m_init) _m_init(); }
134         #define m_init _m_init
135
136         void _m_shutdown();
137         void m_shutdown() { if (_m_shutdown) _m_shutdown(); }
138         #define m_shutdown _m_shutdown
139
140         void _m_draw(float width, float height);
141         void m_draw(float width, float height) { if (_m_draw) _m_draw(width, height); }
142         #define m_draw _m_draw
143
144         void _m_keydown(int keynr, int ascii);
145         void m_keydown(int keynr, int ascii) { if (_m_keydown) _m_keydown(keynr, ascii); }
146         #define m_keydown _m_keydown
147
148         void _m_toggle(int mode);
149         void m_toggle(int mode) { if (_m_toggle) _m_toggle(mode); }
150         #define m_toggle _m_toggle
151 #endif
152
153 #ifdef SVQC
154         void _main();
155         void main() { if (_main) _main(); }
156         #define main _main
157
158         void _SV_Shutdown();
159         void SV_Shutdown() { if (_SV_Shutdown) _SV_Shutdown(); }
160         #define SV_Shutdown _SV_Shutdown
161
162         void _StartFrame();
163         void StartFrame() { if (_StartFrame) _StartFrame(); }
164         #define StartFrame _StartFrame
165
166         void _SetNewParms();
167         void SetNewParms() { if (_SetNewParms) _SetNewParms(); }
168         #define SetNewParms _SetNewParms
169
170         void _SetChangeParms(entity this);
171         void SetChangeParms() { ENGINE_EVENT(); if (_SetChangeParms) _SetChangeParms(this); }
172         #define SetChangeParms _SetChangeParms
173
174         void _ClientConnect(entity this);
175         void ClientConnect() { ENGINE_EVENT(); if (_ClientConnect) _ClientConnect(this); }
176         #define ClientConnect _ClientConnect
177
178         void _ClientDisconnect(entity this);
179         void ClientDisconnect() { ENGINE_EVENT(); if (_ClientDisconnect) _ClientDisconnect(this); }
180         #define ClientDisconnect _ClientDisconnect
181
182         void _PutClientInServer(entity this);
183         void PutClientInServer() { ENGINE_EVENT(); if (_PutClientInServer) _PutClientInServer(this); }
184         #define PutClientInServer _PutClientInServer
185
186         void _ClientKill(entity this);
187         void ClientKill() { ENGINE_EVENT(); if (_ClientKill) _ClientKill(this); }
188         #define ClientKill _ClientKill
189
190         void _PlayerPreThink(entity this);
191         void PlayerPreThink() { ENGINE_EVENT(); if (_PlayerPreThink) _PlayerPreThink(this); }
192         #define PlayerPreThink _PlayerPreThink
193
194         void _PlayerPostThink(entity this);
195         void PlayerPostThink() { ENGINE_EVENT(); if (_PlayerPostThink) _PlayerPostThink(this); }
196         #define PlayerPostThink _PlayerPostThink
197
198         void _SV_PlayerPhysics(entity this);
199         void SV_PlayerPhysics() { ENGINE_EVENT(); if (_SV_PlayerPhysics) _SV_PlayerPhysics(this); }
200         #define SV_PlayerPhysics _SV_PlayerPhysics
201
202         void _SV_OnEntityPreSpawnFunction(entity this);
203         void SV_OnEntityPreSpawnFunction()
204         {
205                 ENGINE_EVENT();
206                 if (_SV_OnEntityPreSpawnFunction) _SV_OnEntityPreSpawnFunction(this);
207         }
208         #define SV_OnEntityPreSpawnFunction _SV_OnEntityPreSpawnFunction
209
210         void _SV_ChangeTeam(entity this, int _color);
211         void SV_ChangeTeam(int _color) { ENGINE_EVENT(); if (_SV_ChangeTeam) _SV_ChangeTeam(this, _color); }
212         #define SV_ChangeTeam _SV_ChangeTeam
213
214         void _SV_ParseClientCommand(entity this, string command);
215         void SV_ParseClientCommand(string command)
216         {
217                 ENGINE_EVENT();
218                 if (_SV_ParseClientCommand) _SV_ParseClientCommand(this, command);
219         }
220         #define SV_ParseClientCommand _SV_ParseClientCommand
221 #endif
222
223 #ifdef CSQC
224         void _CSQC_Init();
225         void CSQC_Init() { if (_CSQC_Init) _CSQC_Init(); }
226         #define CSQC_Init _CSQC_Init
227
228         void _CSQC_Shutdown();
229         void CSQC_Shutdown() { if (_CSQC_Shutdown) _CSQC_Shutdown(); }
230         #define CSQC_Shutdown _CSQC_Shutdown
231
232         void _CSQC_UpdateView(entity this, float w, float h);
233         void CSQC_UpdateView(float w, float h) { ENGINE_EVENT(); if (_CSQC_UpdateView) _CSQC_UpdateView(this, w, h); }
234         #define CSQC_UpdateView _CSQC_UpdateView
235
236         bool _CSQC_InputEvent(int inputType, float nPrimary, float nSecondary);
237         bool CSQC_InputEvent(int inputType, float nPrimary, float nSecondary)
238         {
239                 return _CSQC_InputEvent ? _CSQC_InputEvent(inputType, nPrimary, nSecondary) : false;
240         }
241         #define CSQC_InputEvent _CSQC_InputEvent
242
243         bool _CSQC_ConsoleCommand(string s);
244         bool CSQC_ConsoleCommand(string s) { return _CSQC_ConsoleCommand ? _CSQC_ConsoleCommand(s) : false; }
245         #define CSQC_ConsoleCommand _CSQC_ConsoleCommand
246
247         void _CSQC_Ent_Update(entity this, bool isNew);
248         void CSQC_Ent_Update(bool isNew) { ENGINE_EVENT(); if (_CSQC_Ent_Update) _CSQC_Ent_Update(this, isNew); }
249         #define CSQC_Ent_Update _CSQC_Ent_Update
250
251         void _CSQC_Ent_Remove(entity this);
252         void CSQC_Ent_Remove() { ENGINE_EVENT(); if (_CSQC_Ent_Remove) _CSQC_Ent_Remove(this); }
253         #define CSQC_Ent_Remove _CSQC_Ent_Remove
254 #endif
255 #undef ENGINE_EVENT