1 /*
2 Copyright (C) 1997-2001 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 // client.h -- primary header for client
21 
22 //define	PARANOID			// speed sapping error checking
23 
24 #ifndef _CLIENT_H
25 
26 #define	BUILDING_CLIENT		1
27 #define	DECOUPLED_RENDERER	1
28 
29 //shared by keys/console
30 #define	MAXCMDLINE	512
31 
32 #include <math.h>
33 #include <string.h>
34 #include <stdarg.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 
38 #ifdef USE_CURL
39 #ifdef _WIN32
40 #define CURL_STATICLIB
41 #define CURL_HIDDEN_SYMBOLS
42 #define CURL_EXTERN_SYMBOL
43 #define CURL_CALLING_CONVENTION __cdecl
44 #endif
45 #include <curl/curl.h>
46 #endif
47 
48 #include "ref.h"
49 
50 #include "vid.h"
51 #include "screen.h"
52 #include "sound.h"
53 #include "input.h"
54 #include "keys.h"
55 #include "console.h"
56 #include "cdaudio.h"
57 
58 //=============================================================================
59 
60 typedef struct
61 {
62 	qboolean		valid;			// cleared if delta parsing was invalid
63 	int				serverframe;
64 	int				servertime;		// server time the message is valid for (in msec)
65 	int				deltaframe;
66 	byte			areabits[MAX_MAP_AREAS/8];		// portalarea visibility bits
67 	player_state_t	playerstate;
68 	int				num_entities;
69 	int				parse_entities;	// non-masked index into cl_parse_entities array
70 } frame_t;
71 
72 typedef struct
73 {
74 	entity_state_t	baseline;//[UPDATE_BACKUP];		// delta from this if not from a previous frame
75 	entity_state_t	current;
76 	entity_state_t	prev;			// will always be valid, but might just be a copy of current
77 
78 	int			serverframe;		// if not current, this ent isn't in the frame
79 
80 	int			trailcount;			// for diminishing grenade trails
81 	vec3_t		lerp_origin;		// for trails (variable hz)
82 
83 	int			fly_stoptime;
84 
85 	int			frame_lerp_from;
86 	int			frame_lerp_to;
87 	int			lerp_time;
88 } centity_t;
89 
90 #define MAX_CLIENTWEAPONMODELS		20		// PGM -- upped from 16 to fit the chainfist vwep
91 
92 typedef struct
93 {
94 	char			name[MAX_QPATH];
95 	char			cinfo[MAX_QPATH];
96 	struct image_s	*skin;
97 	struct image_s	*icon;
98 	char			iconname[MAX_QPATH];
99 	struct model_s	*model;
100 	struct model_s	*weaponmodel[MAX_CLIENTWEAPONMODELS];
101 	qboolean		deferred;
102 } clientinfo_t;
103 
104 extern char cl_weaponmodels[MAX_CLIENTWEAPONMODELS][MAX_QPATH];
105 extern int num_cl_weaponmodels;
106 
107 #define	CMD_BACKUP		64	// allow a lot of command backups for very fast systems
108 
109 //r1: localents
110 typedef struct localent_s localent_t;
111 
112 struct localent_s
113 {
114 	//complete entity
115 	entity_t	ent;
116 
117 	char		*classname;
118 
119 	//in use?
120 	qboolean	inuse;
121 
122 	int			movetype;
123 
124 	vec3_t		mins;
125 	vec3_t		maxs;
126 	vec3_t		velocity;
127 
128 	//we want local ents to be able to pseudo-think too (for freeing, effects, et al)
129 	//FIXME BIG HACK OF DOOM:
130 	//local ents run physics from gloom code for thinking, etc.
131 	float		nextthink;
132 	void		(*think)(localent_t *self);
133 	void		(*touch)(localent_t *self, cplane_t *plane, csurface_t *surf);
134 };
135 
136 //yummmm splash gibs death blood
137 #define MAX_LOCAL_ENTS 1024
138 
139 void Le_Reset (void);
140 
141 #ifdef USE_CURL
142 void CL_CancelHTTPDownloads (qboolean permKill);
143 void CL_InitHTTPDownloads (void);
144 qboolean CL_QueueHTTPDownload (const char *quakePath);
145 void CL_RunHTTPDownloads (void);
146 qboolean CL_PendingHTTPDownloads (void);
147 void CL_SetHTTPServer (const char *URL);
148 void CL_HTTP_Cleanup (qboolean fullShutdown);
149 
150 typedef enum
151 {
152 	DLQ_STATE_NOT_STARTED,
153 	DLQ_STATE_RUNNING,
154 	DLQ_STATE_DONE
155 } dlq_state;
156 
157 typedef struct dlqueue_s
158 {
159 	struct dlqueue_s	*next;
160 	char				quakePath[MAX_QPATH];
161 	dlq_state			state;
162 } dlqueue_t;
163 
164 typedef struct dlhandle_s
165 {
166 	CURL		*curl;
167 	char		filePath[MAX_OSPATH];
168 	FILE		*file;
169 	dlqueue_t	*queueEntry;
170 	size_t		fileSize;
171 	size_t		position;
172 	double		speed;
173 	char		URL[576];
174 	char		*tempBuffer;
175 } dlhandle_t;
176 #endif
177 
178 /*typedef struct
179 {
180 	char		name[MAX_QPATH];
181 	int			download_attempted;
182 } configstring_t;*/
183 
184 //
185 // the client_state_t structure is wiped completely at every
186 // server map change
187 //
188 
189 typedef struct client_state_s
190 {
191 	int			timeoutcount;
192 
193 	int			timedemo_frames;
194 	unsigned 	timedemo_start;
195 
196 	qboolean	refresh_prepped;	// false if on new level or new ref dll
197 	qboolean	sound_prepped;		// ambient sounds can start
198 	qboolean	force_refdef;		// vid has changed, so we can't use a paused refdef
199 
200 	int			parse_entities;		// index (not anded off) into cl_parse_entities[]
201 
202 	usercmd_t	cmd;
203 	usercmd_t	cmds[CMD_BACKUP];	// each mesage will send several old cmds
204 	int			cmd_time[CMD_BACKUP];	// time sent, for calculating pings
205 	int16		predicted_origins[CMD_BACKUP][3];	// for debug comparing against server
206 
207 	float		predicted_step;				// for stair up smoothing
208 	unsigned	predicted_step_time;
209 
210 	vec3_t		predicted_origin;	// generated by CL_PredictMovement
211 	vec3_t		predicted_angles;
212 	vec3_t		prediction_error;
213 
214 	frame_t		frame;				// received from server
215 	int			surpressCount;		// number of messages rate supressed
216 	frame_t		frames[UPDATE_BACKUP];
217 
218 	// the client maintains its own idea of view angles, which are
219 	// sent to the server each frame.  It is cleared to 0 upon entering each level.
220 	// the server sends a delta each frame which is added to the locally
221 	// tracked view angles to account for standing on rotating objects,
222 	// and teleport direction changes
223 	vec3_t		viewangles;
224 
225 	int			time;			// this is the time value that the client
226 	int			initial_server_frame;
227 								// is rendering at.  always <= cls.realtime
228 	float		lerpfrac;		// between oldframe and frame
229 
230 	refdef_t	refdef;
231 
232 	vec3_t		v_forward, v_right, v_up;	// set when refdef.angles is set
233 
234 	//
235 	// transient data from server
236 	//
237 	char		layout[1024];		// general 2D overlay
238 	int			inventory[MAX_ITEMS];
239 
240 	//
241 	// non-gameserver infornamtion
242 	// FIXME: move this cinematic stuff into the cin_t structure
243 #ifdef CINEMATICS
244 	FILE		*cinematic_file;
245 	int			cinematictime;		// cls.realtime for first cinematic frame
246 	int			cinematicframe;
247 	char		cinematicpalette[768];
248 	qboolean	cinematicpalette_active;
249 #endif
250 
251 	//
252 	// server state information
253 	//
254 	qboolean	attractloop;		// running the attract loop, any key will menu
255 	int			servercount;	// server identification for prespawns
256 	char		gamedir[MAX_QPATH];
257 	int			playernum;
258 	int			maxclients;
259 
260 	char		configstrings[MAX_CONFIGSTRINGS][MAX_QPATH];
261 
262 	//
263 	// locally derived information from server state
264 	//
265 	struct model_s	*model_draw[MAX_MODELS];
266 	struct cmodel_s	*model_clip[MAX_MODELS];
267 
268 	struct sfx_s	*sound_precache[MAX_SOUNDS];
269 	//struct image_s	*image_precache[MAX_IMAGES];
270 
271 	clientinfo_t	clientinfo[MAX_CLIENTS];
272 	clientinfo_t	baseclientinfo;
273 
274 	qboolean		enhancedServer;
275 	qboolean		strafeHack;
276 
277 	//r1: defer rendering when realtime < this
278 	uint32			defer_rendering;
279 
280 	byte			demoFrame[1400];
281 	sizebuf_t		demoBuff;
282 	frame_t			*demoLastFrame;
283 
284 	unsigned		settings[SVSET_MAX];
285 	int				player_update_time;
286 	float			playerlerp;
287 	float			modelfrac;
288 
289 	//variable FPS support variables
290 	int				gunlerp_start, gunlerp_end, gunlerp_frame_from, gunlerp_frame_to;
291 
292 	int				kicklerp_end;
293 	vec3_t			kicklerp_from, kicklerp_to;
294 } client_state_t;
295 
296 extern	client_state_t	cl;
297 
298 /*
299 ==================================================================
300 
301 the client_static_t structure is persistant through an arbitrary number
302 of server connections
303 
304 ==================================================================
305 */
306 
307 typedef enum {
308 	ca_uninitialized,
309 	ca_disconnected, 	// not talking to a server
310 	ca_connecting,		// sending request packets to the server
311 	ca_connected,		// netchan_t established, waiting for svc_serverdata
312 	ca_active			// game views should be displayed
313 } connstate_t;
314 
315 /*typedef enum {
316 	dl_none,
317 	dl_model,
318 	dl_sound,
319 	dl_skin,
320 	dl_single
321 } dltype_t;		// download type*/
322 
323 typedef enum {
324 	ps_none,
325 	ps_pending,
326 	ps_active
327 } proxystate_t;
328 
329 typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
330 
331 typedef struct client_static_s
332 {
333 	connstate_t	state;
334 	keydest_t	key_dest;
335 
336 	//unsigned int	framecount;
337 	uint32			lastSpamTime;
338 	uint32			spamTime;
339 	uint32			realtime;			// always increasing, no clamping, etc
340 	float			frametime;			// seconds since last frame
341 
342 // screen rendering information
343 	uint32			disable_screen;		// showing loading plaque between levels
344 									// or changing rendering dlls
345 									// if time gets > 30 seconds ahead, break it
346 	int				disable_servercount;	// when we receive a frame and cl.servercount
347 									// > cls.disable_servercount, clear disable_screen
348 
349 // connection information
350 	char			servername[MAX_OSPATH];	// name of server from original connect
351 	char			lastservername[MAX_OSPATH];	// name of server from original connect
352 	int				connect_time;		// for connection retransmits
353 
354 	int			quakePort;			// a 16 bit value that allows quake servers
355 									// to work around address translating routers
356 	netchan_t	netchan;
357 	int			serverProtocol;		// in case we are doing some kind of version hack
358 
359 	int			challenge;			// from the server to use for connecting
360 
361 	FILE		*download;			// file transfer from server
362 	char		downloadtempname[MAX_OSPATH];
363 	char		downloadname[MAX_OSPATH];
364 	qboolean	downloadpending;
365 	qboolean	failed_download;
366 	//dltype_t	downloadtype;
367 	int			downloadsize;
368 	size_t		downloadposition;
369 	int			downloadpercent;
370 
371 // demo recording info must be here, so it isn't cleared on level change
372 	qboolean	demorecording;
373 	qboolean	demowaiting;	// don't record until a non-delta message is received
374 	qboolean	passivemode;
375 	FILE		*demofile;
376 
377 	int			protocolVersion;	// R1Q2 protocol version
378 
379 #ifdef USE_CURL
380 	dlqueue_t		downloadQueue;			//queue of paths we need
381 
382 	dlhandle_t		HTTPHandles[4];			//actual download handles
383 	//don't raise this!
384 	//i use a hardcoded maximum of 4 simultaneous connections to avoid
385 	//overloading the server. i'm all too familiar with assholes who set
386 	//their IE or Firefox max connections to 16 and rape my Apache processes
387 	//every time they load a page... i'd rather not have my q2 client also
388 	//have the ability to do so - especially since we're possibly downloading
389 	//large files.
390 
391 	char			downloadServer[512];	//base url prefix to download from
392 	char			downloadReferer[32];	//libcurl requires a static string :(
393 #endif
394 
395 	char			followHost[32];
396 	proxystate_t	proxyState;
397 	netadr_t		proxyAddr;
398 } client_static_t;
399 
400 extern client_static_t	cls;
401 
402 //=============================================================================
403 
404 //
405 // cvars
406 //
407 #ifdef CL_STEREO_SUPPORT
408 extern	cvar_t	*cl_stereo_separation;
409 extern	cvar_t	*cl_stereo;
410 #endif
411 
412 extern	cvar_t	*cl_gun;
413 extern	cvar_t	*cl_add_blend;
414 extern	cvar_t	*cl_add_lights;
415 extern	cvar_t	*cl_add_particles;
416 extern	cvar_t	*cl_add_entities;
417 extern	cvar_t	*cl_predict;
418 extern	cvar_t	*cl_backlerp;
419 extern	cvar_t	*cl_footsteps;
420 extern	cvar_t	*cl_smoothsteps;
421 extern	cvar_t	*cl_noskins;
422 //extern	cvar_t	*cl_autoskins;
423 
424 extern	cvar_t	*cl_upspeed;
425 extern	cvar_t	*cl_forwardspeed;
426 extern	cvar_t	*cl_sidespeed;
427 
428 extern	cvar_t	*cl_yawspeed;
429 extern	cvar_t	*cl_pitchspeed;
430 
431 extern	cvar_t	*cl_run;
432 
433 extern	cvar_t	*cl_anglespeedkey;
434 
435 extern	cvar_t	*cl_shownet;
436 extern	cvar_t	*cl_showmiss;
437 extern	cvar_t	*cl_showclamp;
438 
439 extern	cvar_t	*cl_filterchat;
440 
441 extern	cvar_t	*lookspring;
442 extern	cvar_t	*lookstrafe;
443 extern	cvar_t	*sensitivity;
444 
445 extern	cvar_t	*m_pitch;
446 extern	cvar_t	*m_yaw;
447 extern	cvar_t	*m_forward;
448 extern	cvar_t	*m_side;
449 
450 extern	cvar_t	*freelook;
451 
452 extern	cvar_t	*cl_lightlevel;	// FIXME HACK
453 
454 extern	cvar_t	*cl_paused;
455 extern	cvar_t	*cl_timedemo;
456 
457 extern	cvar_t	*cl_vwep;
458 
459 //extern	cvar_t	*cl_defertimer;
460 
461 extern	cvar_t	*scr_sizegraph;
462 extern	cvar_t	*fs_gamedirvar;
463 
464 extern	cvar_t	*cl_nolerp;
465 //extern	cvar_t	*cl_snaps;
466 
467 extern	cvar_t	*cl_railtrail;
468 extern	cvar_t	*cl_async;
469 
470 extern	cvar_t	*cl_protocol;
471 extern	cvar_t	*cl_test;
472 extern	cvar_t	*cl_test2;
473 extern	cvar_t	*cl_test3;
474 
475 #ifdef USE_CURL
476 extern	cvar_t	*cl_http_downloads;
477 extern	cvar_t	*cl_http_filelists;
478 extern	cvar_t	*cl_http_proxy;
479 extern	cvar_t	*cl_http_max_connections;
480 #endif
481 
482 extern	cvar_t	*cl_original_dlights;
483 extern	cvar_t	*cl_default_location;
484 extern	cvar_t	*cl_player_updates;
485 
486 extern	cvar_t	*fov;
487 
488 extern	cvar_t	*vid_fullscreen;
489 
490 extern	cvar_t	*cl_quietstartup;
491 
492 #ifndef DEDICATED_ONLY
493 extern	qboolean send_packet_now;
494 #endif
495 
496 typedef struct
497 {
498 	int			entity;				// so entities can reuse same entry
499 	int			die;				// stop lighting after this time
500 
501 	qboolean	follow;			// r1: follow entity
502 
503 	vec3_t		color;
504 	vec3_t		origin;
505 
506 	float		radius;
507 	//float	minlight;			// don't add when contributing less
508 } cdlight_t;
509 
510 extern	centity_t	cl_entities[MAX_EDICTS];
511 extern	cdlight_t	cl_dlights[MAX_DLIGHTS];
512 
513 // the cl_parse_entities must be large enough to hold UPDATE_BACKUP frames of
514 // entities, so that when a delta compressed message arives from the server
515 // it can be un-deltad from the original
516 #define	MAX_PARSE_ENTITIES	1024
517 extern	entity_state_t	cl_parse_entities[MAX_PARSE_ENTITIES];
518 
519 //=============================================================================
520 
521 extern	qboolean os_winxp;
522 
523 extern	netadr_t	net_from;
524 extern	sizebuf_t	net_message;
525 
526 void DrawString (int x, int y, const char *s);
527 void DrawAltString (int x, int y, const char *s);	// toggle high bit
528 qboolean	CL_CheckOrDownloadFile (const char *filename);
529 
530 void CL_AddNetgraph (void);
531 void CL_AddSizegraph (void);
532 
533 //ROGUE
534 typedef struct cl_sustain
535 {
536 	int			id;
537 	int			type;
538 	int			endtime;
539 	int			nextthink;
540 	int			thinkinterval;
541 	vec3_t		org;
542 	vec3_t		dir;
543 	int			color;
544 	int			count;
545 	int			magnitude;
546 	void		(*think)(struct cl_sustain *self);
547 } cl_sustain_t;
548 
549 #define MAX_SUSTAINS		32
550 void CL_ParticleSteamEffect2(cl_sustain_t *self);
551 
552 void CL_TeleporterParticles (entity_state_t *ent);
553 void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count);
554 void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count);
555 
556 // RAFAEL
557 void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count);
558 
559 
560 qboolean CL_IgnoreMatch (const char *string);
561 
562 //=================================================
563 
564 // ========
565 // PGM
566 typedef struct particle_s
567 {
568 	struct particle_s	*next;
569 
570 	int			type;
571 	int			color;
572 
573 	vec3_t		org;
574 	vec3_t		vel;
575 	vec3_t		accel;
576 
577 	//float		colorvel;
578 	float		time;
579 	float		alpha;
580 	float		alphavel;
581 } cparticle_t;
582 
583 
584 #define	PARTICLE_GRAVITY	40
585 #define BLASTER_PARTICLE_COLOR		0xe0
586 // PMM
587 #define PT_NONE		0
588 #define PT_INSTANT	1
589 // PGM
590 // ========
591 
592 void CL_ClearEffects (void);
593 void CL_ClearTEnts (void);
594 void CL_BlasterTrail (vec3_t start, vec3_t end);
595 void CL_QuadTrail (vec3_t start, vec3_t end);
596 void CL_RailTrail (vec3_t start, vec3_t end, byte clr);
597 void CL_BubbleTrail (vec3_t start, vec3_t end);
598 void CL_FlagTrail (vec3_t start, vec3_t end, int color);
599 
600 // RAFAEL
601 void CL_IonripperTrail (vec3_t start, vec3_t end);
602 
603 // ========
604 // PGM
605 void CL_BlasterParticles2 (vec3_t org, vec3_t dir, uint32 color);
606 void CL_BlasterTrail2 (vec3_t start, vec3_t end);
607 void CL_DebugTrail (vec3_t start, vec3_t end);
608 void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int spacing);
609 void CL_Flashlight (int ent, vec3_t pos);
610 void CL_ForceWall (vec3_t start, vec3_t end, int color);
611 //void CL_FlameEffects (vec3_t origin);
612 void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int numcolors, int dirspread, float alphavel);
613 void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist);
614 void CL_Heatbeam (vec3_t start, vec3_t end);
615 void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
616 void CL_TrackerTrail (vec3_t start, vec3_t end, int particleColor);
617 void CL_Tracker_Explode(vec3_t origin);
618 void CL_TagTrail (vec3_t start, vec3_t end, int color);
619 void CL_ColorFlash (vec3_t pos, int ent, float intensity, float r, float g, float b);
620 void CL_Tracker_Shell(vec3_t origin);
621 void CL_MonsterPlasma_Shell(vec3_t origin);
622 void CL_ColorExplosionParticles (vec3_t org, int color, int run);
623 void CL_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
624 void CL_Widowbeamout (cl_sustain_t *self);
625 void CL_Nukeblast (cl_sustain_t *self);
626 void CL_WidowSplash (vec3_t org);
627 // PGM
628 // ========
629 
630 //r1ch:localents
631 localent_t *Le_Alloc (void);
632 void Le_Free (localent_t *lent);
633 
634 int CL_ParseEntityBits (uint32 *bits);
635 void CL_ParseDelta (const entity_state_t *from, entity_state_t *to, int number, int bits);
636 void CL_ParseFrame (int extrabits);
637 
638 void CL_ParseTEnt (void);
639 void CL_ParseConfigString (void);
640 void CL_ParseMuzzleFlash (void);
641 void CL_ParseMuzzleFlash2 (void);
642 void SmokeAndFlash(vec3_t origin);
643 
644 void CL_SetLightstyle (int i);
645 
646 //void CL_RunParticles (void);
647 void CL_RunDLights (void);
648 void CL_RunLightStyles (void);
649 
650 void CL_AddEntities (void);
651 void CL_AddDLights (void);
652 void CL_AddTEnts (void);
653 void CL_AddLightStyles (void);
654 
655 //=================================================
656 
657 void CL_PrepRefresh (void);
658 void CL_RegisterSounds (void);
659 
660 NORETURN void CL_Quit_f (void);
661 
662 void IN_Accumulate (void);
663 
664 void VID_ReloadRefresh (void);
665 
666 //void CL_ParseLayout (void);
667 
668 
669 //
670 // cl_main
671 //
672 extern	refexport_t	re;		// interface to refresh .dll
673 
674 void CL_Init (void);
675 
676 void CL_FixUpGender(void);
677 void CL_Disconnect (qboolean skipdisconnect);
678 void CL_Disconnect_f (void);
679 void CL_GetChallengePacket (void);
680 void CL_PingServers_f (void);
681 void CL_Snd_Restart_f (void);
682 void CL_RequestNextDownload (void);
683 
684 #ifdef CLIENT_DLL
685 void CL_ClDLL_Restart_f (void);
686 #endif
687 
688 //
689 // cl_input
690 //
691 typedef struct
692 {
693 	int32	down[2];		// key nums holding it down
694 	uint32	downtime;		// msec timestamp
695 	uint32	msec;			// msec down this frame
696 	int32	state;
697 } kbutton_t;
698 
699 extern	kbutton_t	in_mlook, in_klook;
700 extern 	kbutton_t 	in_strafe;
701 extern 	kbutton_t 	in_speed;
702 
703 void CL_InitInput (void);
704 void CL_SendCmd (void);
705 void CL_SendCmd_Synchronous (void);
706 void CL_SendMove (usercmd_t *cmd);
707 
708 void CL_ClearState (void);
709 
710 void CL_ReadPackets (void);
711 
712 int  CL_ReadFromServer (void);
713 void CL_WriteToServer (usercmd_t *cmd);
714 void CL_BaseMove (usercmd_t *cmd);
715 
716 void IN_CenterView (void);
717 
718 float CL_KeyState (kbutton_t *key);
719 char *Key_KeynumToString (int keynum);
720 
721 //
722 // cl_demo.c
723 //
724 void CL_WriteFullDemoMessage (void);
725 void CL_WriteDemoMessage (byte *buff, int len, qboolean forceFlush);
726 void CL_Stop_f (void);
727 void CL_Record_f (void);
728 
729 //
730 // cl_parse.c
731 //
732 extern	int	serverPacketCount;
733 extern	int noFrameFromServerPacket;
734 
735 qboolean CL_ParseServerMessage (void);
736 void CL_LoadClientinfo (clientinfo_t *ci, char *s);
737 void SHOWNET(const char *s);
738 void CL_ParseClientinfo (int player);
739 void CL_Download_f (void);
740 void CL_Passive_f (void);
741 void CL_ParsePlayerUpdate (void);
742 //
743 // cl_view.c
744 //
745 extern	int			gun_frame;
746 extern	struct model_s	*gun_model;
747 
748 void V_Init (void);
749 #ifdef CL_STEREO_SUPPORT
750 void V_RenderView( float stereo_separation );
751 #else
752 void V_RenderView( void );
753 #endif
754 void V_AddEntity (entity_t *ent);
755 void V_AddParticle (vec3_t org, unsigned color, float alpha);
756 void V_AddLight (vec3_t org, float intensity, float r, float g, float b);
757 void V_AddLightStyle (int style, float r, float g, float b);
758 
759 void IN_DeactivateMouse (void);
760 
761 //
762 // cl_tent.c
763 //
764 void CL_RegisterTEntSounds (void);
765 void CL_RegisterTEntModels (void);
766 void CL_SmokeAndFlash(vec3_t origin);
767 
768 
769 //
770 // cl_pred.c
771 //
772 void CL_InitPrediction (void);
773 void CL_PredictMove (void);
774 void CL_CheckPredictionError (void);
775 
776 //
777 // cl_fx.c
778 //
779 cdlight_t *CL_AllocDlight (int entity, qboolean follow);
780 void CL_BigTeleportParticles (vec3_t org);
781 void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old);
782 void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags);
783 void CL_FlyEffect (centity_t *ent, vec3_t origin);
784 void CL_BfgParticles (entity_t *ent);
785 void CL_AddParticles (void);
786 void CL_EntityEvent (entity_state_t *ent);
787 // RAFAEL
788 void CL_TrapParticles (entity_t *ent);
789 
790 //
791 // menus
792 //
793 void M_Init (void);
794 void M_Keydown (int key);
795 void M_Draw (void);
796 void M_Menu_Main_f (void);
797 void M_ForceMenuOff (void);
798 void M_AddToServerList (netadr_t adr, char *info);
799 
800 //
801 // cl_inv.c
802 //
803 void CL_ParseInventory (void);
804 void CL_KeyInventory (int key);
805 void CL_DrawInventory (void);
806 
807 void IN_Restart_f (void);
808 
809 //
810 // cl_pred.c
811 //
812 void CL_PredictMovement (void);
813 
814 void CL_FixCvarCheats (void);
815 
816 #ifdef CLIENT_DLL
817 typedef struct
818 {
819 	// if api_version is different, the dll cannot be used
820 	int		api_version;
821 
822 	// called when the library is loaded
823 	int		(IMPORT *Init) ( void *hinstance );
824 
825 	// called before the library is unloaded
826 	void	(IMPORT *Shutdown) (void);
827 
828 	// exported functions
829 	qboolean	(IMPORT *CLParseTempEnt) (int type);
830 } clexport_t;
831 
832 
833 typedef struct
834 {
835 	//network reading functions
836 	int		(EXPORT *MSG_ReadChar) (sizebuf_t *sb);
837 	int		(EXPORT *MSG_ReadByte) (sizebuf_t *sb);
838 	int		(EXPORT *MSG_ReadShort) (sizebuf_t *sb);
839 	int		(EXPORT *MSG_ReadLong) (sizebuf_t *sb);
840 	float	(EXPORT *MSG_ReadFloat) (sizebuf_t *sb);
841 	char	*(EXPORT *MSG_ReadString) (sizebuf_t *sb);
842 	char	*(EXPORT *MSG_ReadStringLine) (sizebuf_t *sb);
843 
844 	float	(EXPORT *MSG_ReadCoord) (sizebuf_t *sb);
845 	void	(EXPORT *MSG_ReadPos) (sizebuf_t *sb, vec3_t pos);
846 	float	(EXPORT *MSG_ReadAngle) (sizebuf_t *sb);
847 	float	(EXPORT *MSG_ReadAngle16) (sizebuf_t *sb);
848 
849 	void	(EXPORT *MSG_ReadDir) (sizebuf_t *sb, vec3_t vector);
850 	void	(EXPORT *MSG_ReadData) (sizebuf_t *sb, void *buffer, int size);
851 
852 	void	(EXPORT *Cmd_AddCommand) (const char *name, void(*cmd)(void));
853 	void	(EXPORT *Cmd_RemoveCommand) (const char *name);
854 
855 	int		(EXPORT *Cmd_Argc) (void);
856 	char	*(EXPORT *Cmd_Argv) (int i);
857 
858 	void	(EXPORT *Cmd_ExecuteText) (int exec_when, char *text);
859 
860 	void	(EXPORT *Com_Error) (int err_level, const char *str, ...);
861 	void	(EXPORT *Com_Printf) (const char *str, ...);
862 
863 	// files will be memory mapped read only
864 	// the returned buffer may be part of a larger pak file,
865 	// or a discrete file from anywhere in the quake search path
866 	// a -1 return means the file does not exist
867 	// NULL can be passed for buf to just determine existance
868 	int		(EXPORT *FS_LoadFile) (const char *name, void **buf);
869 	void	(EXPORT *FS_FreeFile) (void *buf);
870 
871 	// gamedir will be the current directory that generated
872 	// files should be stored to, ie: "f:\quake\id1"
873 	char	*(EXPORT *FS_Gamedir) (void);
874 
875 	cvar_t	*(EXPORT *Cvar_Get) (const char *name, const char *value, int flags);
876 	cvar_t	*(EXPORT *Cvar_Set)( const char *name, const char *value );
877 	void	 (EXPORT *Cvar_SetValue)( const char *name, float value );
878 
879 	// memory management
880 	void	*(EXPORT *Z_Alloc) (int size);
881 	void	(EXPORT *Z_Free) (void *buf);
882 } climport_t;
883 
884 
885 // this is the only function actually exported at the linker level
886 typedef	clexport_t	(EXPORT *GetClAPI_t) (climport_t);
887 
888 extern	clexport_t ce;
889 extern	qboolean cllib_active;
890 #endif
891 
892 #define _CLIENT_H
893 
894 #endif
895