1 /* 2 Copyright (C) 1996-2001 Id Software, Inc. 3 Copyright (C) 2002-2009 John Fitzgibbons and others 4 Copyright (C) 2010-2014 QuakeSpasm developers 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 15 See the GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 21 */ 22 23 #ifndef _CLIENT_H_ 24 #define _CLIENT_H_ 25 26 // client.h 27 28 typedef struct 29 { 30 int length; 31 char map[MAX_STYLESTRING]; 32 char average; //johnfitz 33 char peak; //johnfitz 34 } lightstyle_t; 35 36 typedef struct 37 { 38 char name[MAX_SCOREBOARDNAME]; 39 float entertime; 40 int frags; 41 int colors; // two 4 bit fields 42 int ping; 43 byte translations[VID_GRADES*256]; 44 45 char userinfo[8192]; 46 } scoreboard_t; 47 48 typedef struct 49 { 50 int destcolor[3]; 51 float percent; // 0-256 52 } cshift_t; 53 54 #define CSHIFT_CONTENTS 0 55 #define CSHIFT_DAMAGE 1 56 #define CSHIFT_BONUS 2 57 #define CSHIFT_POWERUP 3 58 #define NUM_CSHIFTS 4 59 60 #define NAME_LENGTH 64 61 62 63 // 64 // client_state_t should hold all pieces of the client state 65 // 66 67 #define SIGNONS 4 // signon messages to receive before connected 68 69 #define MAX_DLIGHTS 64 //johnfitz -- was 32 70 typedef struct 71 { 72 vec3_t origin; 73 float radius; 74 float die; // stop lighting after this time 75 float decay; // drop this each second 76 float minlight; // don't add when contributing less 77 int key; 78 vec3_t color; //johnfitz -- lit support via lordhavoc 79 } dlight_t; 80 81 82 #define MAX_BEAMS 32 //johnfitz -- was 24 83 typedef struct 84 { 85 int entity; 86 struct qmodel_s *model; 87 float endtime; 88 vec3_t start, end; 89 #ifdef PSET_SCRIPT 90 const char *trailname; 91 struct trailstate_s *trailstate; 92 #endif 93 } beam_t; 94 95 #define MAX_MAPSTRING 2048 96 #define MAX_DEMOS 8 97 #define MAX_DEMONAME 16 98 99 typedef enum { 100 ca_dedicated, // a dedicated server with no ability to start a client 101 ca_disconnected, // full screen console with no connection 102 ca_connected // valid netcon, talking to a server 103 } cactive_t; 104 105 // 106 // the client_static_t structure is persistant through an arbitrary number 107 // of server connections 108 // 109 typedef struct 110 { 111 cactive_t state; 112 113 // personalization data sent to server 114 char spawnparms[MAX_MAPSTRING]; // to restart a level 115 116 // demo loop control 117 int demonum; // -1 = don't play demos 118 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing 119 120 // demo recording info must be here, because record is started before 121 // entering a map (and clearing client_state_t) 122 qboolean demorecording; 123 qboolean demoplayback; 124 125 // did the user pause demo playback? (separate from cl.paused because we don't 126 // want a svc_setpause inside the demo to actually pause demo playback). 127 qboolean demopaused; 128 129 qboolean timedemo; 130 int forcetrack; // -1 = use normal cd track 131 FILE *demofile; 132 int td_lastframe; // to meter out one message a frame 133 int td_startframe; // host_framecount at start 134 float td_starttime; // realtime at second frame of timedemo 135 136 // connection information 137 int signon; // 0 to SIGNONS 138 struct qsocket_s *netcon; 139 sizebuf_t message; // writing buffer to send to server 140 141 char userinfo[8192]; 142 } client_static_t; 143 144 extern client_static_t cls; 145 146 // 147 // the client_state_t structure is wiped completely at every 148 // server signon 149 // 150 typedef struct 151 { 152 int movemessages; // since connecting to this server 153 // throw out the first couple, so the player 154 // doesn't accidentally do something the 155 // first frame 156 int ackedmovemessages; // echo of movemessages from the server. 157 usercmd_t movecmds[64]; // ringbuffer of previous movement commands (journal for prediction) 158 #define MOVECMDS_MASK (countof(cl.movecmds)-1) 159 usercmd_t pendingcmd; // accumulated state from mice+joysticks. 160 161 // information for local display 162 int stats[MAX_CL_STATS]; // health, etc 163 float statsf[MAX_CL_STATS]; 164 char *statss[MAX_CL_STATS]; 165 int items; // inventory bit flags 166 float item_gettime[32]; // cl.time of aquiring item, for blinking 167 float faceanimtime; // use anim frame if cl.time < this 168 169 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups 170 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types 171 172 // the client maintains its own idea of view angles, which are 173 // sent to the server each frame. The server sets punchangle when 174 // the view is temporarliy offset, and an angle reset commands at the start 175 // of each level and after teleporting. 176 vec3_t mviewangles[2]; // during demo playback viewangles is lerped 177 // between these 178 vec3_t viewangles; 179 180 vec3_t mvelocity[2]; // update by server, used for lean+bob 181 // (0 is newest) 182 vec3_t velocity; // lerped between mvelocity[0] and [1] 183 184 vec3_t punchangle; // temporary offset 185 186 // pitch drifting vars 187 float idealpitch; 188 float pitchvel; 189 qboolean nodrift; 190 float driftmove; 191 double laststop; 192 193 float viewheight; 194 float crouch; // local amount for smoothing stepups 195 196 qboolean paused; // send over by server 197 qboolean onground; 198 qboolean inwater; 199 200 int intermission; // don't change view angle, full screen, etc 201 int completed_time; // latched at intermission start 202 203 double mtime[2]; // the timestamp of last two messages 204 double time; // clients view of time, should be between 205 // servertime and oldservertime to generate 206 // a lerp point for other data 207 double oldtime; // previous cl.time, time-oldtime is used 208 // to decay light values and smooth step ups 209 210 211 float last_received_message; // (realtime) for net trouble icon 212 213 // 214 // information that is static for the entire time connected to a server 215 // 216 struct qmodel_s *model_precache[MAX_MODELS]; 217 struct sfx_s *sound_precache[MAX_SOUNDS]; 218 219 char mapname[128]; 220 char levelname[128]; // for display on solo scoreboard //johnfitz -- was 40. 221 int viewentity; // cl_entitites[cl.viewentity] = player 222 int maxclients; 223 int gametype; 224 225 // refresh related state 226 struct qmodel_s *worldmodel; // cl_entitites[0].model 227 struct efrag_s *free_efrags; 228 int num_efrags; 229 // int num_entities; // held in cl_entities array 230 // int num_statics; // held in cl_staticentities array 231 entity_t viewent; // the gun model 232 233 entity_t *entities; //spike -- moved into here 234 int max_edicts; 235 int num_entities; 236 237 entity_t **static_entities; //spike -- was static 238 int max_static_entities; 239 int num_statics; 240 241 int cdtrack, looptrack; // cd audio 242 243 // frag scoreboard 244 scoreboard_t *scores; // [cl.maxclients] 245 246 unsigned protocol; //johnfitz 247 unsigned protocolflags; 248 unsigned protocol_pext1; //spike -- flag of fte protocol extensions 249 unsigned protocol_pext2; //spike -- flag of fte protocol extensions 250 251 #ifdef PSET_SCRIPT 252 qboolean protocol_particles; 253 struct 254 { 255 const char *name; 256 int index; 257 } particle_precache[MAX_PARTICLETYPES]; 258 struct 259 { 260 const char *name; 261 int index; 262 } local_particle_precache[MAX_PARTICLETYPES]; 263 #endif 264 int ackframes[8]; //big enough to cover burst 265 unsigned int ackframes_count; 266 qboolean requestresend; 267 qboolean sendprespawn; 268 269 qcvm_t qcvm; //for csqc. 270 271 char serverinfo[8192]; // \key\value infostring data. 272 } client_state_t; 273 274 275 // 276 // cvars 277 // 278 extern cvar_t cl_name; 279 extern cvar_t cl_color; 280 281 extern cvar_t cl_upspeed; 282 extern cvar_t cl_forwardspeed; 283 extern cvar_t cl_backspeed; 284 extern cvar_t cl_sidespeed; 285 286 extern cvar_t cl_movespeedkey; 287 288 extern cvar_t cl_yawspeed; 289 extern cvar_t cl_pitchspeed; 290 291 extern cvar_t cl_anglespeedkey; 292 293 extern cvar_t cl_alwaysrun; // QuakeSpasm 294 295 extern cvar_t cl_autofire; 296 297 extern cvar_t cl_shownet; 298 extern cvar_t cl_nolerp; 299 300 extern cvar_t cfg_unbindall; 301 302 extern cvar_t cl_pitchdriftspeed; 303 extern cvar_t lookspring; 304 extern cvar_t lookstrafe; 305 extern cvar_t sensitivity; 306 307 extern cvar_t m_pitch; 308 extern cvar_t m_yaw; 309 extern cvar_t m_forward; 310 extern cvar_t m_side; 311 312 313 #define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64 314 315 extern client_state_t cl; 316 317 // FIXME, allocate dynamically 318 extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; 319 extern dlight_t cl_dlights[MAX_DLIGHTS]; 320 extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES]; 321 extern beam_t cl_beams[MAX_BEAMS]; 322 extern entity_t **cl_visedicts; 323 extern int cl_numvisedicts; 324 extern int cl_maxvisedicts; //extended if we exceeded it the previous frame 325 326 //============================================================================= 327 328 // 329 // cl_main 330 // 331 dlight_t *CL_AllocDlight (int key); 332 void CL_DecayLights (void); 333 334 void CL_Init (void); 335 336 void CL_EstablishConnection (const char *host); 337 void CL_Signon1 (void); 338 void CL_Signon2 (void); 339 void CL_Signon3 (void); 340 void CL_Signon4 (void); 341 342 void CL_Disconnect (void); 343 void CL_Disconnect_f (void); 344 void CL_NextDemo (void); 345 346 // 347 // cl_input 348 // 349 typedef struct 350 { 351 int down[2]; // key nums holding it down 352 int state; // low bit is down state 353 } kbutton_t; 354 355 extern kbutton_t in_mlook, in_klook; 356 extern kbutton_t in_strafe; 357 extern kbutton_t in_speed; 358 359 void CL_InitInput (void); 360 void CL_AccumulateCmd (void); 361 void CL_SendCmd (void); 362 void CL_SendMove (const usercmd_t *cmd); 363 int CL_ReadFromServer (void); 364 void CL_AdjustAngles (void); 365 void CL_BaseMove (usercmd_t *cmd); 366 void CL_FinishMove(usercmd_t *cmd); 367 368 void CL_UpdateBeam (struct qmodel_s *m, const char *trailname, const char *impactname, int ent, float *start, float *end); 369 void CL_ParseTEnt (void); 370 void CL_UpdateTEnts (void); 371 372 void CL_FreeState(void); 373 void CL_ClearState (void); 374 void CL_ClearTrailStates(void); 375 376 // 377 // cl_demo.c 378 // 379 void CL_StopPlayback (void); 380 int CL_GetMessage (void); 381 382 void CL_Stop_f (void); 383 void CL_Record_f (void); 384 void CL_PlayDemo_f (void); 385 void CL_TimeDemo_f (void); 386 387 // 388 // cl_parse.c 389 // 390 void CL_ParseServerMessage (void); 391 void CL_RegisterParticles(void); 392 void CL_NewTranslation (int slot); 393 394 // 395 // view 396 // 397 void V_StartPitchDrift (void); 398 void V_StopPitchDrift (void); 399 400 void V_RenderView (void); 401 //void V_UpdatePalette (void); //johnfitz 402 void V_Register (void); 403 void V_ParseDamage (void); 404 void V_SetContentsColor (int contents); 405 406 // 407 // cl_tent 408 // 409 void CL_InitTEnts (void); 410 void CL_SignonReply (void); 411 float CL_TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int *ent); 412 413 // 414 // chase 415 // 416 extern cvar_t chase_active; 417 418 void Chase_Init (void); 419 void TraceLine (vec3_t start, vec3_t end, vec3_t impact); 420 void Chase_UpdateForClient (void); //johnfitz 421 void Chase_UpdateForDrawing (void); //johnfitz 422 423 #endif /* _CLIENT_H_ */ 424 425