/* * Copyright(c) 1997-2001 Id Software, Inc. * Copyright(c) 2002 The Quakeforge Project. * Copyright(c) 2006 Quetoo. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or(at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __CLIENT_H__ #define __CLIENT_H__ #include "qcommon.h" #include "video.h" #include "screen.h" #include "sound.h" #include "input.h" #include "keys.h" #include "console.h" typedef struct { qboolean valid; // cleared if delta parsing was invalid int serverframe; int servertime; // server time the message is valid for(in msec) int deltaframe; byte areabits[MAX_MAP_AREAS / 8]; // portalarea visibility bits player_state_t playerstate; int num_entities; int parse_entities; // non-masked index into cl_parse_entities array } frame_t; typedef struct { entity_state_t baseline; // delta from this if not from a previous frame entity_state_t current; entity_state_t prev; // will always be valid, but might just be a copy of current int serverframe; // if not current, this ent isn't in the frame int trailcount; // for diminishing grenade trails vec3_t lerp_origin; // for trails (variable hz) int fly_stoptime; } centity_t; #define MAX_CLIENTWEAPONMODELS 20 // PGM -- upped from 16 to fit the chainfist vwep typedef struct { char name[MAX_QPATH]; char cinfo[MAX_QPATH]; struct image_s *skin; struct image_s *icon; char iconname[MAX_QPATH]; struct model_s *model; struct model_s *weaponmodel[MAX_CLIENTWEAPONMODELS]; byte bright[3]; } clientinfo_t; extern char cl_weaponmodels[MAX_CLIENTWEAPONMODELS][MAX_QPATH]; extern int num_cl_weaponmodels; #define CMD_BACKUP 64 // allow a lot of command backups for very fast systems // the client_state_t structure is wiped completely at every // server map change typedef struct { int timeoutcount; int timedemo_frames; int timedemo_start; qboolean view_prepped; // false if on new level or new ref dll int parse_entities; // index(not anded off) into cl_parse_entities[] usercmd_t cmd; usercmd_t cmds[CMD_BACKUP]; // each mesage will send several old cmds int cmd_time[CMD_BACKUP]; // time sent, for calculating pings short predicted_origins[CMD_BACKUP][3]; // for debug comparing against server float predicted_step; // for stair up smoothing unsigned predicted_step_time; vec3_t predicted_origin; // generated by CL_PredictMovement vec3_t predicted_angles; vec3_t prediction_error; frame_t frame; // received from server int surpressCount; // number of messages rate supressed frame_t frames[UPDATE_BACKUP]; // the client maintains its own idea of view angles, which are // sent to the server each frame. It is cleared to 0 upon entering each level. // the server sends a delta each frame which is added to the locally // tracked view angles to account for standing on rotating objects, // and teleport direction changes vec3_t viewangles; int time; // this is the time value that the client // is rendering at. always <= cls.realtime int initial_server_frame; float lerpfrac; // between oldframe and frame viewdef_t viewdef; vec3_t v_forward, v_right, v_up; // set when viewdef.angles is set // transient data from server char layout[1024]; // general 2D overlay int inventory[MAX_ITEMS]; // server state information qboolean demoserver; // viewing a demo, was known as 'attractloop' int servercount; // server identification for prespawns char gamedir[MAX_QPATH]; int playernum; char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]; // locally derived information from server state struct model_s *model_draw[MAX_MODELS]; struct cmodel_s *model_clip[MAX_MODELS]; struct sfx_s *sound_precache[MAX_SOUNDS]; struct image_s *image_precache[MAX_IMAGES]; clientinfo_t clientinfo[MAX_CLIENTS]; clientinfo_t baseclientinfo; qboolean enhancedServer; qboolean strafeHack; } client_state_t; extern client_state_t cl; /* the client_static_t structure is persistant through an arbitrary number of server connections */ typedef enum { ca_uninitialized, ca_disconnected, // not talking to a server ca_connecting, // sending request packets to the server ca_connected, // netchan_t established, waiting for svc_serverdata ca_active // game views should be displayed } connstate_t; typedef enum { key_game, key_console, key_message } keydest_t; typedef struct { connstate_t state; keydest_t key_dest; int realtime; // always increasing, no clamping, etc float frametime; // seconds since last frame // connection information char servername[MAX_OSPATH]; // name of server to connect to float connect_time; // for connection retransmits int qport; // deal with network address translation int protocol; // in case we are doing some kind of version hack netchan_t netchan; int challenge; // from the server to use for connecting FILE *download; // file transfer from server char downloadtempname[MAX_OSPATH]; char downloadname[MAX_OSPATH]; int downloadnumber; int downloadpercent; // demo recording info must be here, so it isn't cleared on level change qboolean demorecording; qboolean demowaiting; // don't record until a non-delta message is received FILE *demofile; } client_static_t; extern client_static_t cls; // cvars extern cvar_t *cl_add_particles; extern cvar_t *cl_add_entities; extern cvar_t *cl_predict; extern cvar_t *cl_footsteps; extern cvar_t *cl_noskins; extern cvar_t *cl_brightskins; extern cvar_t *cl_shownet; extern cvar_t *cl_showmiss; extern cvar_t *cl_showclamp; extern cvar_t *paused; extern cvar_t *timedemo; extern cvar_t *cl_vwep; // cl_console.c void DrawString(int x, int y, char *s); void DrawAltString(int x, int y, char *s); // toggle high bit // cl_screen.c void CL_AddNetgraph(void); // cl_ents.c void CL_AddEntities(void); void CL_AddTEnts(void); void CL_ClearTEnts(void); // cl_tent.c void CL_RegisterTEntSounds(void); void CL_RegisterTEntModels(void); // cl_main.c extern qboolean send_packet_now; void CL_Init(void); void CL_FixUpGender(void); void CL_Disconnect(void); void CL_Reconnect_f(void); void CL_RequestNextDownload(void); void CL_WriteDemoMessage(void); // cl_input.c typedef struct { int down[2]; // key nums holding it down unsigned downtime; // msec timestamp unsigned msec; // msec down this frame int state; } kbutton_t; extern kbutton_t in_klook; extern kbutton_t in_strafe; extern kbutton_t in_speed; void CL_InitInput(void); void CL_RefreshCmd(void); void CL_SendCmd(void); // cl_keys.c void CL_ClearState(void); float CL_KeyState(kbutton_t *key); char *Key_KeynumToString(int keynum); // cl_parse.c extern centity_t cl_entities[MAX_EDICTS]; #define MAX_PARSE_ENTITIES 1024 extern entity_state_t cl_parse_entities[MAX_PARSE_ENTITIES]; extern netadr_t net_from; extern sizebuf_t net_message; extern char *svc_strings[256]; qboolean CL_CheckOrDownloadFile(char *filename); void CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits); unsigned int CL_ParseEntityBits(unsigned int *bits); void CL_ParseFrame(int extrabits); void CL_ParseConfigString(void); void CL_ParseClientinfo(int player); void CL_ParseMuzzleFlash(void); void CL_ParseMuzzleFlash2(void); void CL_ParseServerMessage(void); void CL_ParseTEnt(void); void CL_LoadClientinfo(clientinfo_t *ci, char *s); void CL_ShowNet(char *s); void CL_Download_f(void); // cl_view.c void V_Init(void); void V_RegisterViewMedia(void); void V_AddEntity(entity_t *ent); void V_AddParticle(vec3_t org, int color, float alpha); void V_UpdateView(void); // cl_pred.c void CL_PredictMovement(void); void CL_CheckPredictionError(void); // cl_fx.c typedef struct particle_s { struct particle_s *next; float time; vec3_t org; vec3_t vel; vec3_t accel; float color; float colorvel; float alpha; float alphavel; } cparticle_t; #define PARTICLE_GRAVITY 120 void CL_AddParticles(void); void CL_BFGParticles(entity_t *ent); void CL_BigTeleportParticles(vec3_t org); void CL_BlasterTrail(vec3_t start, vec3_t end); void CL_BubbleTrail(vec3_t start, vec3_t end); void CL_ClearEffects(void); void CL_DiminishingTrail(vec3_t start, vec3_t end, centity_t *old, int flags); void CL_EntityEvent(entity_state_t *ent); void CL_FlagTrail(vec3_t start, vec3_t end, float color); void CL_FlyEffect(centity_t *ent, vec3_t origin); void CL_ParticleEffect(vec3_t org, vec3_t dir, int color, int count); void CL_ParticleEffect2(vec3_t org, vec3_t dir, int color, int count); void CL_ParticleEffect3(vec3_t org, vec3_t dir, int color, int count); void CL_QuadTrail(vec3_t start, vec3_t end); void CL_RailTrail(vec3_t start, vec3_t end); void CL_RocketTrail(vec3_t start, vec3_t end, centity_t *old); void CL_TeleporterParticles(entity_state_t *ent); // cl_inv.c void CL_ParseInventory(void); void CL_DrawInventory(void); // gl_sdl.c extern void IN_HandleEvents(void); #endif /* __CLIENT_H__ */