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 //#define	GLTEST			// experimental stuff
23 
24 #define	QUAKE_GAME			// as opposed to utilities
25 
26 #define	VERSION			1.09
27 #define	GLQUAKE_VERSION		1.00
28 #define	D3DQUAKE_VERSION	0.01
29 #define	WINQUAKE_VERSION	0.996
30 #define	LINUX_VERSION		1.30
31 #define	X11_VERSION		1.10
32 #define MACOSX_VERSION		1.00
33 #define STQUAKE_VERSION		1.04
34 
35 //define	PARANOID			// speed sapping error checking
36 
37 #ifdef QUAKE2
38 #define	GAMENAME	"id1"		// directory to look in by default
39 #else
40 #define	GAMENAME	"id1"
41 #endif
42 
43 #include <math.h>
44 #include <string.h>
45 #include <stdarg.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 
49 #if !defined(_SETJMP_H)
50 #include <setjmp.h>
51 #endif
52 
53 #ifndef min
54 #define min(a,b) (a<b?a:b)
55 #endif
56 #ifndef max
57 #define max(a,b) (a>b?a:b)
58 #endif
59 
60 
61 #if defined(_WIN32) && !defined(WINDED)
62 
63 #if defined(_M_IX86)
64 #define __i386__	1
65 #endif
66 
67 void	VID_LockBuffer (void);
68 void	VID_UnlockBuffer (void);
69 
70 #else
71 
72 #define	VID_LockBuffer()
73 #define	VID_UnlockBuffer()
74 
75 #endif
76 
77 #if defined(__i386__) && defined(USE_ASM)
78 #define id386	1
79 #else
80 #define id386	0
81 #endif
82 
83 #if id386
84 #define UNALIGNED_OK	1	// set to 0 if unaligned accesses are not supported
85 #else
86 #define UNALIGNED_OK	0
87 #endif
88 
89 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
90 #define CACHE_SIZE	32		// used to align key data structures
91 
92 #define UNUSED(x)	(x = x)	// for pesky compiler / lint warnings
93 
94 #define	MINIMUM_MEMORY			0x550000
95 #define	MINIMUM_MEMORY_LEVELPAK	(MINIMUM_MEMORY + 0x100000)
96 
97 #define MAX_NUM_ARGVS	50
98 
99 // up / down
100 #define	PITCH	0
101 
102 // left / right
103 #define	YAW		1
104 
105 // fall over
106 #define	ROLL	2
107 
108 
109 #define	MAX_QPATH		64			// max length of a quake game pathname
110 #define	MAX_OSPATH		128			// max length of a filesystem pathname
111 
112 #define	ON_EPSILON		0.1			// point on plane side epsilon
113 
114 #define	MAX_MSGLEN		64000 //Later Packet Overflow
115 #define	MAX_DATAGRAM	16384
116 //#define	MAX_MSGLEN		8000		// max length of a reliable message
117 //#define	MAX_DATAGRAM	1024		// max length of unreliable message
118 
119 //
120 // per-level limits
121 //
122 #define	MAX_EDICTS		2048			// FIXME: ouch! ouch! ouch! ////Upped Limits (once 600)- Eradicator
123 #define	MAX_LIGHTSTYLES	64
124 #define	MAX_MODELS		256			// these are sent over the net as bytes
125 #define	MAX_SOUNDS		256			// so they cannot be blindly increased
126 
127 #define	SAVEGAME_COMMENT_LENGTH	39
128 
129 #define	MAX_STYLESTRING	64
130 
131 //
132 // stats are integers communicated to the client by the server
133 //
134 #define	MAX_CL_STATS		32
135 #define	STAT_HEALTH			0
136 #define	STAT_FRAGS			1
137 #define	STAT_WEAPON			2
138 #define	STAT_AMMO			3
139 #define	STAT_ARMOR			4
140 #define	STAT_WEAPONFRAME	5
141 #define	STAT_SHELLS			6
142 #define	STAT_NAILS			7
143 #define	STAT_ROCKETS		8
144 #define	STAT_CELLS			9
145 #define	STAT_ACTIVEWEAPON	10
146 #define	STAT_TOTALSECRETS	11
147 #define	STAT_TOTALMONSTERS	12
148 #define	STAT_SECRETS		13		// bumped on client side by svc_foundsecret
149 #define	STAT_MONSTERS		14		// bumped by svc_killedmonster
150 
151 // stock defines
152 
153 #define	IT_SHOTGUN				1
154 #define	IT_SUPER_SHOTGUN		2
155 #define	IT_NAILGUN				4
156 #define	IT_SUPER_NAILGUN		8
157 #define	IT_GRENADE_LAUNCHER		16
158 #define	IT_ROCKET_LAUNCHER		32
159 #define	IT_LIGHTNING			64
160 #define IT_SUPER_LIGHTNING      128
161 #define IT_SHELLS               256
162 #define IT_NAILS                512
163 #define IT_ROCKETS              1024
164 #define IT_CELLS                2048
165 #define IT_AXE                  4096
166 #define IT_ARMOR1               8192
167 #define IT_ARMOR2               16384
168 #define IT_ARMOR3               32768
169 #define IT_SUPERHEALTH          65536
170 #define IT_KEY1                 131072
171 #define IT_KEY2                 262144
172 #define	IT_INVISIBILITY			524288
173 #define	IT_INVULNERABILITY		1048576
174 #define	IT_SUIT					2097152
175 #define	IT_QUAD					4194304
176 #define IT_SIGIL1               (1<<28)
177 #define IT_SIGIL2               (1<<29)
178 #define IT_SIGIL3               (1<<30)
179 #define IT_SIGIL4               (1<<31)
180 
181 //===========================================
182 //rogue changed and added defines
183 
184 #define RIT_SHELLS              128
185 #define RIT_NAILS               256
186 #define RIT_ROCKETS             512
187 #define RIT_CELLS               1024
188 #define RIT_AXE                 2048
189 #define RIT_LAVA_NAILGUN        4096
190 #define RIT_LAVA_SUPER_NAILGUN  8192
191 #define RIT_MULTI_GRENADE       16384
192 #define RIT_MULTI_ROCKET        32768
193 #define RIT_PLASMA_GUN          65536
194 #define RIT_ARMOR1              8388608
195 #define RIT_ARMOR2              16777216
196 #define RIT_ARMOR3              33554432
197 #define RIT_LAVA_NAILS          67108864
198 #define RIT_PLASMA_AMMO         134217728
199 #define RIT_MULTI_ROCKETS       268435456
200 #define RIT_SHIELD              536870912
201 #define RIT_ANTIGRAV            1073741824
202 #define RIT_SUPERHEALTH         2147483648
203 
204 //MED 01/04/97 added hipnotic defines
205 //===========================================
206 //hipnotic added defines
207 #define HIT_PROXIMITY_GUN_BIT 16
208 #define HIT_MJOLNIR_BIT       7
209 #define HIT_LASER_CANNON_BIT  23
210 #define HIT_PROXIMITY_GUN   (1<<HIT_PROXIMITY_GUN_BIT)
211 #define HIT_MJOLNIR         (1<<HIT_MJOLNIR_BIT)
212 #define HIT_LASER_CANNON    (1<<HIT_LASER_CANNON_BIT)
213 #define HIT_WETSUIT         (1<<(23+2))
214 #define HIT_EMPATHY_SHIELDS (1<<(23+3))
215 
216 //===========================================
217 
218 #define	MAX_SCOREBOARD		64 //Increased player limit (once 16) - Eradicator
219 #define	MAX_SCOREBOARDNAME	32
220 
221 #define	SOUND_CHANNELS		8
222 
223 // This makes anyone on id's net privileged
224 // Use for multiplayer testing only - VERY dangerous!!!
225 // #define IDGODS
226 
227 #include "common.h"
228 #include "bspfile.h"
229 #include "vid.h"
230 #include "sys.h"
231 #include "zone.h"
232 #include "mathlib.h"
233 
234 typedef struct
235 {
236 	vec3_t	origin;
237 	vec3_t	angles;
238 	int		modelindex;
239 	int		frame;
240 	int		colormap;
241 	int		skin;
242 	int		effects;
243 	//PENTA
244 	vec3_t	color;
245 	float	alpha;
246 	int		style;
247 	int		light_lev;
248 	int		pflags;
249 } entity_state_t;
250 
251 
252 #include "wad.h"
253 #include "draw.h"
254 #include "cvar.h"
255 #include "screen.h"
256 #include "net.h"
257 #include "protocol.h"
258 #include "cmd.h"
259 #include "sbar.h"
260 #include "sound.h"
261 #include "render.h"
262 #include "client.h"
263 #include "progs.h"
264 #include "server.h"
265 
266 #ifdef GLQUAKE
267 #include "gl_model.h"
268 #else
269 #include "model.h"
270 #include "d_iface.h"
271 #endif
272 
273 #include "input.h"
274 #include "world.h"
275 #include "keys.h"
276 #include "console.h"
277 #include "view.h"
278 #include "menu.h"
279 #include "crc.h"
280 #include "cdaudio.h"
281 
282 #ifdef GLQUAKE
283 #include "glquake.h"
284 #endif
285 
286 //=============================================================================
287 
288 // the host system specifies the base of the directory tree, the
289 // command line parms passed to the program, and the amount of memory
290 // available for the program to use
291 
292 typedef struct
293 {
294 	char	*basedir;
295 #if defined (USERPREF_DIR)
296 	char	*userdir;		// - DC - for user pref dir
297 #endif
298 	char	*cachedir;		// for development over ISDN lines
299 	int		argc;
300 	char	**argv;
301 	void	*membase;
302 	int		memsize;
303 } quakeparms_t;
304 
305 
306 //=============================================================================
307 
308 
309 extern qboolean noclip_anglehack;
310 
311 
312 //
313 // host
314 //
315 extern	quakeparms_t host_parms;
316 
317 extern	cvar_t		sys_ticrate;
318 extern	cvar_t		sys_nostdout;
319 extern	cvar_t		developer;
320 
321 extern	qboolean	host_initialized;		// true if into command execution
322 extern	double		host_frametime;
323 extern	byte		*host_basepal;
324 extern	byte		*host_colormap;
325 extern	int			host_framecount;	// incremented every frame, never reset
326 extern	double		realtime;			// not bounded in any way, changed at
327 										// start of every frame, never reset
328 
329 void Host_ClearMemory (void);
330 void Host_ServerFrame (void);
331 void Host_InitCommands (void);
332 void Host_Init (quakeparms_t *parms);
333 void Host_Shutdown(void);
334 void Host_Error (char *error, ...);
335 void Host_EndGame (char *message, ...);
336 void Host_Frame (float time);
337 void Host_Quit_f (void);
338 void Host_ClientCommands (char *fmt, ...);
339 void Host_ShutdownServer (qboolean crash);
340 
341 extern qboolean		msg_suppress_1;		// suppresses resolution and cache size console output
342 										//  an fullscreen DIB focus gain/loss
343 extern int			current_skill;		// skill level for currently loaded level (in case
344 										//  the user changes the cvar while the level is
345 										//  running, this reflects the level actually in use)
346 
347 extern qboolean		isDedicated;
348 
349 extern int			minimum_memory;
350 
351 
352 extern qboolean fullsbardraw;
353 //
354 // chase
355 //
356 extern	cvar_t	chase_active;
357 
358 void Chase_Init (void);
359 void Chase_Reset (void);
360 void Chase_Update (void);
361