Annotation of quake2/client/client.h, revision 1.1.1.1

1.1       root        1: // client.h -- primary header for client
                      2: //define       PARANOID                        // speed sapping error checking
                      3: #include <math.h>
                      4: #include <string.h>
                      5: #include <stdarg.h>
                      6: #include <stdio.h>
                      7: #include <stdlib.h>
                      8: #include "ref.h"
                      9: #include "vid.h"
                     10: #include "screen.h"
                     11: #include "sound.h"
                     12: #include "input.h"
                     13: #include "keys.h"
                     14: #include "console.h"
                     15: #include "cdaudio.h"
                     16: //=============================================================================
                     17: typedef struct
                     18: {
                     19:        qboolean                valid;                  // cleared if delta parsing was invalid
                     20:        int                             serverframe;
                     21:        int                             servertime;             // server time the message is valid for (in msec)
                     22:        int                             deltaframe;
                     23:        byte                    areabits[MAX_MAP_AREAS/8];              // portalarea visibility bits
                     24:        player_state_t  playerstate;
                     25:        int                             num_entities;
                     26:        int                             parse_entities; // non-masked index into cl_parse_entities array
                     27: } frame_t;
                     28: typedef struct
                     29: {
                     30:        entity_state_t  baseline;               // delta from this if not from a previous frame
                     31:        entity_state_t  current;
                     32:        entity_state_t  prev;                   // will always be valid, but might just be a copy of current
                     33:        int                     serverframe;            // if not current, this ent isn't in the frame
                     34: 
                     35:        int                     trailcount;                     // for diminishing grenade trails
                     36:        vec3_t          lerp_origin;            // for trails (variable hz)
                     37: 
                     38:        int                     fly_stoptime;
                     39: } centity_t;
                     40: 
                     41: 
                     42: typedef struct
                     43: {
                     44:        char    name[MAX_QPATH];
                     45:        struct image_s  *skin;
                     46:        struct image_s  *icon;
                     47:        char    iconname[MAX_QPATH];
                     48:        struct model_s  *model;
                     49:        struct model_s  *weaponmodel;
                     50: } clientinfo_t;
                     51: 
                     52: #define        CMD_BACKUP              64      // allow a lot of command backups for very fast systems
                     53: //
                     54: // the client_state_t structure is wiped completely at every
                     55: // server map change
                     56: //
                     57: typedef struct
                     58: {
                     59:        int                     timeoutcount;
                     60:        int                     timedemo_frames;
                     61:        int                     timedemo_start;
                     62:        qboolean        refresh_prepped;        // false if on new level or new ref dll
                     63:        qboolean        sound_prepped;          // ambient sounds can start
                     64:        qboolean        force_refdef;           // vid has changed, so we can't use a paused refdef
                     65:        int                     parse_entities;         // index (not anded off) into cl_parse_entities[]
                     66:        usercmd_t       cmd;
                     67:        usercmd_t       cmds[CMD_BACKUP];       // each mesage will send several old cmds
                     68:        int                     cmd_time[CMD_BACKUP];   // time sent, for calculating pings
                     69:        short           predicted_origins[CMD_BACKUP][3];       // for debug comparing against server
                     70: 
                     71:        float           predicted_step;                         // for stair up smoothing
                     72:        unsigned        predicted_step_time;
                     73: 
                     74:        vec3_t          predicted_origin;       // generated by CL_PredictMovement
                     75:        vec3_t          predicted_angles;
                     76:        vec3_t          prediction_error;
                     77:        frame_t         frame;                          // received from server
                     78:        int                     surpressCount;          // number of messages rate supressed
                     79:        frame_t         frames[UPDATE_BACKUP];
                     80:        // the client maintains its own idea of view angles, which are
                     81:        // sent to the server each frame.  It is cleared to 0 upon entering each level.
                     82:        // the server sends a delta each frame which is added to the locally
                     83:        // tracked view angles to account for standing on rotating objects,
                     84:        // and teleport direction changes
                     85:        vec3_t          viewangles;
                     86:        int                     time;                   // this is the time value that the client
                     87:                                                                // is rendering at.  allways <= cls.realtime
                     88:        float           lerpfrac;               // between oldframe and frame
                     89:        refdef_t        refdef;
                     90:        vec3_t          v_forward, v_right, v_up;       // set when refdef.angles is set
                     91:        //
                     92:        // transient data from server
                     93:        //
                     94:        char            layout[1024];           // general 2D overlay
                     95:        int                     inventory[MAX_ITEMS];
                     96:        //
                     97:        // non-gameserver infornamtion
                     98:        // FIXME: move this cinematic stuff into the cin_t structure
                     99:        FILE            *cinematic_file;
                    100:        int                     cinematictime;          // cls.realtime for first cinematic frame
                    101:        int                     cinematicframe;
                    102:        char            cinematicpalette[768];
                    103:        qboolean        cinematicpalette_active;
                    104:        //
                    105:        // server state information
                    106:        //
                    107:        qboolean        attractloop;            // running the attract loop, any key will menu
                    108:        int                     servercount;    // server identification for prespawns
                    109:        char            gamedir[MAX_QPATH];
                    110:        int                     playernum;
                    111:        char            configstrings[MAX_CONFIGSTRINGS][MAX_QPATH];
                    112:        //
                    113:        // locally derived information from server state
                    114:        //
                    115:        struct model_s  *model_draw[MAX_MODELS];
                    116:        struct cmodel_s *model_clip[MAX_MODELS];
                    117:        struct sfx_s    *sound_precache[MAX_SOUNDS];
                    118:        struct image_s  *image_precache[MAX_IMAGES];
                    119: 
                    120:        clientinfo_t    clientinfo[MAX_CLIENTS];
                    121:        clientinfo_t    baseclientinfo;
                    122: } client_state_t;
                    123: extern client_state_t  cl;
                    124: /*
                    125: ==================================================================
                    126: the client_static_t structure is persistant through an arbitrary number
                    127: of server connections
                    128: ==================================================================
                    129: */
                    130: typedef enum {
                    131:        ca_uninitialized,
                    132:        ca_disconnected,        // not talking to a server
                    133:        ca_connecting,          // sending request packets to the server
                    134:        ca_connected,           // netchan_t established, waiting for svc_serverdata
                    135:        ca_active                       // game views should be displayed
                    136: } connstate_t;
                    137: typedef enum {
                    138:        dl_none,
                    139:        dl_model,
                    140:        dl_sound,
                    141:        dl_skin,
                    142:        dl_single
                    143: } dltype_t;            // download type
                    144: typedef enum {key_game, key_console, key_message, key_menu} keydest_t;
                    145: typedef struct
                    146: {
                    147:        connstate_t     state;
                    148:        keydest_t       key_dest;
                    149:        int                     framecount;
                    150:        int                     realtime;                       // allways increasing, no clamping, etc
                    151:        float           frametime;                      // seconds since last frame
                    152: // screen rendering information
                    153:        float           disable_screen;         // showing loading plaque between levels
                    154:                                                                        // or changing rendering dlls
                    155:                                                                        // if time gets > 30 seconds ahead, break it
                    156:        int                     disable_servercount;    // when we receive a frame and cl.servercount
                    157:                                                                        // > cls.disable_servercount, clear disable_screen
                    158: // connection information
                    159:        char            servername[MAX_OSPATH]; // name of server from original connect
                    160:        float           connect_time;           // for connection retransmits
                    161: 
                    162:        int                     quakePort;                      // a 16 bit value that allows quake servers
                    163:                                                                        // to work around address translating routers
                    164:        netchan_t       netchan;
                    165:        int                     serverProtocol;         // in case we are doing some kind of version hack
                    166: 
                    167:        int                     challenge;                      // from the server to use for connecting
                    168:        FILE            *download;                      // file transfer from server
                    169:        char            downloadtempname[MAX_OSPATH];
                    170:        char            downloadname[MAX_OSPATH];
                    171:        int                     downloadnumber;
                    172:        dltype_t        downloadtype;
                    173:        int                     downloadpercent;
                    174: // demo recording info must be here, so it isn't cleared on level change
                    175:        qboolean        demorecording;
                    176:        qboolean        demowaiting;    // don't record until a non-delta message is received
                    177:        FILE            *demofile;
                    178: } client_static_t;
                    179: extern client_static_t cls;
                    180: //=============================================================================
                    181: //
                    182: // cvars
                    183: //
                    184: extern cvar_t  *cl_stereo_separation;
                    185: extern cvar_t  *cl_stereo;
                    186: 
                    187: extern cvar_t  *cl_gun;
                    188: extern cvar_t  *cl_add_blend;
                    189: extern cvar_t  *cl_add_lights;
                    190: extern cvar_t  *cl_add_particles;
                    191: extern cvar_t  *cl_add_entities;
                    192: extern cvar_t  *cl_predict;
                    193: extern cvar_t  *cl_footsteps;
                    194: extern cvar_t  *cl_noskins;
                    195: extern cvar_t  *cl_autoskins;
                    196: extern cvar_t  *cl_upspeed;
                    197: extern cvar_t  *cl_forwardspeed;
                    198: extern cvar_t  *cl_sidespeed;
                    199: extern cvar_t  *cl_yawspeed;
                    200: extern cvar_t  *cl_pitchspeed;
                    201: 
                    202: extern cvar_t  *cl_run;
                    203: extern cvar_t  *cl_anglespeedkey;
                    204: extern cvar_t  *cl_shownet;
                    205: extern cvar_t  *cl_showmiss;
                    206: extern cvar_t  *cl_showclamp;
                    207: extern cvar_t  *lookspring;
                    208: extern cvar_t  *lookstrafe;
                    209: extern cvar_t  *sensitivity;
                    210: extern cvar_t  *m_pitch;
                    211: extern cvar_t  *m_yaw;
                    212: extern cvar_t  *m_forward;
                    213: extern cvar_t  *m_side;
                    214: extern cvar_t  *freelook;
                    215: extern cvar_t  *cl_lightlevel; // FIXME HACK
                    216: extern cvar_t  *cl_paused;
                    217: extern cvar_t  *cl_timedemo;
                    218: typedef struct
                    219: {
                    220:        int             key;                            // so entities can reuse same entry
                    221:        vec3_t  color;
                    222:        vec3_t  origin;
                    223:        float   radius;
                    224:        float   die;                            // stop lighting after this time
                    225:        float   decay;                          // drop this each second
                    226:        float   minlight;                       // don't add when contributing less
                    227: } cdlight_t;
                    228: extern centity_t       cl_entities[MAX_EDICTS];
                    229: extern cdlight_t       cl_dlights[MAX_DLIGHTS];
                    230: 
                    231: // the cl_parse_entities must be large enough to hold UPDATE_BACKUP frames of
                    232: // entities, so that when a delta compressed message arives from the server
                    233: // it can be un-deltad from the original 
                    234: #define        MAX_PARSE_ENTITIES      1024
                    235: extern entity_state_t  cl_parse_entities[MAX_PARSE_ENTITIES];
                    236: //=============================================================================
                    237: extern netadr_t        net_from;
                    238: extern sizebuf_t       net_message;
                    239: void DrawString (int x, int y, char *s);
                    240: void DrawAltString (int x, int y, char *s);    // toggle high bit
                    241: qboolean       CL_CheckOrDownloadFile (char *filename);
                    242: 
                    243: void CL_AddNetgraph (void);
                    244: void CL_TeleporterParticles (entity_state_t *ent);
                    245: void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count);
                    246: void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count);
                    247: //=================================================
                    248: void CL_ClearEffects (void);
                    249: void CL_ClearTEnts (void);
                    250: void CL_BlasterTrail (vec3_t start, vec3_t end);
                    251: void CL_QuadTrail (vec3_t start, vec3_t end);
                    252: void CL_RailTrail (vec3_t start, vec3_t end);
                    253: void CL_BubbleTrail (vec3_t start, vec3_t end);
                    254: void CL_FlagTrail (vec3_t start, vec3_t end, float color);
                    255: 
                    256: // added this
                    257: void CL_PlasmaTrail (vec3_t start, vec3_t end);
                    258: void CL_BoomerTrail (vec3_t start, vec3_t end);
                    259: int CL_ParseEntityBits (unsigned *bits);
                    260: void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int number, int bits);
                    261: void CL_ParseFrame (void);
                    262: void CL_ParseTEnt (void);
                    263: void CL_ParseConfigString (void);
                    264: void CL_ParseMuzzleFlash (void);
                    265: void CL_ParseMuzzleFlash2 (void);
                    266: void SmokeAndFlash(vec3_t origin);
                    267: void CL_SetLightstyle (int i);
                    268: void CL_RunParticles (void);
                    269: void CL_RunDLights (void);
                    270: void CL_RunLightStyles (void);
                    271: void CL_AddEntities (void);
                    272: void CL_AddDLights (void);
                    273: void CL_AddTEnts (void);
                    274: void CL_AddLightStyles (void);
                    275: //=================================================
                    276: void CL_PrepRefresh (void);
                    277: void CL_RegisterSounds (void);
                    278: void CL_Quit_f (void);
                    279: void IN_Accumulate (void);
                    280: void CL_ParseLayout (void);
                    281: //
                    282: // cl_main
                    283: //
                    284: extern refexport_t     re;             // interface to refresh .dll
                    285: void CL_Init (void);
                    286: void CL_Disconnect (void);
                    287: void CL_Disconnect_f (void);
                    288: void CL_GetChallengePacket (void);
                    289: void CL_PingServers_f (void);
                    290: void CL_Snd_Restart_f (void);
                    291: //
                    292: // cl_input
                    293: //
                    294: typedef struct
                    295: {
                    296:        int                     down[2];                // key nums holding it down
                    297:        unsigned        downtime;               // msec timestamp
                    298:        unsigned        msec;                   // msec down this frame
                    299:        int                     state;
                    300: } kbutton_t;
                    301: extern kbutton_t       in_mlook, in_klook;
                    302: extern         kbutton_t       in_strafe;
                    303: extern         kbutton_t       in_speed;
                    304: void CL_InitInput (void);
                    305: void CL_SendCmd (void);
                    306: void CL_SendMove (usercmd_t *cmd);
                    307: void CL_ClearState (void);
                    308: void CL_ReadPackets (void);
                    309: int  CL_ReadFromServer (void);
                    310: void CL_WriteToServer (usercmd_t *cmd);
                    311: void CL_BaseMove (usercmd_t *cmd);
                    312: void IN_CenterView (void);
                    313: float CL_KeyState (kbutton_t *key);
                    314: char *Key_KeynumToString (int keynum);
                    315: //
                    316: // cl_demo.c
                    317: //
                    318: void CL_WriteDemoMessage (void);
                    319: void CL_Stop_f (void);
                    320: void CL_Record_f (void);
                    321: //
                    322: // cl_parse.c
                    323: //
                    324: extern char *svc_strings[256];
                    325: 
                    326: void CL_ParseServerMessage (void);
                    327: void CL_LoadClientinfo (clientinfo_t *ci, char *s);
                    328: void SHOWNET(char *s);
                    329: void CL_ParseClientinfo (int player);
                    330: //
                    331: // cl_view.c
                    332: //
                    333: extern int                     gun_frame;
                    334: extern struct model_s  *gun_model;
                    335: 
                    336: void V_Init (void);
                    337: void V_RenderView( float stereo_separation );
                    338: void V_AddEntity (entity_t *ent);
                    339: void V_AddParticle (vec3_t org, int color, float alpha);
                    340: void V_AddLight (vec3_t org, float intensity, float r, float g, float b);
                    341: void V_AddLightStyle (int style, float r, float g, float b);
                    342: //
                    343: // cl_tent.c
                    344: //
                    345: void CL_RegisterTEntSounds (void);
                    346: void CL_RegisterTEntModels (void);
                    347: void CL_SmokeAndFlash(vec3_t origin);
                    348: //
                    349: // cl_pred.c
                    350: //
                    351: void CL_InitPrediction (void);
                    352: void CL_PredictMove (void);
                    353: void CL_CheckPredictionError (void);
                    354: //
                    355: // cl_fx.c
                    356: //
                    357: cdlight_t *CL_AllocDlight (int key);
                    358: void CL_BigTeleportParticles (vec3_t org);
                    359: void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old);
                    360: void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags);
                    361: void CL_FlyEffect (centity_t *ent, vec3_t origin);
                    362: void CL_BfgParticles (entity_t *ent);
                    363: void CL_AddParticles (void);
                    364: void CL_EntityEvent (entity_state_t *ent);
                    365: //
                    366: // menus
                    367: //
                    368: void M_Init (void);
                    369: void M_Keydown (int key);
                    370: void M_Draw (void);
                    371: void M_Menu_Main_f (void);
                    372: void M_ForceMenuOff (void);
                    373: void M_AddToServerList (netadr_t adr, char *info);
                    374: //
                    375: // cl_inv.c
                    376: //
                    377: void CL_ParseInventory (void);
                    378: void CL_KeyInventory (int key);
                    379: void CL_DrawInventory (void);
                    380: 
                    381: //
                    382: // cl_pred.c
                    383: //
                    384: void CL_PredictMovement (void);
                    385: 
                    386: #if id386
                    387: void x86_TimerStart( void );
                    388: void x86_TimerStop( void );
                    389: void x86_TimerInit( unsigned long smallest, unsigned longest );
                    390: unsigned long *x86_TimerGetHistogram( void );
                    391: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.