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

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.2 ! root       49: #define MAX_CLIENTWEAPONMODELS         16
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       root      306: void CL_TeleporterParticles (entity_state_t *ent);
                    307: void CL_ParticleEffect (vec3_t org, vec3_t dir, int color, int count);
                    308: void CL_ParticleEffect2 (vec3_t org, vec3_t dir, int color, int count);
1.1.1.2 ! root      309: 
        !           310: // RAFAEL
        !           311: void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count);
        !           312: 
        !           313: 
1.1       root      314: //=================================================
1.1.1.2 ! root      315: 
1.1       root      316: void CL_ClearEffects (void);
                    317: void CL_ClearTEnts (void);
                    318: void CL_BlasterTrail (vec3_t start, vec3_t end);
                    319: void CL_QuadTrail (vec3_t start, vec3_t end);
                    320: void CL_RailTrail (vec3_t start, vec3_t end);
                    321: void CL_BubbleTrail (vec3_t start, vec3_t end);
                    322: void CL_FlagTrail (vec3_t start, vec3_t end, float color);
                    323: 
1.1.1.2 ! root      324: // RAFAEL
        !           325: void CL_IonripperTrail (vec3_t start, vec3_t end);
        !           326: 
1.1       root      327: int CL_ParseEntityBits (unsigned *bits);
                    328: void CL_ParseDelta (entity_state_t *from, entity_state_t *to, int number, int bits);
                    329: void CL_ParseFrame (void);
1.1.1.2 ! root      330: 
1.1       root      331: void CL_ParseTEnt (void);
                    332: void CL_ParseConfigString (void);
                    333: void CL_ParseMuzzleFlash (void);
                    334: void CL_ParseMuzzleFlash2 (void);
                    335: void SmokeAndFlash(vec3_t origin);
1.1.1.2 ! root      336: 
1.1       root      337: void CL_SetLightstyle (int i);
1.1.1.2 ! root      338: 
1.1       root      339: void CL_RunParticles (void);
                    340: void CL_RunDLights (void);
                    341: void CL_RunLightStyles (void);
1.1.1.2 ! root      342: 
1.1       root      343: void CL_AddEntities (void);
                    344: void CL_AddDLights (void);
                    345: void CL_AddTEnts (void);
                    346: void CL_AddLightStyles (void);
1.1.1.2 ! root      347: 
1.1       root      348: //=================================================
1.1.1.2 ! root      349: 
1.1       root      350: void CL_PrepRefresh (void);
                    351: void CL_RegisterSounds (void);
1.1.1.2 ! root      352: 
1.1       root      353: void CL_Quit_f (void);
1.1.1.2 ! root      354: 
1.1       root      355: void IN_Accumulate (void);
1.1.1.2 ! root      356: 
1.1       root      357: void CL_ParseLayout (void);
1.1.1.2 ! root      358: 
        !           359: 
1.1       root      360: //
                    361: // cl_main
                    362: //
                    363: extern refexport_t     re;             // interface to refresh .dll
1.1.1.2 ! root      364: 
1.1       root      365: void CL_Init (void);
1.1.1.2 ! root      366: 
        !           367: void CL_FixUpGender(void);
1.1       root      368: void CL_Disconnect (void);
                    369: void CL_Disconnect_f (void);
                    370: void CL_GetChallengePacket (void);
                    371: void CL_PingServers_f (void);
                    372: void CL_Snd_Restart_f (void);
1.1.1.2 ! root      373: void CL_RequestNextDownload (void);
        !           374: 
1.1       root      375: //
                    376: // cl_input
                    377: //
                    378: typedef struct
                    379: {
                    380:        int                     down[2];                // key nums holding it down
                    381:        unsigned        downtime;               // msec timestamp
                    382:        unsigned        msec;                   // msec down this frame
                    383:        int                     state;
                    384: } kbutton_t;
1.1.1.2 ! root      385: 
1.1       root      386: extern kbutton_t       in_mlook, in_klook;
                    387: extern         kbutton_t       in_strafe;
                    388: extern         kbutton_t       in_speed;
1.1.1.2 ! root      389: 
1.1       root      390: void CL_InitInput (void);
                    391: void CL_SendCmd (void);
                    392: void CL_SendMove (usercmd_t *cmd);
1.1.1.2 ! root      393: 
1.1       root      394: void CL_ClearState (void);
1.1.1.2 ! root      395: 
1.1       root      396: void CL_ReadPackets (void);
1.1.1.2 ! root      397: 
1.1       root      398: int  CL_ReadFromServer (void);
                    399: void CL_WriteToServer (usercmd_t *cmd);
                    400: void CL_BaseMove (usercmd_t *cmd);
1.1.1.2 ! root      401: 
1.1       root      402: void IN_CenterView (void);
1.1.1.2 ! root      403: 
1.1       root      404: float CL_KeyState (kbutton_t *key);
                    405: char *Key_KeynumToString (int keynum);
1.1.1.2 ! root      406: 
1.1       root      407: //
                    408: // cl_demo.c
                    409: //
                    410: void CL_WriteDemoMessage (void);
                    411: void CL_Stop_f (void);
                    412: void CL_Record_f (void);
1.1.1.2 ! root      413: 
1.1       root      414: //
                    415: // cl_parse.c
                    416: //
                    417: extern char *svc_strings[256];
                    418: 
                    419: void CL_ParseServerMessage (void);
                    420: void CL_LoadClientinfo (clientinfo_t *ci, char *s);
                    421: void SHOWNET(char *s);
                    422: void CL_ParseClientinfo (int player);
1.1.1.2 ! root      423: void CL_Download_f (void);
        !           424: 
1.1       root      425: //
                    426: // cl_view.c
                    427: //
                    428: extern int                     gun_frame;
                    429: extern struct model_s  *gun_model;
                    430: 
                    431: void V_Init (void);
                    432: void V_RenderView( float stereo_separation );
                    433: void V_AddEntity (entity_t *ent);
                    434: void V_AddParticle (vec3_t org, int color, float alpha);
                    435: void V_AddLight (vec3_t org, float intensity, float r, float g, float b);
                    436: void V_AddLightStyle (int style, float r, float g, float b);
1.1.1.2 ! root      437: 
1.1       root      438: //
                    439: // cl_tent.c
                    440: //
                    441: void CL_RegisterTEntSounds (void);
                    442: void CL_RegisterTEntModels (void);
                    443: void CL_SmokeAndFlash(vec3_t origin);
1.1.1.2 ! root      444: 
        !           445: 
1.1       root      446: //
                    447: // cl_pred.c
                    448: //
                    449: void CL_InitPrediction (void);
                    450: void CL_PredictMove (void);
                    451: void CL_CheckPredictionError (void);
1.1.1.2 ! root      452: 
1.1       root      453: //
                    454: // cl_fx.c
                    455: //
                    456: cdlight_t *CL_AllocDlight (int key);
                    457: void CL_BigTeleportParticles (vec3_t org);
                    458: void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old);
                    459: void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old, int flags);
                    460: void CL_FlyEffect (centity_t *ent, vec3_t origin);
                    461: void CL_BfgParticles (entity_t *ent);
                    462: void CL_AddParticles (void);
                    463: void CL_EntityEvent (entity_state_t *ent);
1.1.1.2 ! root      464: // RAFAEL
        !           465: void CL_TrapParticles (entity_t *ent);
        !           466: 
1.1       root      467: //
                    468: // menus
                    469: //
                    470: void M_Init (void);
                    471: void M_Keydown (int key);
                    472: void M_Draw (void);
                    473: void M_Menu_Main_f (void);
                    474: void M_ForceMenuOff (void);
                    475: void M_AddToServerList (netadr_t adr, char *info);
1.1.1.2 ! root      476: 
1.1       root      477: //
                    478: // cl_inv.c
                    479: //
                    480: void CL_ParseInventory (void);
                    481: void CL_KeyInventory (int key);
                    482: void CL_DrawInventory (void);
                    483: 
                    484: //
                    485: // cl_pred.c
                    486: //
                    487: void CL_PredictMovement (void);
                    488: 
                    489: #if id386
                    490: void x86_TimerStart( void );
                    491: void x86_TimerStop( void );
                    492: void x86_TimerInit( unsigned long smallest, unsigned longest );
                    493: unsigned long *x86_TimerGetHistogram( void );
                    494: #endif

unix.superglobalmegacorp.com

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