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