]> icculus.org git repositories - divverent/darkplaces.git/blob - quakedef.h
added DP_ENT_GLOWMOD extension, like DP_ENT_COLORMOD but alters glow
[divverent/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 /// on UNIX platforms we need to define this so that video saving does not cause a SIGFSZ (file size) signal when a video clip exceeds 2GB
26 #define _FILE_OFFSET_BITS 64
27
28 // for cd_linux.c
29 #define __KERNEL_STRICT_NAMES
30
31 #if defined(__GNUC__) && (__GNUC__ > 2)
32 #define DP_FUNC_PRINTF(n) __attribute__ ((format (printf, n, n+1)))
33 #define DP_FUNC_PURE      __attribute__ ((pure))
34 #else
35 #define DP_FUNC_PRINTF(n)
36 #define DP_FUNC_PURE
37 #endif
38
39 #include <sys/types.h>
40 #include <ctype.h>
41 #include <math.h>
42 #include <string.h>
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <limits.h>
47 #include <setjmp.h>
48
49 #include "qtypes.h"
50
51 extern char *buildstring;
52 extern char engineversion[128];
53
54 #define GAMENAME "id1"
55
56 #define MAX_NUM_ARGVS   50
57
58
59 #define MAX_QPATH               128                     ///< max length of a quake game pathname
60 #define MAX_OSPATH              1024            ///< max length of a filesystem pathname
61
62 #define ON_EPSILON              0.1                     ///< point on plane side epsilon
63
64 #define MAX_PACKETFRAGMENT 1024         ///< max length of packet fragment
65 #define NET_MAXMESSAGE  65536
66 #define NET_MINRATE             1000 ///< limits "rate" and "sv_maxrate" cvars
67
68 //
69 // per-level limits
70 //
71 // LordHavoc: increased entity limit to 2048 from 600
72 #define MAX_EDICTS              32768           // FIXME: ouch! ouch! ouch!
73 #define MAX_LIGHTSTYLES 256                     // LordHavoc: increased from 64, NOTE special consideration is needed in savegames!
74 // LordHavoc: increased model and sound limits from 256 and 256 to 4096 and 4096 (and added protocol extensions accordingly to break the 256 barrier)
75 // div0: increased model limit to 8192
76 #define MAX_MODELS              8192
77 #define MAX_SOUNDS              4096
78
79 #define SAVEGAME_COMMENT_LENGTH 39
80
81 #define MAX_STYLESTRING 64
82
83 //
84 // stats are integers communicated to the client by the server
85 //
86 #define MAX_CL_STATS            256
87 #define STAT_HEALTH                     0
88 //#define       STAT_FRAGS                      1
89 #define STAT_WEAPON                     2
90 #define STAT_AMMO                       3
91 #define STAT_ARMOR                      4
92 #define STAT_WEAPONFRAME        5
93 #define STAT_SHELLS                     6
94 #define STAT_NAILS                      7
95 #define STAT_ROCKETS            8
96 #define STAT_CELLS                      9
97 #define STAT_ACTIVEWEAPON       10
98 #define STAT_TOTALSECRETS       11
99 #define STAT_TOTALMONSTERS      12
100 #define STAT_SECRETS            13              ///< bumped on client side by svc_foundsecret
101 #define STAT_MONSTERS           14              ///< bumped by svc_killedmonster
102 #define STAT_ITEMS                      15 ///< FTE, DP
103 #define STAT_VIEWHEIGHT         16 ///< FTE, DP
104 //#define STAT_TIME                     17 ///< FTE
105 //#define STAT_VIEW2            20 ///< FTE
106 #define STAT_VIEWZOOM           21 ///< DP
107 #define STAT_MOVEFLAGS                              225 ///< DP
108 #define STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL       226 ///< DP
109 #define STAT_MOVEVARS_WARSOWBUNNY_ACCEL                         227 ///< DP
110 #define STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED                      228 ///< DP
111 #define STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL                     229 ///< DP
112 #define STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO       230 ///< DP
113 #define STAT_MOVEVARS_AIRSTOPACCELERATE                         231 ///< DP
114 #define STAT_MOVEVARS_AIRSTRAFEACCELERATE                       232 ///< DP
115 #define STAT_MOVEVARS_MAXAIRSTRAFESPEED                         233 ///< DP
116 #define STAT_MOVEVARS_AIRCONTROL                                        234 ///< DP
117 #define STAT_FRAGLIMIT                                                          235 ///< DP
118 #define STAT_TIMELIMIT                                                          236 ///< DP
119 #define STAT_MOVEVARS_WALLFRICTION                                      237 ///< DP
120 #define STAT_MOVEVARS_FRICTION                                          238 ///< DP
121 #define STAT_MOVEVARS_WATERFRICTION                                     239 ///< DP
122 #define STAT_MOVEVARS_TICRATE                                           240 ///< DP
123 #define STAT_MOVEVARS_TIMESCALE                                         241 ///< DP
124 #define STAT_MOVEVARS_GRAVITY                                           242 ///< DP
125 #define STAT_MOVEVARS_STOPSPEED                                         243 ///< DP
126 #define STAT_MOVEVARS_MAXSPEED                                          244 ///< DP
127 #define STAT_MOVEVARS_SPECTATORMAXSPEED                         245 ///< DP
128 #define STAT_MOVEVARS_ACCELERATE                                        246 ///< DP
129 #define STAT_MOVEVARS_AIRACCELERATE                                     247 ///< DP
130 #define STAT_MOVEVARS_WATERACCELERATE                           248 ///< DP
131 #define STAT_MOVEVARS_ENTGRAVITY                                        249 ///< DP
132 #define STAT_MOVEVARS_JUMPVELOCITY                                      250 ///< DP
133 #define STAT_MOVEVARS_EDGEFRICTION                                      251 ///< DP
134 #define STAT_MOVEVARS_MAXAIRSPEED                                       252 ///< DP
135 #define STAT_MOVEVARS_STEPHEIGHT                                        253 ///< DP
136 #define STAT_MOVEVARS_AIRACCEL_QW                                       254 ///< DP
137 #define STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION        255 ///< DP
138
139 // moveflags values
140 #define MOVEFLAG_VALID 0x80000000
141 #define MOVEFLAG_Q2AIRACCELERATE 0x00000001
142
143 // stock defines
144
145 #define IT_SHOTGUN                              1
146 #define IT_SUPER_SHOTGUN                2
147 #define IT_NAILGUN                              4
148 #define IT_SUPER_NAILGUN                8
149 #define IT_GRENADE_LAUNCHER             16
150 #define IT_ROCKET_LAUNCHER              32
151 #define IT_LIGHTNING                    64
152 #define IT_SUPER_LIGHTNING      128
153 #define IT_SHELLS               256
154 #define IT_NAILS                512
155 #define IT_ROCKETS              1024
156 #define IT_CELLS                2048
157 #define IT_AXE                  4096
158 #define IT_ARMOR1               8192
159 #define IT_ARMOR2               16384
160 #define IT_ARMOR3               32768
161 #define IT_SUPERHEALTH          65536
162 #define IT_KEY1                 131072
163 #define IT_KEY2                 262144
164 #define IT_INVISIBILITY                 524288
165 #define IT_INVULNERABILITY              1048576
166 #define IT_SUIT                                 2097152
167 #define IT_QUAD                                 4194304
168 #define IT_SIGIL1               (1<<28)
169 #define IT_SIGIL2               (1<<29)
170 #define IT_SIGIL3               (1<<30)
171 #define IT_SIGIL4               (1<<31)
172
173 //===========================================
174 // AK nexuiz changed and added defines
175
176 #define NEX_IT_UZI              1
177 #define NEX_IT_SHOTGUN          2
178 #define NEX_IT_GRENADE_LAUNCHER 4
179 #define NEX_IT_ELECTRO          8
180 #define NEX_IT_CRYLINK          16
181 #define NEX_IT_NEX              32
182 #define NEX_IT_HAGAR            64
183 #define NEX_IT_ROCKET_LAUNCHER  128
184 #define NEX_IT_SHELLS           256
185 #define NEX_IT_BULLETS          512
186 #define NEX_IT_ROCKETS          1024
187 #define NEX_IT_CELLS            2048
188 #define NEX_IT_LASER            4094
189 #define NEX_IT_STRENGTH         8192
190 #define NEX_IT_INVINCIBLE       16384
191 #define NEX_IT_SPEED            32768
192 #define NEX_IT_SLOWMO           65536
193
194 //===========================================
195 //rogue changed and added defines
196
197 #define RIT_SHELLS              128
198 #define RIT_NAILS               256
199 #define RIT_ROCKETS             512
200 #define RIT_CELLS               1024
201 #define RIT_AXE                 2048
202 #define RIT_LAVA_NAILGUN        4096
203 #define RIT_LAVA_SUPER_NAILGUN  8192
204 #define RIT_MULTI_GRENADE       16384
205 #define RIT_MULTI_ROCKET        32768
206 #define RIT_PLASMA_GUN          65536
207 #define RIT_ARMOR1              8388608
208 #define RIT_ARMOR2              16777216
209 #define RIT_ARMOR3              33554432
210 #define RIT_LAVA_NAILS          67108864
211 #define RIT_PLASMA_AMMO         134217728
212 #define RIT_MULTI_ROCKETS       268435456
213 #define RIT_SHIELD              536870912
214 #define RIT_ANTIGRAV            1073741824
215 #define RIT_SUPERHEALTH         2147483648
216
217 //MED 01/04/97 added hipnotic defines
218 //===========================================
219 //hipnotic added defines
220 #define HIT_PROXIMITY_GUN_BIT 16
221 #define HIT_MJOLNIR_BIT       7
222 #define HIT_LASER_CANNON_BIT  23
223 #define HIT_PROXIMITY_GUN   (1<<HIT_PROXIMITY_GUN_BIT)
224 #define HIT_MJOLNIR         (1<<HIT_MJOLNIR_BIT)
225 #define HIT_LASER_CANNON    (1<<HIT_LASER_CANNON_BIT)
226 #define HIT_WETSUIT         (1<<(23+2))
227 #define HIT_EMPATHY_SHIELDS (1<<(23+3))
228
229 //===========================================
230
231 // LordHavoc: increased player limit from 16 to 255
232 #define MAX_SCOREBOARD          255
233 // LordHavoc: increased name limit from 32 to 64 characters
234 #define MAX_SCOREBOARDNAME      64
235 // infostring sizes used by QuakeWorld support
236 // was 196
237 #define MAX_USERINFO_STRING 1280
238 // was 512
239 #define MAX_SERVERINFO_STRING 1280
240 #define MAX_LOCALINFO_STRING 32768
241
242 #include "zone.h"
243 #include "fs.h"
244 #include "common.h"
245 #include "cvar.h"
246 #include "bspfile.h"
247 #include "sys.h"
248 #include "vid.h"
249 #include "mathlib.h"
250
251 #include "r_textures.h"
252
253 #include "draw.h"
254 #include "screen.h"
255 #include "netconn.h"
256 #include "protocol.h"
257 #include "cmd.h"
258 #include "sbar.h"
259 #include "sound.h"
260 #include "model_shared.h"
261 #include "world.h"
262 #include "client.h"
263 #include "render.h"
264 #include "progs.h"
265 #include "progsvm.h"
266 #include "server.h"
267
268 #include "input.h"
269 #include "keys.h"
270 #include "console.h"
271 #include "menu.h"
272
273 #include "glquake.h"
274
275 #include "palette.h"
276
277 extern qboolean noclip_anglehack;
278
279 extern cvar_t developer;
280 extern cvar_t developer_loadfile;
281 extern cvar_t developer_loading;
282
283 /* Preprocessor macros to identify platform
284     DP_OS_NAME  - "friendly" name of the OS, for humans to read
285     DP_OS_STR   - "identifier" of the OS, more suited for code to use
286     DP_ARCH_STR - "identifier" of the processor architecture
287  */
288 #if defined(__linux__)
289 # define DP_OS_NAME             "Linux"
290 # define DP_OS_STR              "linux"
291 #elif defined(WIN64)
292 # define DP_OS_NAME             "Windows64"
293 # define DP_OS_STR              "win64"
294 #elif defined(WIN32)
295 # define DP_OS_NAME             "Windows"
296 # define DP_OS_STR              "win32"
297 #elif defined(__FreeBSD__)
298 # define DP_OS_NAME             "FreeBSD"
299 # define DP_OS_STR              "freebsd"
300 #elif defined(__NetBSD__)
301 # define DP_OS_NAME             "NetBSD"
302 # define DP_OS_STR              "netbsd"
303 #elif defined(__OpenBSD__)
304 # define DP_OS_NAME             "OpenBSD"
305 # define DP_OS_STR              "openbsd"
306 #elif defined(MACOSX)
307 # define DP_OS_NAME             "Mac OS X"
308 # define DP_OS_STR              "osx"
309 #elif defined(__MORPHOS__)
310 # define DP_OS_NAME             "MorphOS"
311 # define DP_OS_STR              "morphos"
312 #else
313 # define DP_OS_NAME             "Unknown"
314 #endif
315
316 #if defined(__GNUC__)
317 # if defined(__i386__)
318 #  define DP_ARCH_STR           "686"
319 # elif defined(__x86_64__)
320 #  define DP_ARCH_STR           "x86_64"
321 # elif defined(__powerpc__)
322 #  define DP_ARCH_STR           "ppc"
323 # endif
324 #elif defined(WIN64)
325 # define DP_ARCH_STR            "x86_64"
326 #elif defined(WIN32)
327 # define DP_ARCH_STR            "x86"
328 #endif
329
330 /// incremented every frame, never reset
331 extern int host_framecount;
332 /// not bounded in any way, changed at start of every frame, never reset
333 extern double realtime;
334
335 void Host_InitCommands(void);
336 void Host_Main(void);
337 void Host_Shutdown(void);
338 void Host_StartVideo(void);
339 void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1);
340 void Host_Quit_f(void);
341 void Host_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1);
342 void Host_ShutdownServer(void);
343 void Host_Reconnect_f(void);
344 void Host_NoOperation_f(void);
345
346 void Host_AbortCurrentFrame(void);
347
348 /// 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)
349 extern int current_skill;
350
351 //
352 // chase
353 //
354 extern cvar_t chase_active;
355 extern cvar_t cl_viewmodel_scale;
356
357 void Chase_Init (void);
358 void Chase_Reset (void);
359 void Chase_Update (void);
360
361 void fractalnoise(unsigned char *noise, int size, int startgrid);
362 void fractalnoisequick(unsigned char *noise, int size, int startgrid);
363 float noise4f(float x, float y, float z, float w);
364
365 void Sys_Shared_Init(void);
366
367 // Flag in size field of demos to indicate a client->server packet. Demo
368 // playback will ignore this, but it may be useful to make DP sniff packets to
369 // debug protocol exploits.
370 #define DEMOMSG_CLIENT_TO_SERVER 0x80000000
371
372 // In Quake, any char in 0..32 counts as whitespace
373 //#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
374 #define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
375
376 // This also includes extended characters, and ALL control chars
377 #define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
378
379
380 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
381
382 #endif
383