]> git.xonotic.org Git - xonotic/darkplaces.git/blob - quakedef.h
Add qdefs.h and qstats.h to split up quakedef.h. Make a lot of headers standalone...
[xonotic/darkplaces.git] / quakedef.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // quakedef.h -- primary header for client
21
22 #ifndef QUAKEDEF_H
23 #define QUAKEDEF_H
24
25 #ifdef __APPLE__
26 # include <TargetConditionals.h>
27 #endif
28
29 #include <sys/types.h>
30 #include <ctype.h>
31 #include <math.h>
32 #include <string.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <limits.h>
37
38 #include "qtypes.h"
39
40 extern const char *buildstring;
41 extern char engineversion[128];
42
43 #define GAMENAME "id1"
44
45 #include "qdefs.h"
46 #include "qstats.h"
47
48 // moveflags values
49 #define MOVEFLAG_VALID 0x80000000
50 #define MOVEFLAG_Q2AIRACCELERATE 0x00000001
51 #define MOVEFLAG_NOGRAVITYONGROUND 0x00000002
52 #define MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE 0x00000004
53
54 // stock defines
55
56 #define IT_SHOTGUN                              1
57 #define IT_SUPER_SHOTGUN                2
58 #define IT_NAILGUN                              4
59 #define IT_SUPER_NAILGUN                8
60 #define IT_GRENADE_LAUNCHER             16
61 #define IT_ROCKET_LAUNCHER              32
62 #define IT_LIGHTNING                    64
63 #define IT_SUPER_LIGHTNING      128
64 #define IT_SHELLS               256
65 #define IT_NAILS                512
66 #define IT_ROCKETS              1024
67 #define IT_CELLS                2048
68 #define IT_AXE                  4096
69 #define IT_ARMOR1               8192
70 #define IT_ARMOR2               16384
71 #define IT_ARMOR3               32768
72 #define IT_SUPERHEALTH          65536
73 #define IT_KEY1                 131072
74 #define IT_KEY2                 262144
75 #define IT_INVISIBILITY                 524288
76 #define IT_INVULNERABILITY              1048576
77 #define IT_SUIT                                 2097152
78 #define IT_QUAD                                 4194304
79 #define IT_SIGIL1               (1<<28)
80 #define IT_SIGIL2               (1<<29)
81 #define IT_SIGIL3               (1<<30)
82 #define IT_SIGIL4               (1<<31)
83
84 //===========================================
85 // AK nexuiz changed and added defines
86
87 #define NEX_IT_UZI              1
88 #define NEX_IT_SHOTGUN          2
89 #define NEX_IT_GRENADE_LAUNCHER 4
90 #define NEX_IT_ELECTRO          8
91 #define NEX_IT_CRYLINK          16
92 #define NEX_IT_NEX              32
93 #define NEX_IT_HAGAR            64
94 #define NEX_IT_ROCKET_LAUNCHER  128
95 #define NEX_IT_SHELLS           256
96 #define NEX_IT_BULLETS          512
97 #define NEX_IT_ROCKETS          1024
98 #define NEX_IT_CELLS            2048
99 #define NEX_IT_LASER            4094
100 #define NEX_IT_STRENGTH         8192
101 #define NEX_IT_INVINCIBLE       16384
102 #define NEX_IT_SPEED            32768
103 #define NEX_IT_SLOWMO           65536
104
105 //===========================================
106 //rogue changed and added defines
107
108 #define RIT_SHELLS              128
109 #define RIT_NAILS               256
110 #define RIT_ROCKETS             512
111 #define RIT_CELLS               1024
112 #define RIT_AXE                 2048
113 #define RIT_LAVA_NAILGUN        4096
114 #define RIT_LAVA_SUPER_NAILGUN  8192
115 #define RIT_MULTI_GRENADE       16384
116 #define RIT_MULTI_ROCKET        32768
117 #define RIT_PLASMA_GUN          65536
118 #define RIT_ARMOR1              8388608
119 #define RIT_ARMOR2              16777216
120 #define RIT_ARMOR3              33554432
121 #define RIT_LAVA_NAILS          67108864
122 #define RIT_PLASMA_AMMO         134217728
123 #define RIT_MULTI_ROCKETS       268435456
124 #define RIT_SHIELD              536870912
125 #define RIT_ANTIGRAV            1073741824
126 #define RIT_SUPERHEALTH         2147483648
127
128 //MED 01/04/97 added hipnotic defines
129 //===========================================
130 //hipnotic added defines
131 #define HIT_PROXIMITY_GUN_BIT 16
132 #define HIT_MJOLNIR_BIT       7
133 #define HIT_LASER_CANNON_BIT  23
134 #define HIT_PROXIMITY_GUN   (1<<HIT_PROXIMITY_GUN_BIT)
135 #define HIT_MJOLNIR         (1<<HIT_MJOLNIR_BIT)
136 #define HIT_LASER_CANNON    (1<<HIT_LASER_CANNON_BIT)
137 #define HIT_WETSUIT         (1<<(23+2))
138 #define HIT_EMPATHY_SHIELDS (1<<(23+3))
139
140 //===========================================
141
142 #include "zone.h"
143 #include "thread.h"
144 #include "fs.h"
145 #include "common.h"
146 #include "com_list.h"
147 #include "cvar.h"
148 #include "bspfile.h"
149 #include "sys.h"
150 #include "vid.h"
151 #include "mathlib.h"
152
153 #include "r_textures.h"
154
155 #include "crypto.h"
156 #include "draw.h"
157 #include "screen.h"
158 #include "netconn.h"
159 #include "protocol.h"
160 #include "cmd.h"
161 #include "host.h"
162 #include "sbar.h"
163 #include "sound.h"
164 #include "model_shared.h"
165 #include "world.h"
166 #include "client.h"
167 #include "render.h"
168 #include "progs.h"
169 #include "progsvm.h"
170 #include "server.h"
171
172 #include "input.h"
173 #include "keys.h"
174 #include "console.h"
175 #ifdef CONFIG_MENU
176 #include "menu.h"
177 #endif
178 #include "csprogs.h"
179
180 extern qbool noclip_anglehack;
181
182 extern cvar_t developer;
183 extern cvar_t developer_entityparsing;
184 extern cvar_t developer_extra;
185 extern cvar_t developer_insane;
186 extern cvar_t developer_loadfile;
187 extern cvar_t developer_loading;
188
189 extern cvar_t sessionid;
190
191 #define STARTCONFIGFILENAME "quake.rc"
192 #define CONFIGFILENAME "config.cfg"
193
194 /* Preprocessor macros to identify platform
195     DP_OS_NAME  - "friendly" name of the OS, for humans to read
196     DP_OS_STR   - "identifier" of the OS, more suited for code to use
197     DP_ARCH_STR - "identifier" of the processor architecture
198  */
199 #if defined(__ANDROID__) /* must come first because it also defines linux */
200 # define DP_OS_NAME             "Android"
201 # define DP_OS_STR              "android"
202 # define USE_GLES2              1
203 # define USE_RWOPS              1
204 # define LINK_TO_ZLIB   1
205 # define LINK_TO_LIBVORBIS 1
206 #ifdef USEXMP
207 # define LINK_TO_LIBXMP 1 // nyov: if someone can test with the android NDK compiled libxmp?
208 #endif
209 # define DP_MOBILETOUCH 1
210 # define DP_FREETYPE_STATIC 1
211 #elif TARGET_OS_IPHONE /* must come first because it also defines MACOSX */
212 # define DP_OS_NAME             "iPhoneOS"
213 # define DP_OS_STR              "iphoneos"
214 # define USE_GLES2              1
215 # define LINK_TO_ZLIB   1
216 # define LINK_TO_LIBVORBIS 1
217 # define DP_MOBILETOUCH 1
218 # define DP_FREETYPE_STATIC 1
219 #elif defined(__linux__)
220 # define DP_OS_NAME             "Linux"
221 # define DP_OS_STR              "linux"
222 #elif defined(_WIN64)
223 # define DP_OS_NAME             "Windows64"
224 # define DP_OS_STR              "win64"
225 #elif defined(WIN32)
226 # define DP_OS_NAME             "Windows"
227 # define DP_OS_STR              "win32"
228 #elif defined(__FreeBSD__)
229 # define DP_OS_NAME             "FreeBSD"
230 # define DP_OS_STR              "freebsd"
231 #elif defined(__NetBSD__)
232 # define DP_OS_NAME             "NetBSD"
233 # define DP_OS_STR              "netbsd"
234 #elif defined(__OpenBSD__)
235 # define DP_OS_NAME             "OpenBSD"
236 # define DP_OS_STR              "openbsd"
237 #elif defined(__DragonFly__)
238 # define DP_OS_NAME             "DragonFlyBSD"
239 # define DP_OS_STR              "dragonflybsd"
240 #elif defined(MACOSX)
241 # define DP_OS_NAME             "Mac OS X"
242 # define DP_OS_STR              "osx"
243 #elif defined(__MORPHOS__)
244 # define DP_OS_NAME             "MorphOS"
245 # define DP_OS_STR              "morphos"
246 #elif defined (sun) || defined (__sun)
247 # if defined (__SVR4) || defined (__svr4__)
248 #  define DP_OS_NAME    "Solaris"
249 #  define DP_OS_STR             "solaris"
250 # else
251 #  define DP_OS_NAME    "SunOS"
252 #  define DP_OS_STR             "sunos"
253 # endif
254 #else
255 # define DP_OS_NAME             "Unknown"
256 # define DP_OS_STR              "unknown"
257 #endif
258
259 #if defined(__GNUC__) || (__clang__)
260 # if defined(__i386__)
261 #  define DP_ARCH_STR           "686"
262 #  define SSE_POSSIBLE
263 #  ifdef __SSE__
264 #   define SSE_PRESENT
265 #  endif
266 #  ifdef __SSE2__
267 #   define SSE2_PRESENT
268 #  endif
269 # elif defined(__x86_64__)
270 #  define DP_ARCH_STR           "x86_64"
271 #  define SSE_PRESENT
272 #  define SSE2_PRESENT
273 # elif defined(__powerpc__)
274 #  define DP_ARCH_STR           "ppc"
275 # endif
276 #elif defined(_WIN64)
277 # define DP_ARCH_STR            "x86_64"
278 # define SSE_PRESENT
279 # define SSE2_PRESENT
280 #elif defined(WIN32)
281 # define DP_ARCH_STR            "x86"
282 # define SSE_POSSIBLE
283 #endif
284
285 #ifdef SSE_PRESENT
286 # define SSE_POSSIBLE
287 #endif
288
289 #ifdef NO_SSE
290 # undef SSE_PRESENT
291 # undef SSE_POSSIBLE
292 # undef SSE2_PRESENT
293 #endif
294
295 #ifdef SSE_POSSIBLE
296 // runtime detection of SSE/SSE2 capabilities for x86
297 qbool Sys_HaveSSE(void);
298 qbool Sys_HaveSSE2(void);
299 #else
300 #define Sys_HaveSSE() false
301 #define Sys_HaveSSE2() false
302 #endif
303
304 #include "glquake.h"
305
306 #include "palette.h"
307 extern cvar_t host_isclient;
308
309 /// skill level for currently loaded level (in case the user changes the cvar while the level is running, this reflects the level actually in use)
310 extern int current_skill;
311
312 //
313 // chase
314 //
315 extern cvar_t chase_active;
316 extern cvar_t cl_viewmodel_scale;
317
318 void Chase_Init (void);
319 void Chase_Reset (void);
320 void Chase_Update (void);
321
322 void fractalnoise(unsigned char *noise, int size, int startgrid);
323 void fractalnoisequick(unsigned char *noise, int size, int startgrid);
324 float noise4f(float x, float y, float z, float w);
325
326 void Sys_Shared_Init(void);
327
328 // Flag in size field of demos to indicate a client->server packet. Demo
329 // playback will ignore this, but it may be useful to make DP sniff packets to
330 // debug protocol exploits.
331 #define DEMOMSG_CLIENT_TO_SERVER 0x80000000
332
333 // In Quake, any char in 0..32 counts as whitespace
334 //#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
335 #define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
336 #define ISCOMMENT(ch, pos) ch[pos] == '/' && ch[pos + 1] == '/' && (pos == 0 || ISWHITESPACE(ch[pos - 1]))
337 // This also includes extended characters, and ALL control chars
338 #define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
339
340
341 #ifdef PRVM_64
342 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
343 #define FLOAT_LOSSLESS_FORMAT "%.17g"
344 #define VECTOR_LOSSLESS_FORMAT "%.17g %.17g %.17g"
345 #else
346 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
347 #define FLOAT_LOSSLESS_FORMAT "%.9g"
348 #define VECTOR_LOSSLESS_FORMAT "%.9g %.9g %.9g"
349 #endif
350
351 // originally this was _MSC_VER
352 // but here we want to test the system libc, which on win32 is borked, and NOT the compiler
353 #ifdef WIN32
354 #define INT_LOSSLESS_FORMAT_SIZE "I64"
355 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((__int64)(x))
356 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((unsigned __int64)(x))
357 #else
358 #define INT_LOSSLESS_FORMAT_SIZE "j"
359 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((intmax_t)(x))
360 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((uintmax_t)(x))
361 #endif
362
363 #endif
364