2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
client.h
|
|
|
|
|
|
|
|
Client definitions
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CLIENT_H
|
|
|
|
#define _CLIENT_H
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/info.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/vid.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/zone.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-02-11 22:48:57 +00:00
|
|
|
#include "netchan.h"
|
2004-02-21 02:31:22 +00:00
|
|
|
#include "qw/protocol.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
#include "r_local.h"
|
2001-05-19 00:23:21 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
player_state_t is the information needed by a player entity
|
|
|
|
to do move prediction and to generate a drawable entity
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct player_state_s {
|
|
|
|
int messagenum; // all player's won't be updated each frame
|
|
|
|
|
|
|
|
double state_time; // not the same as the packet time,
|
|
|
|
// because player commands come asyncronously
|
|
|
|
usercmd_t command; // last command for prediction
|
|
|
|
|
|
|
|
vec3_t origin;
|
|
|
|
vec3_t viewangles; // only for demos, not from server
|
|
|
|
vec3_t velocity;
|
|
|
|
int weaponframe;
|
|
|
|
|
|
|
|
int number;
|
|
|
|
int modelindex;
|
|
|
|
int frame;
|
|
|
|
int skinnum;
|
|
|
|
int effects;
|
|
|
|
|
|
|
|
int flags; // dead, gib, etc
|
|
|
|
|
|
|
|
float waterjumptime;
|
|
|
|
int onground; // -1 = in air, else pmove entity number
|
|
|
|
int oldbuttons;
|
2002-09-13 04:30:18 +00:00
|
|
|
int oldonground;
|
2002-06-18 21:41:24 +00:00
|
|
|
|
|
|
|
// QSG2
|
|
|
|
byte glow_size;
|
|
|
|
byte glow_color;
|
2001-02-19 21:15:25 +00:00
|
|
|
} player_state_t;
|
|
|
|
|
2001-02-21 19:53:41 +00:00
|
|
|
#undef MAX_SCOREBOARDNAME
|
2001-02-19 21:15:25 +00:00
|
|
|
#define MAX_SCOREBOARDNAME 16
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct player_info_s
|
|
|
|
{
|
|
|
|
int userid;
|
2001-11-04 07:50:39 +00:00
|
|
|
struct info_s *userinfo;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// scoreboard information
|
2001-12-03 05:36:39 +00:00
|
|
|
char name[MAX_SCOREBOARDNAME];
|
2001-02-19 21:15:25 +00:00
|
|
|
float entertime;
|
|
|
|
int frags;
|
|
|
|
int ping;
|
|
|
|
byte pl;
|
|
|
|
|
|
|
|
// skin information
|
|
|
|
int topcolor;
|
|
|
|
int bottomcolor;
|
2001-11-04 19:06:50 +00:00
|
|
|
struct info_key_s *skinname;
|
|
|
|
struct info_key_s *team;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
int _topcolor;
|
|
|
|
int _bottomcolor;
|
|
|
|
|
|
|
|
int spectator;
|
2001-08-25 05:54:21 +00:00
|
|
|
byte translations[4*VID_GRADES*256]; // space for colormap32
|
2001-08-27 21:13:00 +00:00
|
|
|
int translationcolor[256];
|
2001-02-19 21:15:25 +00:00
|
|
|
struct skin_s *skin;
|
2002-10-02 21:56:45 +00:00
|
|
|
int stats[MAX_CL_STATS]; // health, etc
|
|
|
|
int prevcount;
|
2001-02-19 21:15:25 +00:00
|
|
|
} player_info_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// generated on client side
|
|
|
|
usercmd_t cmd; // cmd that generated the frame
|
|
|
|
double senttime; // time cmd was sent off
|
|
|
|
int delta_sequence; // sequence number to delta from, -1 = full update
|
|
|
|
|
|
|
|
// received from server
|
|
|
|
double receivedtime; // time message was received, or -1
|
2001-05-18 18:33:37 +00:00
|
|
|
player_state_t playerstate[MAX_CLIENTS]; // message received that
|
|
|
|
// reflects performing the
|
|
|
|
// usercmd
|
2001-02-19 21:15:25 +00:00
|
|
|
packet_entities_t packet_entities;
|
|
|
|
qboolean invalid; // true if the packet_entities delta was invalid
|
|
|
|
} frame_t;
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_DEMOS 8
|
|
|
|
#define MAX_DEMONAME 16
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2001-05-18 18:33:37 +00:00
|
|
|
ca_disconnected, // full screen console with no connection
|
|
|
|
ca_demostart, // starting up a demo
|
|
|
|
ca_connected, // netchan_t established, waiting for svc_serverdata
|
|
|
|
ca_onserver, // processing data lists, donwloading, etc
|
|
|
|
ca_active // everything is in, so frames can be rendered
|
2001-02-19 21:15:25 +00:00
|
|
|
} cactive_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
dl_none,
|
|
|
|
dl_model,
|
|
|
|
dl_sound,
|
|
|
|
dl_skin,
|
|
|
|
dl_single
|
|
|
|
} dltype_t; // download type
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
/*
|
|
|
|
the client_static_t structure is persistant through an arbitrary number
|
|
|
|
of server connections
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// connection information
|
|
|
|
cactive_t state;
|
|
|
|
|
|
|
|
// network stuff
|
|
|
|
netchan_t netchan;
|
|
|
|
|
|
|
|
// private userinfo for sending to masterless servers
|
2001-11-04 07:50:39 +00:00
|
|
|
struct info_s *userinfo;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
char servername[MAX_OSPATH]; // name of server from original connect
|
2001-12-05 21:56:52 +00:00
|
|
|
netadr_t server_addr; // address of server
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
int qport;
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
// file transfer from server
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *download;
|
2001-02-19 21:15:25 +00:00
|
|
|
char downloadtempname[MAX_OSPATH];
|
|
|
|
char downloadname[MAX_OSPATH];
|
|
|
|
int downloadnumber;
|
|
|
|
dltype_t downloadtype;
|
|
|
|
int downloadpercent;
|
|
|
|
|
|
|
|
// demo loop control
|
|
|
|
int demonum; // -1 = don't play demos
|
|
|
|
char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
|
|
|
|
|
|
|
|
// demo recording info must be here, because record is started before
|
|
|
|
// entering a map (and clearing client_state_t)
|
|
|
|
qboolean demorecording;
|
|
|
|
qboolean demoplayback;
|
2002-10-02 21:56:45 +00:00
|
|
|
qboolean demoplayback2;
|
|
|
|
qboolean findtrack;
|
|
|
|
int lastto;
|
|
|
|
int lasttype;
|
|
|
|
int prevtime;
|
|
|
|
double basetime;
|
2001-02-19 21:15:25 +00:00
|
|
|
qboolean timedemo;
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *demofile;
|
2001-02-19 21:15:25 +00:00
|
|
|
float td_lastframe; // to meter out one message a frame
|
|
|
|
int td_startframe; // host_framecount at start
|
|
|
|
float td_starttime; // realtime at second frame of timedemo
|
|
|
|
|
|
|
|
int challenge;
|
|
|
|
|
|
|
|
float latency; // rolling average
|
|
|
|
} client_static_t;
|
|
|
|
|
|
|
|
extern client_static_t cls;
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
/*
|
|
|
|
the client_state_t structure is wiped completely at every server signon
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int servercount; // server identification for prespawns
|
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
struct info_s *serverinfo;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
int parsecount; // server message counter
|
|
|
|
int validsequence; // this is the sequence number of the last good
|
|
|
|
// packetentity_t we got. If this is 0, we can't
|
|
|
|
// render a frame yet
|
|
|
|
int movemessages; // since connecting to this server
|
|
|
|
// throw out the first couple, so the player
|
|
|
|
// doesn't accidentally do something the
|
|
|
|
// first frame
|
|
|
|
|
|
|
|
int spectator;
|
|
|
|
|
|
|
|
double last_ping_request; // while showing scoreboard
|
|
|
|
double last_servermessage;
|
|
|
|
|
|
|
|
// sentcmds[cl.netchan.outgoing_sequence & UPDATE_MASK] = cmd
|
|
|
|
frame_t frames[UPDATE_BACKUP];
|
|
|
|
|
|
|
|
// information for local display
|
|
|
|
int stats[MAX_CL_STATS]; // health, etc
|
|
|
|
float item_gettime[32]; // cl.time of aquiring item, for blinking
|
|
|
|
float faceanimtime; // use anim frame if cl.time < this
|
|
|
|
|
|
|
|
cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
|
|
|
|
cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
// the client maintains its own idea of view angles, which are sent to the
|
|
|
|
// server each frame. And only reset at level change and teleport times
|
2001-02-19 21:15:25 +00:00
|
|
|
vec3_t viewangles;
|
|
|
|
|
|
|
|
// the client simulates or interpolates movement to get these values
|
|
|
|
double time; // this is the time value that the client
|
2001-02-23 05:44:57 +00:00
|
|
|
// is rendering at. always <= realtime
|
2001-02-19 21:15:25 +00:00
|
|
|
vec3_t simorg;
|
|
|
|
vec3_t simvel;
|
|
|
|
vec3_t simangles;
|
|
|
|
|
|
|
|
// pitch drifting vars
|
|
|
|
float pitchvel;
|
|
|
|
qboolean nodrift;
|
|
|
|
float driftmove;
|
|
|
|
double laststop;
|
|
|
|
|
|
|
|
int onground; // -1 when in air
|
|
|
|
float crouch; // local amount for smoothing stepups
|
|
|
|
|
|
|
|
qboolean paused; // send over by server
|
|
|
|
|
|
|
|
float punchangle; // temporar yview kick from weapon firing
|
|
|
|
|
|
|
|
int intermission; // don't change view angle, full screen, etc
|
|
|
|
int completed_time; // latched ffrom time at intermission start
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
/* information that is static for the entire time connected to a server */
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
char model_name[MAX_MODELS][MAX_QPATH];
|
|
|
|
char sound_name[MAX_SOUNDS][MAX_QPATH];
|
|
|
|
|
|
|
|
struct model_s *model_precache[MAX_MODELS];
|
|
|
|
struct sfx_s *sound_precache[MAX_SOUNDS];
|
|
|
|
|
|
|
|
char levelname[40]; // for display on solo scoreboard
|
|
|
|
int playernum;
|
2001-03-27 22:30:25 +00:00
|
|
|
int viewentity;
|
2001-09-11 03:50:24 +00:00
|
|
|
float stdver;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-10-01 01:51:36 +00:00
|
|
|
// serverinfo mirrors
|
|
|
|
int chase;
|
2001-11-11 07:02:38 +00:00
|
|
|
int sv_cshifts;
|
2001-11-04 19:06:50 +00:00
|
|
|
int no_pogo_stick;
|
|
|
|
int teamplay;
|
|
|
|
int watervis;
|
2001-10-01 01:51:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// refresh related state
|
|
|
|
struct model_s *worldmodel; // cl_entitites[0].model
|
|
|
|
int num_entities; // stored bottom up in cl_entities array
|
|
|
|
int num_statics; // stored top down in cl_entitiers
|
|
|
|
|
|
|
|
int cdtrack; // cd audio
|
|
|
|
|
|
|
|
entity_t viewent; // weapon model
|
|
|
|
|
|
|
|
// all player information
|
|
|
|
player_info_t players[MAX_CLIENTS];
|
|
|
|
} client_state_t;
|
|
|
|
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
/*
|
|
|
|
cvars
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
extern struct cvar_s *cl_upspeed;
|
|
|
|
extern struct cvar_s *cl_forwardspeed;
|
|
|
|
extern struct cvar_s *cl_backspeed;
|
|
|
|
extern struct cvar_s *cl_sidespeed;
|
|
|
|
|
|
|
|
extern struct cvar_s *cl_movespeedkey;
|
|
|
|
|
|
|
|
extern struct cvar_s *cl_yawspeed;
|
|
|
|
extern struct cvar_s *cl_pitchspeed;
|
|
|
|
|
|
|
|
extern struct cvar_s *cl_anglespeedkey;
|
|
|
|
|
|
|
|
extern struct cvar_s *cl_shownet;
|
2003-05-09 20:30:50 +00:00
|
|
|
extern struct cvar_s *hud_sbar;
|
|
|
|
extern struct cvar_s *hud_sbar_separator;
|
|
|
|
extern struct cvar_s *hud_swap;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern struct cvar_s *cl_pitchdriftspeed;
|
|
|
|
extern struct cvar_s *lookspring;
|
|
|
|
|
|
|
|
extern struct cvar_s *m_pitch;
|
|
|
|
extern struct cvar_s *m_yaw;
|
|
|
|
extern struct cvar_s *m_forward;
|
|
|
|
extern struct cvar_s *m_side;
|
|
|
|
|
2001-05-13 04:01:06 +00:00
|
|
|
extern struct cvar_s *cl_name;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-02 23:29:41 +00:00
|
|
|
extern struct cvar_s *cl_model_crcs;
|
|
|
|
|
2002-04-25 16:50:56 +00:00
|
|
|
extern struct cvar_s *rate;
|
|
|
|
|
2003-07-27 23:20:11 +00:00
|
|
|
extern struct cvar_s *hud_ping;
|
|
|
|
extern struct cvar_s *hud_pl;
|
2001-08-11 04:14:58 +00:00
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
extern struct cvar_s *skin;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#define MAX_STATIC_ENTITIES 128 // torches, etc
|
|
|
|
|
|
|
|
extern client_state_t cl;
|
|
|
|
|
|
|
|
// FIXME, allocate dynamically
|
|
|
|
extern entity_state_t cl_baselines[MAX_EDICTS];
|
|
|
|
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|
|
|
|
|
|
|
extern qboolean nomaster;
|
|
|
|
extern char *server_version; // version of server we connected to
|
|
|
|
|
2001-04-10 06:55:28 +00:00
|
|
|
extern double realtime;
|
2003-05-08 05:49:57 +00:00
|
|
|
extern int fps_count;
|
2001-04-10 06:55:28 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
extern struct cbuf_s *cl_cbuf;
|
2002-12-01 07:22:42 +00:00
|
|
|
extern struct cbuf_s *cl_stbuf;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-31 01:02:52 +00:00
|
|
|
void Cvar_Info (struct cvar_s *var);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-09 14:05:30 +00:00
|
|
|
void CL_NetGraph (void);
|
2001-05-23 06:33:23 +00:00
|
|
|
void CL_UpdateScreen (double realtime);
|
|
|
|
|
2001-08-19 03:51:52 +00:00
|
|
|
void CL_SetState (cactive_t state);
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
void V_ParseDamage (void);
|
2001-11-05 20:13:27 +00:00
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
void V_PrepBlend (void);
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
void CL_Cmd_ForwardToServer (void);
|
|
|
|
void CL_Cmd_Init (void);
|
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
void CL_RSShot_f (void);
|
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
#define RSSHOT_WIDTH 320
|
|
|
|
#define RSSHOT_HEIGHT 200
|
2001-05-22 06:00:38 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif // _CLIENT_H
|