2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
client.h
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
Client definitions
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
#include "QF/input.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/sound.h"
|
2001-11-27 21:42:49 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-11-27 21:42:49 +00:00
|
|
|
#include "game.h"
|
2003-02-11 22:48:57 +00:00
|
|
|
#include "netmain.h"
|
2001-05-18 18:33:37 +00:00
|
|
|
#include "protocol.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
#include "r_local.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct usercmd_s
|
|
|
|
{
|
|
|
|
vec3_t viewangles;
|
|
|
|
|
|
|
|
// intended velocities
|
|
|
|
float forwardmove;
|
|
|
|
float sidemove;
|
|
|
|
float upmove;
|
|
|
|
} usercmd_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char name[MAX_SCOREBOARDNAME];
|
|
|
|
float entertime;
|
|
|
|
int frags;
|
|
|
|
int colors; // two 4 bit fields
|
2001-05-27 04:23:39 +00:00
|
|
|
int _colors;
|
2001-08-25 05:54:21 +00:00
|
|
|
byte translations[4*VID_GRADES*256]; // space for colormap32
|
2001-02-19 21:15:25 +00:00
|
|
|
} scoreboard_t;
|
|
|
|
|
|
|
|
#define NAME_LENGTH 64
|
|
|
|
|
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// client_state_t should hold all pieces of the client state
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#define SIGNONS 4 // signon messages to receive before connected
|
|
|
|
|
|
|
|
#define MAX_DEMOS 8
|
|
|
|
#define MAX_DEMONAME 16
|
2001-05-18 18:33:37 +00:00
|
|
|
#define MAX_MAPSTRING 2048
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2001-05-18 18:33:37 +00:00
|
|
|
ca_dedicated, // a dedicated server with no ability to start a client
|
|
|
|
ca_disconnected, // full screen console with no connection
|
|
|
|
ca_connected // valid netcon, talking to a server
|
2001-02-19 21:15:25 +00:00
|
|
|
} cactive_t;
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
typedef enum {
|
|
|
|
dl_none,
|
|
|
|
dl_model,
|
|
|
|
dl_sound,
|
|
|
|
dl_skin,
|
|
|
|
dl_single
|
|
|
|
} dltype_t; // download type
|
|
|
|
|
2001-02-28 08:53:17 +00:00
|
|
|
// FIXME: A grotesque (temporary) hack. They're not the same thing to QW.
|
|
|
|
#define ca_active ca_connected
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
cactive_t state;
|
|
|
|
|
|
|
|
// personalization data sent to server
|
|
|
|
char mapstring[MAX_QPATH];
|
|
|
|
char spawnparms[MAX_MAPSTRING]; // to restart a level
|
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
// file transfer from server
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *download;
|
2010-08-24 07:20:07 +00:00
|
|
|
char *downloadtempname;
|
|
|
|
char *downloadname;
|
2001-05-18 18:33:37 +00:00
|
|
|
int downloadnumber;
|
|
|
|
dltype_t downloadtype;
|
|
|
|
int downloadpercent;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// 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;
|
|
|
|
qboolean timedemo;
|
|
|
|
int forcetrack; // -1 = use normal cd track
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *demofile;
|
2001-02-19 21:15:25 +00:00
|
|
|
int 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
|
|
|
|
|
|
|
|
// connection information
|
|
|
|
int signon; // 0 to SIGNONS
|
|
|
|
struct qsocket_s *netcon;
|
|
|
|
sizebuf_t message; // writing buffer to send to server
|
|
|
|
|
|
|
|
} 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
|
|
|
|
{
|
2002-09-12 22:09:55 +00:00
|
|
|
int movemessages; // Since connecting to this server throw out
|
|
|
|
// the first couple, so the player doesn't
|
|
|
|
// accidentally do something the first frame
|
|
|
|
usercmd_t cmd; // Last command sent to the server
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// information for local display
|
2002-09-12 22:09:55 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
// The client maintains its own idea of view angles, which are sent to the
|
|
|
|
// server each frame. The server sets punchangle when the view is temporarily
|
|
|
|
// offset, and an angle reset commands at the start of each level and after
|
|
|
|
// teleporting.
|
|
|
|
vec3_t mviewangles[2]; // During demo playback viewangles is lerped
|
2001-02-19 21:15:25 +00:00
|
|
|
// between these
|
|
|
|
vec3_t viewangles;
|
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
vec3_t mvelocity[2]; // Update by server, used for lean+bob
|
2001-02-19 21:15:25 +00:00
|
|
|
// (0 is newest)
|
2002-09-12 22:09:55 +00:00
|
|
|
vec3_t velocity; // Lerped between mvelocity[0] and [1]
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
vec3_t punchangle; // Temporary offset
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// pitch drifting vars
|
|
|
|
float idealpitch;
|
|
|
|
float pitchvel;
|
|
|
|
qboolean nodrift;
|
|
|
|
float driftmove;
|
|
|
|
double laststop;
|
|
|
|
|
|
|
|
float viewheight;
|
2002-09-12 22:09:55 +00:00
|
|
|
float crouch; // Local amount for smoothing stepups
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
qboolean paused; // Send over by server
|
2001-02-19 21:15:25 +00:00
|
|
|
qboolean onground;
|
|
|
|
qboolean inwater;
|
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
int intermission; // Don't change view angle, full screen, etc
|
|
|
|
int completed_time; // Latched at intermission start
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
double mtime[2]; // The timestamp of last two messages
|
|
|
|
double time; // Clients view of time, should be between
|
|
|
|
// servertime and oldservertime to generate a
|
|
|
|
// lerp point for other data
|
|
|
|
double oldtime; // Previous cl.time, time-oldtime is used
|
2001-02-19 21:15:25 +00:00
|
|
|
// to decay light values and smooth step ups
|
|
|
|
|
|
|
|
float last_received_message; // (realtime) for net trouble icon
|
|
|
|
|
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
|
|
|
struct model_s *model_precache[MAX_MODELS];
|
|
|
|
struct sfx_s *sound_precache[MAX_SOUNDS];
|
|
|
|
|
|
|
|
char levelname[40]; // for display on solo scoreboard
|
|
|
|
int viewentity; // cl_entitites[cl.viewentity] = player
|
|
|
|
int maxclients;
|
|
|
|
int gametype;
|
|
|
|
|
|
|
|
// refresh related state
|
|
|
|
struct model_s *worldmodel; // cl_entitites[0].model
|
|
|
|
int num_entities; // held in cl_entities array
|
|
|
|
int num_statics; // held in cl_staticentities array
|
|
|
|
entity_t viewent; // the gun model
|
|
|
|
|
|
|
|
int cdtrack, looptrack; // cd audio
|
|
|
|
|
|
|
|
// frag scoreboard
|
|
|
|
scoreboard_t *scores; // [cl.maxclients]
|
2010-08-24 00:53:54 +00:00
|
|
|
|
|
|
|
unsigned protocol;
|
2001-02-19 21:15:25 +00:00
|
|
|
} client_state_t;
|
|
|
|
|
|
|
|
|
2001-11-27 21:42:49 +00:00
|
|
|
typedef struct cl_entity_state_s {
|
|
|
|
entity_t *ent;
|
|
|
|
entity_state_t baseline;
|
|
|
|
int forcelink;
|
|
|
|
vec3_t msg_origins[2];
|
|
|
|
vec3_t msg_angles[2];
|
|
|
|
double msgtime;
|
|
|
|
int effects;
|
|
|
|
int colors;
|
|
|
|
struct model_s *model;
|
|
|
|
int skinnum;
|
2002-09-12 22:09:55 +00:00
|
|
|
byte alpha;
|
|
|
|
byte scale;
|
|
|
|
byte colormod;
|
|
|
|
byte glow_size;
|
|
|
|
byte glow_color;
|
2001-11-27 21:42:49 +00:00
|
|
|
} cl_entity_state_t;
|
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
|
|
|
|
// cvars
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_name;
|
|
|
|
extern struct cvar_s *cl_color;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +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;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_movespeedkey;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_yawspeed;
|
|
|
|
extern struct cvar_s *cl_pitchspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_anglespeedkey;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_autofire;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_shownet;
|
|
|
|
extern struct cvar_s *cl_nolerp;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-05-09 20:30:50 +00:00
|
|
|
extern struct cvar_s *hud_sbar;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_pitchdriftspeed;
|
|
|
|
extern struct cvar_s *lookspring;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
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-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
extern struct cvar_s *cl_name;
|
2001-10-28 04:23:37 +00:00
|
|
|
extern struct cvar_s *cl_writecfg;
|
|
|
|
|
|
|
|
extern struct cvar_s *cl_cshift_bonus;
|
|
|
|
extern struct cvar_s *cl_cshift_contents;
|
|
|
|
extern struct cvar_s *cl_cshift_damage;
|
|
|
|
extern struct cvar_s *cl_cshift_powerup;
|
|
|
|
|
|
|
|
extern struct cvar_s *noskins;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
#define MAX_STATIC_ENTITIES 512 // torches, etc
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern client_state_t cl;
|
|
|
|
|
|
|
|
// FIXME, allocate dynamically
|
|
|
|
extern entity_t cl_entities[MAX_EDICTS];
|
2001-11-27 21:42:49 +00:00
|
|
|
extern cl_entity_state_t cl_baselines[MAX_EDICTS];
|
2001-02-19 21:15:25 +00:00
|
|
|
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
extern int fps_count;
|
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
extern void (*write_angles) (sizebuf_t *sb, const vec3_t angles);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// cl_main
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_Init (void);
|
|
|
|
void CL_InitCvars (void);
|
|
|
|
|
2001-07-15 07:04:17 +00:00
|
|
|
void CL_EstablishConnection (const char *host);
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_Signon1 (void);
|
|
|
|
void CL_Signon2 (void);
|
|
|
|
void CL_Signon3 (void);
|
|
|
|
void CL_Signon4 (void);
|
|
|
|
|
|
|
|
void CL_Disconnect (void);
|
|
|
|
void CL_Disconnect_f (void);
|
|
|
|
void CL_NextDemo (void);
|
|
|
|
|
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// cl_input
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_InitInput (void);
|
|
|
|
void CL_SendCmd (void);
|
|
|
|
void CL_SendMove (usercmd_t *cmd);
|
|
|
|
|
2001-05-18 19:58:49 +00:00
|
|
|
void CL_ParseParticleEffect (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_ParseTEnt (void);
|
|
|
|
void CL_UpdateTEnts (void);
|
|
|
|
|
|
|
|
void CL_ClearState (void);
|
|
|
|
|
|
|
|
int CL_ReadFromServer (void);
|
|
|
|
void CL_WriteToServer (usercmd_t *cmd);
|
|
|
|
void CL_BaseMove (usercmd_t *cmd);
|
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
float CL_KeyState (kbutton_t *key);
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// cl_demo.c
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_StopPlayback (void);
|
|
|
|
int CL_GetMessage (void);
|
|
|
|
|
|
|
|
void CL_Stop_f (void);
|
|
|
|
void CL_Record_f (void);
|
|
|
|
void CL_PlayDemo_f (void);
|
|
|
|
void CL_TimeDemo_f (void);
|
2002-06-08 23:22:26 +00:00
|
|
|
void CL_Demo_Init (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-08 23:22:26 +00:00
|
|
|
extern struct cvar_s *demo_gzip;
|
|
|
|
extern struct cvar_s *demo_speed;
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// cl_parse.c
|
2001-05-21 22:25:35 +00:00
|
|
|
struct skin_s;
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_ParseServerMessage (void);
|
2001-05-21 22:25:35 +00:00
|
|
|
void CL_NewTranslation (int slot, struct skin_s *skin);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-18 18:33:37 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// view
|
2001-02-19 21:15:25 +00:00
|
|
|
void V_StartPitchDrift (void);
|
|
|
|
void V_StopPitchDrift (void);
|
|
|
|
|
|
|
|
void V_RenderView (void);
|
|
|
|
void V_UpdatePalette (void);
|
|
|
|
void V_Register (void);
|
|
|
|
void V_ParseDamage (void);
|
|
|
|
void V_SetContentsColor (int contents);
|
2001-10-28 04:23:37 +00:00
|
|
|
void V_PrepBlend (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-09-12 22:09:55 +00:00
|
|
|
// cl_tent
|
2001-05-15 21:34:54 +00:00
|
|
|
void CL_TEnts_Init (void);
|
|
|
|
void CL_ClearEnts (void);
|
|
|
|
void CL_ClearTEnts (void);
|
|
|
|
void CL_Init_Entity (struct entity_s *ent);
|
|
|
|
void CL_ParseTEnt (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_SignonReply (void);
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
extern kbutton_t in_left, in_right, in_forward, in_back;
|
|
|
|
extern kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
|
|
|
extern kbutton_t in_use, in_jump, in_attack;
|
|
|
|
extern kbutton_t in_up, in_down;
|
2001-05-18 18:33:37 +00:00
|
|
|
|
|
|
|
extern double realtime;
|
|
|
|
|
2001-10-29 17:46:03 +00:00
|
|
|
extern qboolean recording;
|
|
|
|
|
2001-03-31 01:02:52 +00:00
|
|
|
void Cvar_Info (struct cvar_s *var);
|
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
void CL_UpdateScreen (double realtime);
|
|
|
|
|
2001-08-20 17:48:16 +00:00
|
|
|
void CL_SetState (cactive_t state);
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
void CL_Cmd_ForwardToServer (void);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif // __client_h
|