|
|
1.1 root 1: // client.h -- primary header for client
1.1.1.2 root 2:
1.1 root 3: //define PARANOID // speed sapping error checking
1.1.1.2 root 4:
1.1 root 5: #include <math.h>
6: #include <string.h>
7: #include <stdarg.h>
8: #include <stdio.h>
9: #include <stdlib.h>
1.1.1.2 root 10:
1.1 root 11: #include "ref.h"
1.1.1.2 root 12:
1.1 root 13: #include "vid.h"
14: #include "screen.h"
15: #include "sound.h"
16: #include "input.h"
17: #include "keys.h"
18: #include "console.h"
19: #include "cdaudio.h"
1.1.1.2 root 20:
1.1 root 21: //=============================================================================
1.1.1.2 root 22:
1.1 root 23: typedef struct
24: {
25: qboolean valid; // cleared if delta parsing was invalid
26: int serverframe;
27: int servertime; // server time the message is valid for (in msec)
28: int deltaframe;
29: byte areabits[MAX_MAP_AREAS/8]; // portalarea visibility bits
30: player_state_t playerstate;
31: int num_entities;
32: int parse_entities; // non-masked index into cl_parse_entities array
33: } frame_t;
1.1.1.2 root 34:
1.1 root 35: typedef struct
36: {
37: entity_state_t baseline; // delta from this if not from a previous frame
38: entity_state_t current;
39: entity_state_t prev; // will always be valid, but might just be a copy of current
1.1.1.2 root 40:
1.1 root 41: int serverframe; // if not current, this ent isn't in the frame
42:
43: int trailcount; // for diminishing grenade trails
44: vec3_t lerp_origin; // for trails (variable hz)
45:
46: int fly_stoptime;
47: } centity_t;
48:
1.1.1.3 ! root 49: #define MAX_CLIENTWEAPONMODELS 20 // PGM -- upped from 16 to fit the chainfist vwep
1.1 root 50:
51: typedef struct
52: {
53: char name[MAX_QPATH];
1.1.1.2 root 54: char cinfo[MAX_QPATH];
1.1 root 55: struct image_s *skin;
56: struct image_s *icon;
57: char iconname[MAX_QPATH];
58: struct model_s *model;
1.1.1.2 root 59: struct model_s *weaponmodel[MAX_CLIENTWEAPONMODELS];
1.1 root 60: } clientinfo_t;
61:
1.1.1.2 root 62: extern char cl_weaponmodels[MAX_CLIENTWEAPONMODELS][MAX_QPATH];
63: extern int num_cl_weaponmodels;
64:
1.1 root 65: #define CMD_BACKUP 64 // allow a lot of command backups for very fast systems
1.1.1.2 root 66:
1.1 root 67: //
68: // the client_state_t structure is wiped completely at every
69: // server map change
70: //
71: typedef struct
72: {
73: int timeoutcount;
1.1.1.2 root 74:
1.1 root 75: int timedemo_frames;
76: int timedemo_start;
1.1.1.2 root 77:
1.1 root 78: qboolean refresh_prepped; // false if on new level or new ref dll
79: qboolean sound_prepped; // ambient sounds can start
80: qboolean force_refdef; // vid has changed, so we can't use a paused refdef
1.1.1.2 root 81:
1.1 root 82: int parse_entities; // index (not anded off) into cl_parse_entities[]
1.1.1.2 root 83:
1.1 root 84: usercmd_t cmd;
85: usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds
86: int cmd_time[CMD_BACKUP]; // time sent, for calculating pings
87: short predicted_origins[CMD_BACKUP][3]; // for debug comparing against server
88:
89: float predicted_step; // for stair up smoothing
90: unsigned predicted_step_time;
91:
92: vec3_t predicted_origin; // generated by CL_PredictMovement
93: vec3_t predicted_angles;
94: vec3_t prediction_error;
1.1.1.2 root 95:
1.1 root 96: frame_t frame; // received from server
97: int surpressCount; // number of messages rate supressed
98: frame_t frames[UPDATE_BACKUP];
1.1.1.2 root 99:
1.1 root 100: // the client maintains its own idea of view angles, which are
101: // sent to the server each frame. It is cleared to 0 upon entering each level.
102: // the server sends a delta each frame which is added to the locally
103: // tracked view angles to account for standing on rotating objects,
104: // and teleport direction changes
105: vec3_t viewangles;
1.1.1.2 root 106:
1.1 root 107: int time; // this is the time value that the client
1.1.1.2 root 108: // is rendering at. always <= cls.realtime
1.1 root 109: float lerpfrac; // between oldframe and frame
1.1.1.2 root 110:
1.1 root 111: refdef_t refdef;
1.1.1.2 root 112:
1.1 root 113: vec3_t v_forward, v_right, v_up; // set when refdef.angles is set
1.1.1.2 root 114:
1.1 root 115: //
116: // transient data from server
117: //
118: char layout[1024]; // general 2D overlay
119: int inventory[MAX_ITEMS];
1.1.1.2 root 120:
1.1 root 121: //
122: // non-gameserver infornamtion
123: // FIXME: move this cinematic stuff into the cin_t structure
124: FILE *cinematic_file;
125: int cinematictime; // cls.realtime for first cinematic frame
126: int cinematicframe;
127: char cinematicpalette[768];
128: qboolean cinematicpalette_active;
1.1.1.2 root 129:
1.1 root 130: //
131: // server state information
132: //
133: qboolean attractloop; // running the attract loop, any key will menu
134: int servercount; // server identification for prespawns
135: char gamedir[MAX_QPATH];
136: int playernum;
1.1.1.2 root 137:
1.1 root 138: char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH];
1.1.1.2 root 139:
1.1 root 140: //
141: // locally derived information from server state
142: //
143: struct model_s *model_draw[MAX_MODELS];
144: struct cmodel_s *model_clip[MAX_MODELS];
1.1.1.2 root 145:
1.1 root 146: struct sfx_s *sound_precache[MAX_SOUNDS];
147: struct image_s *image_precache[MAX_IMAGES];
148:
149: clientinfo_t clientinfo[MAX_CLIENTS];
150: clientinfo_t baseclientinfo;
151: } client_state_t;
1.1.1.2 root 152:
1.1 root 153: extern client_state_t cl;
1.1.1.2 root 154:
1.1 root 155: /*
156: ==================================================================
1.1.1.2 root 157:
1.1 root 158: the client_static_t structure is persistant through an arbitrary number
159: of server connections
1.1.1.2 root 160:
1.1 root 161: ==================================================================
162: */
1.1.1.2 root 163:
1.1 root 164: typedef enum {
165: ca_uninitialized,
166: ca_disconnected, // not talking to a server
167: ca_connecting, // sending request packets to the server
168: ca_connected, // netchan_t established, waiting for svc_serverdata
169: ca_active // game views should be displayed
170: } connstate_t;
1.1.1.2 root 171:
1.1 root 172: typedef enum {
173: dl_none,
174: dl_model,
175: dl_sound,
176: dl_skin,
177: dl_single
178: } dltype_t; // download type
1.1.1.2 root 179:
1.1 root 180: typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
1.1.1.2 root 181:
1.1 root 182: typedef struct
183: {
184: connstate_t state;
185: keydest_t key_dest;
1.1.1.2 root 186:
1.1 root 187: int framecount;
1.1.1.2 root 188: int realtime; // always increasing, no clamping, etc
1.1 root 189: float frametime; // seconds since last frame
1.1.1.2 root 190:
1.1 root 191: // screen rendering information
192: float disable_screen; // showing loading plaque between levels
193: // or changing rendering dlls
194: // if time gets > 30 seconds ahead, break it
195: int disable_servercount; // when we receive a frame and cl.servercount
196: // > cls.disable_servercount, clear disable_screen
1.1.1.2 root 197:
1.1 root 198: // connection information
199: char servername[MAX_OSPATH]; // name of server from original connect
200: float connect_time; // for connection retransmits
201:
202: int quakePort; // a 16 bit value that allows quake servers
203: // to work around address translating routers
204: netchan_t netchan;
205: int serverProtocol; // in case we are doing some kind of version hack
206:
207: int challenge; // from the server to use for connecting
1.1.1.2 root 208:
1.1 root 209: FILE *download; // file transfer from server
210: char downloadtempname[MAX_OSPATH];
211: char downloadname[MAX_OSPATH];
212: int downloadnumber;
213: dltype_t downloadtype;
214: int downloadpercent;
1.1.1.2 root 215:
1.1 root 216: // demo recording info must be here, so it isn't cleared on level change
217: qboolean demorecording;
218: qboolean demowaiting; // don't record until a non-delta message is received
219: FILE *demofile;
220: } client_static_t;
1.1.1.2 root 221:
1.1 root 222: extern client_static_t cls;
1.1.1.2 root 223:
1.1 root 224: //=============================================================================
1.1.1.2 root 225:
1.1 root 226: //
227: // cvars
228: //
229: extern cvar_t *cl_stereo_separation;
230: extern cvar_t *cl_stereo;
231:
232: extern cvar_t *cl_gun;
233: extern cvar_t *cl_add_blend;
234: extern cvar_t *cl_add_lights;
235: extern cvar_t *cl_add_particles;
236: extern cvar_t *cl_add_entities;
237: extern cvar_t *cl_predict;
238: extern cvar_t *cl_footsteps;
239: extern cvar_t *cl_noskins;
240: extern cvar_t *cl_autoskins;
1.1.1.2 root 241:
1.1 root 242: extern cvar_t *cl_upspeed;
243: extern cvar_t *cl_forwardspeed;
244: extern cvar_t *cl_sidespeed;
1.1.1.2 root 245:
1.1 root 246: extern cvar_t *cl_yawspeed;
247: extern cvar_t *cl_pitchspeed;
248:
249: extern cvar_t *cl_run;
1.1.1.2 root 250:
1.1 root 251: extern cvar_t *cl_anglespeedkey;
1.1.1.2 root 252:
1.1 root 253: extern cvar_t *cl_shownet;
254: extern cvar_t *cl_showmiss;
255: extern cvar_t *cl_showclamp;
1.1.1.2 root 256:
1.1 root 257: extern cvar_t *lookspring;
258: extern cvar_t *lookstrafe;
259: extern cvar_t *sensitivity;
1.1.1.2 root 260:
1.1 root 261: extern cvar_t *m_pitch;
262: extern cvar_t *m_yaw;
263: extern cvar_t *m_forward;
264: extern cvar_t *m_side;
1.1.1.2 root 265:
1.1 root 266: extern cvar_t *freelook;
1.1.1.2 root 267:
1.1 root 268: extern cvar_t *cl_lightlevel; // FIXME HACK
1.1.1.2 root 269:
1.1 root 270: extern cvar_t *cl_paused;
271: extern cvar_t *cl_timedemo;
1.1.1.2 root 272:
273: extern cvar_t *cl_vwep;
274:
1.1 root 275: typedef struct
276: {
277: int key; // so entities can reuse same entry
278: vec3_t color;
279: vec3_t origin;
280: float radius;
281: float die; // stop lighting after this time
282: float decay; // drop this each second
283: float minlight; // don't add when contributing less
284: } cdlight_t;
1.1.1.2 root 285:
1.1 root 286: extern centity_t cl_entities[MAX_EDICTS];
287: extern cdlight_t cl_dlights[MAX_DLIGHTS];
288:
289: // the cl_parse_entities must be large enough to hold UPDATE_BACKUP frames of
290: // entities, so that when a delta compressed message arives from the server
291: // it can be un-deltad from the original
292: #define MAX_PARSE_ENTITIES 1024
293: extern entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES];
1.1.1.2 root 294:
1.1 root 295: //=============================================================================
1.1.1.2 root 296:
1.1 root 297: extern netadr_t net_from;
298: extern sizebuf_t net_message;
1.1.1.2 root 299:
1.1 root 300: void DrawString (int x, int y, char *s);
301: void DrawAltString (int x, int y, char *s); // toggle high bit
302: qboolean CL_CheckOrDownloadFile (char *filename);
303:
304: void CL_AddNetgraph (void);
1.1.1.2 root 305:
1.1.1.3 ! root 306: //ROGUE
! 307: typedef struct cl_sustain
! 308: {
! 309: int id;
! 310: int type;
! 311: int endtime;
! 312: int nextthink;
! 313: int thinkinterval;
! 314: vec3_t org;
! 315: vec3_t dir;
! 316: int color;
! 317: int count;
! 318: int magnitude;
! 319: void (*think)(struct cl_sustain *self);
! 320: } cl_sustain_t;
! 321:
! 322: #define MAX_SUSTAINS 32
! 323: void CL_ParticleSteamEffect2(cl_sustain_t *self);
! 324:
1.1 root 325: void CL_TeleporterParticles (entity_state_t *ent);
326: void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count);
327: void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count);
1.1.1.2 root 328:
329: // RAFAEL
330: void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count);
331:
332:
1.1 root 333: //=================================================
1.1.1.2 root 334:
1.1.1.3 ! root 335: // ========
! 336: // PGM
! 337: typedef struct particle_s
! 338: {
! 339: struct particle_s *next;
! 340:
! 341: float time;
! 342:
! 343: vec3_t org;
! 344: vec3_t vel;
! 345: vec3_t accel;
! 346: float color;
! 347: float colorvel;
! 348: float alpha;
! 349: float alphavel;
! 350: } cparticle_t;
! 351:
! 352:
! 353: #define PARTICLE_GRAVITY 40
! 354: #define BLASTER_PARTICLE_COLOR 0xe0
! 355: // PMM
! 356: #define INSTANT_PARTICLE -10000.0
! 357: // PGM
! 358: // ========
! 359:
1.1 root 360: void CL_ClearEffects (void);
361: void CL_ClearTEnts (void);
362: void CL_BlasterTrail (vec3_t start, vec3_t end);
363: void CL_QuadTrail (vec3_t start, vec3_t end);
364: void CL_RailTrail (vec3_t start, vec3_t end);
365: void CL_BubbleTrail (vec3_t start, vec3_t end);
366: void CL_FlagTrail (vec3_t start, vec3_t end, float color);
367:
1.1.1.2 root 368: // RAFAEL
369: void CL_IonripperTrail (vec3_t start, vec3_t end);
370:
1.1.1.3 ! root 371: // ========
! 372: // PGM
! 373: void CL_BlasterParticles2 (vec3_t org, vec3_t dir, unsigned int color);
! 374: void CL_BlasterTrail2 (vec3_t start, vec3_t end);
! 375: void CL_DebugTrail (vec3_t start, vec3_t end);
! 376: void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int spacing);
! 377: void CL_Flashlight (int ent, vec3_t pos);
! 378: void CL_ForceWall (vec3_t start, vec3_t end, int color);
! 379: void CL_FlameEffects (centity_t *ent, vec3_t origin);
! 380: void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int numcolors, int dirspread, float alphavel);
! 381: void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist);
! 382: void CL_Heatbeam (vec3_t start, vec3_t end);
! 383: void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
! 384: void CL_TrackerTrail (vec3_t start, vec3_t end, int particleColor);
! 385: void CL_Tracker_Explode(vec3_t origin);
! 386: void CL_TagTrail (vec3_t start, vec3_t end, float color);
! 387: void CL_ColorFlash (vec3_t pos, int ent, int intensity, float r, float g, float b);
! 388: void CL_Tracker_Shell(vec3_t origin);
! 389: void CL_MonsterPlasma_Shell(vec3_t origin);
! 390: void CL_ColorExplosionParticles (vec3_t org, int color, int run);
! 391: void CL_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
! 392: void CL_Widowbeamout (cl_sustain_t *self);
! 393: void CL_Nukeblast (cl_sustain_t *self);
! 394: void CL_WidowSplash (vec3_t org);
! 395: // PGM
! 396: // ========
! 397:
1.1 root 398: int CL_ParseEntityBits (unsigned *bits);
399: void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int number, int bits);
400: void CL_ParseFrame (void);
1.1.1.2 root 401:
1.1 root 402: void CL_ParseTEnt (void);
403: void CL_ParseConfigString (void);
404: void CL_ParseMuzzleFlash (void);
405: void CL_ParseMuzzleFlash2 (void);
406: void SmokeAndFlash(vec3_t origin);
1.1.1.2 root 407:
1.1 root 408: void CL_SetLightstyle (int i);
1.1.1.2 root 409:
1.1 root 410: void CL_RunParticles (void);
411: void CL_RunDLights (void);
412: void CL_RunLightStyles (void);
1.1.1.2 root 413:
1.1 root 414: void CL_AddEntities (void);
415: void CL_AddDLights (void);
416: void CL_AddTEnts (void);
417: void CL_AddLightStyles (void);
1.1.1.2 root 418:
1.1 root 419: //=================================================
1.1.1.2 root 420:
1.1 root 421: void CL_PrepRefresh (void);
422: void CL_RegisterSounds (void);
1.1.1.2 root 423:
1.1 root 424: void CL_Quit_f (void);
1.1.1.2 root 425:
1.1 root 426: void IN_Accumulate (void);
1.1.1.2 root 427:
1.1 root 428: void CL_ParseLayout (void);
1.1.1.2 root 429:
430:
1.1 root 431: //
432: // cl_main
433: //
434: extern refexport_t re; // interface to refresh .dll
1.1.1.2 root 435:
1.1 root 436: void CL_Init (void);
1.1.1.2 root 437:
438: void CL_FixUpGender(void);
1.1 root 439: void CL_Disconnect (void);
440: void CL_Disconnect_f (void);
441: void CL_GetChallengePacket (void);
442: void CL_PingServers_f (void);
443: void CL_Snd_Restart_f (void);
1.1.1.2 root 444: void CL_RequestNextDownload (void);
445:
1.1 root 446: //
447: // cl_input
448: //
449: typedef struct
450: {
451: int down[2]; // key nums holding it down
452: unsigned downtime; // msec timestamp
453: unsigned msec; // msec down this frame
454: int state;
455: } kbutton_t;
1.1.1.2 root 456:
1.1 root 457: extern kbutton_t in_mlook, in_klook;
458: extern kbutton_t in_strafe;
459: extern kbutton_t in_speed;
1.1.1.2 root 460:
1.1 root 461: void CL_InitInput (void);
462: void CL_SendCmd (void);
463: void CL_SendMove (usercmd_t *cmd);
1.1.1.2 root 464:
1.1 root 465: void CL_ClearState (void);
1.1.1.2 root 466:
1.1 root 467: void CL_ReadPackets (void);
1.1.1.2 root 468:
1.1 root 469: int CL_ReadFromServer (void);
470: void CL_WriteToServer (usercmd_t *cmd);
471: void CL_BaseMove (usercmd_t *cmd);
1.1.1.2 root 472:
1.1 root 473: void IN_CenterView (void);
1.1.1.2 root 474:
1.1 root 475: float CL_KeyState (kbutton_t *key);
476: char *Key_KeynumToString (int keynum);
1.1.1.2 root 477:
1.1 root 478: //
479: // cl_demo.c
480: //
481: void CL_WriteDemoMessage (void);
482: void CL_Stop_f (void);
483: void CL_Record_f (void);
1.1.1.2 root 484:
1.1 root 485: //
486: // cl_parse.c
487: //
488: extern char *svc_strings[256];
489:
490: void CL_ParseServerMessage (void);
491: void CL_LoadClientinfo (clientinfo_t *ci, char *s);
492: void SHOWNET(char *s);
493: void CL_ParseClientinfo (int player);
1.1.1.2 root 494: void CL_Download_f (void);
495:
1.1 root 496: //
497: // cl_view.c
498: //
499: extern int gun_frame;
500: extern struct model_s *gun_model;
501:
502: void V_Init (void);
503: void V_RenderView( float stereo_separation );
504: void V_AddEntity (entity_t *ent);
505: void V_AddParticle (vec3_t org, int color, float alpha);
506: void V_AddLight (vec3_t org, float intensity, float r, float g, float b);
507: void V_AddLightStyle (int style, float r, float g, float b);
1.1.1.2 root 508:
1.1 root 509: //
510: // cl_tent.c
511: //
512: void CL_RegisterTEntSounds (void);
513: void CL_RegisterTEntModels (void);
514: void CL_SmokeAndFlash(vec3_t origin);
1.1.1.2 root 515:
516:
1.1 root 517: //
518: // cl_pred.c
519: //
520: void CL_InitPrediction (void);
521: void CL_PredictMove (void);
522: void CL_CheckPredictionError (void);
1.1.1.2 root 523:
1.1 root 524: //
525: // cl_fx.c
526: //
527: cdlight_t *CL_AllocDlight (int key);
528: void CL_BigTeleportParticles (vec3_t org);
529: void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old);
530: void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags);
531: void CL_FlyEffect (centity_t *ent, vec3_t origin);
532: void CL_BfgParticles (entity_t *ent);
533: void CL_AddParticles (void);
534: void CL_EntityEvent (entity_state_t *ent);
1.1.1.2 root 535: // RAFAEL
536: void CL_TrapParticles (entity_t *ent);
537:
1.1 root 538: //
539: // menus
540: //
541: void M_Init (void);
542: void M_Keydown (int key);
543: void M_Draw (void);
544: void M_Menu_Main_f (void);
545: void M_ForceMenuOff (void);
546: void M_AddToServerList (netadr_t adr, char *info);
1.1.1.2 root 547:
1.1 root 548: //
549: // cl_inv.c
550: //
551: void CL_ParseInventory (void);
552: void CL_KeyInventory (int key);
553: void CL_DrawInventory (void);
554:
555: //
556: // cl_pred.c
557: //
558: void CL_PredictMovement (void);
559:
560: #if id386
561: void x86_TimerStart( void );
562: void x86_TimerStop( void );
563: void x86_TimerInit( unsigned long smallest, unsigned longest );
564: unsigned long *x86_TimerGetHistogram( void );
565: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.