]> icculus.org git repositories - divverent/darkplaces.git/blob - quakedef.h
bump a few limits in DP_SMALLMEMORY (cachedpics was too low for even
[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 #ifdef DP_SMALLMEMORY
59 #define MAX_INPUTLINE                   1024
60 #define CON_TEXTSIZE                    16384
61 #define CON_MAXLINES                    256
62 #define HIST_TEXTSIZE                   2048
63 #define HIST_MAXLINES                   16
64 #define MAX_ALIAS_NAME                  32
65 #define CMDBUFSIZE                              131072
66 #define MAX_ARGS                                10
67
68 #define NET_MAXMESSAGE                  16384
69 #define MAX_PACKETFRAGMENT              1024
70 #define MAX_EDICTS                              4096
71 #define MAX_MODELS                              1024
72 #define MAX_SOUNDS                              1024
73 #define MAX_LIGHTSTYLES                 64
74 #define MAX_STYLESTRING                 16
75 #define MAX_SCOREBOARD                  32
76 #define MAX_SCOREBOARDNAME              64
77 #define MAX_USERINFO_STRING             196
78 #define MAX_SERVERINFO_STRING   512
79 #define MAX_LOCALINFO_STRING    1 // not actually used by DP servers
80 #define CL_MAX_USERCMDS                 32
81 #define CVAR_HASHSIZE                   1024
82 #define M_MAX_EDICTS                    4096
83 #define MAX_DEMOS                               8
84 #define MAX_DEMONAME                    16
85 #define MAX_SAVEGAMES                   12
86 #define SAVEGAME_COMMENT_LENGTH 39
87 #define MAX_CLIENTNETWORKEYES   2
88 #define MAX_OCCLUSION_QUERIES   256
89
90 #define MAX_WATERPLANES                 2
91 #define MAX_CUBEMAPS                    64
92 #define MAX_EXPLOSIONS                  8
93 #define MAX_DLIGHTS                             16
94 #define MAX_CACHED_PICS                 512 // this is 144 bytes each (or 152 on 64bit)
95 #define CACHEPICHASHSIZE                256
96 #define MAX_PARTICLEEFFECTNAME  64
97 #define MAX_PARTICLEEFFECTINFO  256
98 #define MAX_PARTICLETEXTURES    96
99 #define MAXCLVIDEOS                             1
100 #define MAX_GECKO_INSTANCES             1
101 #define MAX_DYNAMIC_TEXTURE_COUNT       2
102 #define MAX_MAP_LEAFS                   8192
103
104 #define MAXTRACKS                               256
105 #define MAX_DYNAMIC_CHANNELS    64
106 #define MAX_CHANNELS                    260
107 #else
108 #define MAX_INPUTLINE                   16384 ///< maximum length of console commandline, QuakeC strings, and many other text processing buffers
109 #define CON_TEXTSIZE                    1048576 ///< max scrollback buffer characters in console
110 #define CON_MAXLINES                    16384 ///< max scrollback buffer lines in console
111 #define HIST_TEXTSIZE                   262144 ///< max command history buffer characters in console
112 #define HIST_MAXLINES                   4096 ///< max command history buffer lines in console
113 #define MAX_ALIAS_NAME                  32
114 #define CMDBUFSIZE                              655360 ///< maximum script size that can be loaded by the exec command (8192 in Quake)
115 #define MAX_ARGS                                80 ///< maximum number of parameters to a console command or alias
116
117 #define NET_MAXMESSAGE                  65536 ///< max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT)
118 #define MAX_PACKETFRAGMENT              1024 ///< max length of packet fragment
119 #define MAX_EDICTS                              32768 ///< max number of objects in game world at once (32768 protocol limit)
120 #define MAX_MODELS                              8192 ///< max number of models loaded at once (including during level transitions)
121 #define MAX_SOUNDS                              4096 ///< max number of sounds loaded at once
122 #define MAX_LIGHTSTYLES                 256 ///< max flickering light styles in level (note: affects savegame format)
123 #define MAX_STYLESTRING                 64 ///< max length of flicker pattern for light style
124 #define MAX_SCOREBOARD                  255 ///< max number of players in game at once (255 protocol limit)
125 #define MAX_SCOREBOARDNAME              64 ///< max length of player name in game
126 #define MAX_USERINFO_STRING             1280 ///< max length of infostring for PROTOCOL_QUAKEWORLD (196 in QuakeWorld)
127 #define MAX_SERVERINFO_STRING   1280 ///< max length of server infostring for PROTOCOL_QUAKEWORLD (512 in QuakeWorld)
128 #define MAX_LOCALINFO_STRING    32768 ///< max length of server-local infostring for PROTOCOL_QUAKEWORLD (32768 in QuakeWorld)
129 #define CL_MAX_USERCMDS                 128 ///< max number of predicted input packets in queue
130 #define CVAR_HASHSIZE                   65536 ///< number of hash buckets for accelerating cvar name lookups
131 #define M_MAX_EDICTS                    32768 ///< max objects in menu vm
132 #define MAX_DEMOS                               8 ///< max demos provided to demos command
133 #define MAX_DEMONAME                    16 ///< max demo name length for demos command
134 #define MAX_SAVEGAMES                   12 ///< max savegames listed in savegame menu
135 #define SAVEGAME_COMMENT_LENGTH 39 ///< max comment length of savegame in menu
136 #define MAX_CLIENTNETWORKEYES   2 ///< max number of locations that can be added to pvs when culling network entities (must be at least 2 for prediction)
137 #define MAX_OCCLUSION_QUERIES   4096 ///< max number of GL_ARB_occlusion_query objects that can be used in one frame
138
139 #define MAX_WATERPLANES                 16 ///< max number of water planes visible (each one causes additional view renders)
140 #define MAX_CUBEMAPS                    256 ///< max number of cubemap textures loaded for light filters
141 #define MAX_EXPLOSIONS                  64 ///< max number of explosion shell effects active at once (not particle related)
142 #define MAX_DLIGHTS                             256 ///< max number of dynamic lights (rocket flashes, etc) in scene at once
143 #define MAX_CACHED_PICS                 1024 ///< max number of 2D pics loaded at once
144 #define CACHEPICHASHSIZE                256 ///< number of hash buckets for accelerating 2D pic name lookups
145 #define MAX_PARTICLEEFFECTNAME  256 ///< maximum number of unique names of particle effects (for particleeffectnum)
146 #define MAX_PARTICLEEFFECTINFO  4096 ///< maximum number of unique particle effects (each name may associate with several of these)
147 #define MAX_PARTICLETEXTURES    1024 ///< maximum number of unique particle textures in the particle font
148 #define MAXCLVIDEOS                             65 ///< maximum number of video streams being played back at once (1 is reserved for the playvideo command)
149 #define MAX_GECKO_INSTANCES             16 ///< maximum number of web browser textures active at once
150 #define MAX_DYNAMIC_TEXTURE_COUNT       64 ///< maximum number of dynamic textures (web browsers, playvideo, etc)
151 #define MAX_MAP_LEAFS                   65536 ///< maximum number of BSP leafs in world (8192 in Quake)
152
153 #define MAXTRACKS                               256 ///< max CD track index
154 // 0 to NUM_AMBIENTS - 1 = water, etc
155 // NUM_AMBIENTS to NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS - 1 = normal entity sounds
156 // NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS to total_channels = static sounds
157 #define MAX_DYNAMIC_CHANNELS    512
158 #define MAX_CHANNELS                    1028
159 #endif
160
161
162 #define CMD_TOKENIZELENGTH (MAX_INPUTLINE + MAX_ARGS) ///< maximum tokenizable commandline length (counting trailing 0)
163
164
165 #define MAX_QPATH               128                     ///< max length of a quake game pathname
166 #ifdef PATH_MAX
167 #define MAX_OSPATH              PATH_MAX
168 #elif MAX_PATH
169 #define MAX_OSPATH              MAX_PATH
170 #else
171 #define MAX_OSPATH              1024            ///< max length of a filesystem pathname
172 #endif
173
174 #define ON_EPSILON              0.1                     ///< point on plane side epsilon
175
176 #define NET_MINRATE             1000 ///< limits "rate" and "sv_maxrate" cvars
177
178 //
179 // stats are integers communicated to the client by the server
180 //
181 #define MAX_CL_STATS            256
182 #define STAT_HEALTH                     0
183 //#define       STAT_FRAGS                      1
184 #define STAT_WEAPON                     2
185 #define STAT_AMMO                       3
186 #define STAT_ARMOR                      4
187 #define STAT_WEAPONFRAME        5
188 #define STAT_SHELLS                     6
189 #define STAT_NAILS                      7
190 #define STAT_ROCKETS            8
191 #define STAT_CELLS                      9
192 #define STAT_ACTIVEWEAPON       10
193 #define STAT_TOTALSECRETS       11
194 #define STAT_TOTALMONSTERS      12
195 #define STAT_SECRETS            13              ///< bumped on client side by svc_foundsecret
196 #define STAT_MONSTERS           14              ///< bumped by svc_killedmonster
197 #define STAT_ITEMS                      15 ///< FTE, DP
198 #define STAT_VIEWHEIGHT         16 ///< FTE, DP
199 //#define STAT_TIME                     17 ///< FTE
200 //#define STAT_VIEW2            20 ///< FTE
201 #define STAT_VIEWZOOM           21 ///< DP
202 #define STAT_MOVEFLAGS                              225 ///< DP
203 #define STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL       226 ///< DP
204 #define STAT_MOVEVARS_WARSOWBUNNY_ACCEL                         227 ///< DP
205 #define STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED                      228 ///< DP
206 #define STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL                     229 ///< DP
207 #define STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO       230 ///< DP
208 #define STAT_MOVEVARS_AIRSTOPACCELERATE                         231 ///< DP
209 #define STAT_MOVEVARS_AIRSTRAFEACCELERATE                       232 ///< DP
210 #define STAT_MOVEVARS_MAXAIRSTRAFESPEED                         233 ///< DP
211 #define STAT_MOVEVARS_AIRCONTROL                                        234 ///< DP
212 #define STAT_FRAGLIMIT                                                          235 ///< DP
213 #define STAT_TIMELIMIT                                                          236 ///< DP
214 #define STAT_MOVEVARS_WALLFRICTION                                      237 ///< DP
215 #define STAT_MOVEVARS_FRICTION                                          238 ///< DP
216 #define STAT_MOVEVARS_WATERFRICTION                                     239 ///< DP
217 #define STAT_MOVEVARS_TICRATE                                           240 ///< DP
218 #define STAT_MOVEVARS_TIMESCALE                                         241 ///< DP
219 #define STAT_MOVEVARS_GRAVITY                                           242 ///< DP
220 #define STAT_MOVEVARS_STOPSPEED                                         243 ///< DP
221 #define STAT_MOVEVARS_MAXSPEED                                          244 ///< DP
222 #define STAT_MOVEVARS_SPECTATORMAXSPEED                         245 ///< DP
223 #define STAT_MOVEVARS_ACCELERATE                                        246 ///< DP
224 #define STAT_MOVEVARS_AIRACCELERATE                                     247 ///< DP
225 #define STAT_MOVEVARS_WATERACCELERATE                           248 ///< DP
226 #define STAT_MOVEVARS_ENTGRAVITY                                        249 ///< DP
227 #define STAT_MOVEVARS_JUMPVELOCITY                                      250 ///< DP
228 #define STAT_MOVEVARS_EDGEFRICTION                                      251 ///< DP
229 #define STAT_MOVEVARS_MAXAIRSPEED                                       252 ///< DP
230 #define STAT_MOVEVARS_STEPHEIGHT                                        253 ///< DP
231 #define STAT_MOVEVARS_AIRACCEL_QW                                       254 ///< DP
232 #define STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION        255 ///< DP
233
234 // moveflags values
235 #define MOVEFLAG_VALID 0x80000000
236 #define MOVEFLAG_Q2AIRACCELERATE 0x00000001
237
238 // stock defines
239
240 #define IT_SHOTGUN                              1
241 #define IT_SUPER_SHOTGUN                2
242 #define IT_NAILGUN                              4
243 #define IT_SUPER_NAILGUN                8
244 #define IT_GRENADE_LAUNCHER             16
245 #define IT_ROCKET_LAUNCHER              32
246 #define IT_LIGHTNING                    64
247 #define IT_SUPER_LIGHTNING      128
248 #define IT_SHELLS               256
249 #define IT_NAILS                512
250 #define IT_ROCKETS              1024
251 #define IT_CELLS                2048
252 #define IT_AXE                  4096
253 #define IT_ARMOR1               8192
254 #define IT_ARMOR2               16384
255 #define IT_ARMOR3               32768
256 #define IT_SUPERHEALTH          65536
257 #define IT_KEY1                 131072
258 #define IT_KEY2                 262144
259 #define IT_INVISIBILITY                 524288
260 #define IT_INVULNERABILITY              1048576
261 #define IT_SUIT                                 2097152
262 #define IT_QUAD                                 4194304
263 #define IT_SIGIL1               (1<<28)
264 #define IT_SIGIL2               (1<<29)
265 #define IT_SIGIL3               (1<<30)
266 #define IT_SIGIL4               (1<<31)
267
268 //===========================================
269 // AK nexuiz changed and added defines
270
271 #define NEX_IT_UZI              1
272 #define NEX_IT_SHOTGUN          2
273 #define NEX_IT_GRENADE_LAUNCHER 4
274 #define NEX_IT_ELECTRO          8
275 #define NEX_IT_CRYLINK          16
276 #define NEX_IT_NEX              32
277 #define NEX_IT_HAGAR            64
278 #define NEX_IT_ROCKET_LAUNCHER  128
279 #define NEX_IT_SHELLS           256
280 #define NEX_IT_BULLETS          512
281 #define NEX_IT_ROCKETS          1024
282 #define NEX_IT_CELLS            2048
283 #define NEX_IT_LASER            4094
284 #define NEX_IT_STRENGTH         8192
285 #define NEX_IT_INVINCIBLE       16384
286 #define NEX_IT_SPEED            32768
287 #define NEX_IT_SLOWMO           65536
288
289 //===========================================
290 //rogue changed and added defines
291
292 #define RIT_SHELLS              128
293 #define RIT_NAILS               256
294 #define RIT_ROCKETS             512
295 #define RIT_CELLS               1024
296 #define RIT_AXE                 2048
297 #define RIT_LAVA_NAILGUN        4096
298 #define RIT_LAVA_SUPER_NAILGUN  8192
299 #define RIT_MULTI_GRENADE       16384
300 #define RIT_MULTI_ROCKET        32768
301 #define RIT_PLASMA_GUN          65536
302 #define RIT_ARMOR1              8388608
303 #define RIT_ARMOR2              16777216
304 #define RIT_ARMOR3              33554432
305 #define RIT_LAVA_NAILS          67108864
306 #define RIT_PLASMA_AMMO         134217728
307 #define RIT_MULTI_ROCKETS       268435456
308 #define RIT_SHIELD              536870912
309 #define RIT_ANTIGRAV            1073741824
310 #define RIT_SUPERHEALTH         2147483648
311
312 //MED 01/04/97 added hipnotic defines
313 //===========================================
314 //hipnotic added defines
315 #define HIT_PROXIMITY_GUN_BIT 16
316 #define HIT_MJOLNIR_BIT       7
317 #define HIT_LASER_CANNON_BIT  23
318 #define HIT_PROXIMITY_GUN   (1<<HIT_PROXIMITY_GUN_BIT)
319 #define HIT_MJOLNIR         (1<<HIT_MJOLNIR_BIT)
320 #define HIT_LASER_CANNON    (1<<HIT_LASER_CANNON_BIT)
321 #define HIT_WETSUIT         (1<<(23+2))
322 #define HIT_EMPATHY_SHIELDS (1<<(23+3))
323
324 //===========================================
325
326 #include "zone.h"
327 #include "fs.h"
328 #include "common.h"
329 #include "cvar.h"
330 #include "bspfile.h"
331 #include "sys.h"
332 #include "vid.h"
333 #include "mathlib.h"
334
335 #include "r_textures.h"
336
337 #include "draw.h"
338 #include "screen.h"
339 #include "netconn.h"
340 #include "protocol.h"
341 #include "cmd.h"
342 #include "sbar.h"
343 #include "sound.h"
344 #include "model_shared.h"
345 #include "world.h"
346 #include "client.h"
347 #include "render.h"
348 #include "progs.h"
349 #include "progsvm.h"
350 #include "server.h"
351
352 #include "input.h"
353 #include "keys.h"
354 #include "console.h"
355 #include "menu.h"
356
357 #include "glquake.h"
358
359 #include "palette.h"
360
361 extern qboolean noclip_anglehack;
362
363 extern cvar_t developer;
364 extern cvar_t developer_loadfile;
365 extern cvar_t developer_loading;
366
367 /* Preprocessor macros to identify platform
368     DP_OS_NAME  - "friendly" name of the OS, for humans to read
369     DP_OS_STR   - "identifier" of the OS, more suited for code to use
370     DP_ARCH_STR - "identifier" of the processor architecture
371  */
372 #if defined(__linux__)
373 # define DP_OS_NAME             "Linux"
374 # define DP_OS_STR              "linux"
375 #elif defined(WIN64)
376 # define DP_OS_NAME             "Windows64"
377 # define DP_OS_STR              "win64"
378 #elif defined(WIN32)
379 # define DP_OS_NAME             "Windows"
380 # define DP_OS_STR              "win32"
381 #elif defined(__FreeBSD__)
382 # define DP_OS_NAME             "FreeBSD"
383 # define DP_OS_STR              "freebsd"
384 #elif defined(__NetBSD__)
385 # define DP_OS_NAME             "NetBSD"
386 # define DP_OS_STR              "netbsd"
387 #elif defined(__OpenBSD__)
388 # define DP_OS_NAME             "OpenBSD"
389 # define DP_OS_STR              "openbsd"
390 #elif defined(MACOSX)
391 # define DP_OS_NAME             "Mac OS X"
392 # define DP_OS_STR              "osx"
393 #elif defined(__MORPHOS__)
394 # define DP_OS_NAME             "MorphOS"
395 # define DP_OS_STR              "morphos"
396 #else
397 # define DP_OS_NAME             "Unknown"
398 #endif
399
400 #if defined(__GNUC__)
401 # if defined(__i386__)
402 #  define DP_ARCH_STR           "686"
403 # elif defined(__x86_64__)
404 #  define DP_ARCH_STR           "x86_64"
405 # elif defined(__powerpc__)
406 #  define DP_ARCH_STR           "ppc"
407 # endif
408 #elif defined(WIN64)
409 # define DP_ARCH_STR            "x86_64"
410 #elif defined(WIN32)
411 # define DP_ARCH_STR            "x86"
412 #endif
413
414 /// incremented every frame, never reset
415 extern int host_framecount;
416 /// not bounded in any way, changed at start of every frame, never reset
417 extern double realtime;
418
419 void Host_InitCommands(void);
420 void Host_Main(void);
421 void Host_Shutdown(void);
422 void Host_StartVideo(void);
423 void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1);
424 void Host_Quit_f(void);
425 void Host_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1);
426 void Host_ShutdownServer(void);
427 void Host_Reconnect_f(void);
428 void Host_NoOperation_f(void);
429
430 void Host_AbortCurrentFrame(void);
431
432 /// 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)
433 extern int current_skill;
434
435 //
436 // chase
437 //
438 extern cvar_t chase_active;
439 extern cvar_t cl_viewmodel_scale;
440
441 void Chase_Init (void);
442 void Chase_Reset (void);
443 void Chase_Update (void);
444
445 void fractalnoise(unsigned char *noise, int size, int startgrid);
446 void fractalnoisequick(unsigned char *noise, int size, int startgrid);
447 float noise4f(float x, float y, float z, float w);
448
449 void Sys_Shared_Init(void);
450
451 // Flag in size field of demos to indicate a client->server packet. Demo
452 // playback will ignore this, but it may be useful to make DP sniff packets to
453 // debug protocol exploits.
454 #define DEMOMSG_CLIENT_TO_SERVER 0x80000000
455
456 // In Quake, any char in 0..32 counts as whitespace
457 //#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
458 #define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
459
460 // This also includes extended characters, and ALL control chars
461 #define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
462
463
464 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
465
466 #endif
467