2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 typedef struct frameblend_s
29 // LordHavoc: nothing in this structure is persistant, it may be overwritten by the client every frame, for persistant data use entity_lerp_t.
30 typedef struct entity_render_s
36 // opacity (alpha) of the model
38 // size the model is shown
43 // current uninterpolated animation frame (for things which do not use interpolation)
45 // entity shirt and pants colors
47 // light, particles, etc
54 // these are copied from the persistent data
56 // frame that the model is interpolating from
58 // frame that the model is interpolating to
60 // interpolation factor, usually computed from frame2time
62 // time frame1 began playing (for framegroup animations)
64 // time frame2 began playing (for framegroup animations)
67 // calculated by the renderer (but not persistent)
69 // if visframe == r_framecount, it is visible
71 // calculated during R_AddModelEntities
73 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
74 frameblend_t frameblend[4];
78 typedef struct entity_persistent_s
91 // interpolated animation
93 // lerp resets when model changes
95 // frame that the model is interpolating from
97 // frame that the model is interpolating to
99 // interpolation factor, usually computed from frame2time
101 // time frame1 began playing (for framegroup animations)
103 // time frame2 began playing (for framegroup animations)
108 typedef struct entity_s
110 // baseline state (default values)
111 entity_state_t state_baseline;
112 // previous state (interpolating from this)
113 entity_state_t state_previous;
114 // current state (interpolating to this)
115 entity_state_t state_current;
117 // used for regenerating parts of render
118 entity_persistent_t persistent;
120 // the only data the renderer should know about
121 entity_render_t render;
129 // intended velocities
138 char map[MAX_STYLESTRING];
143 char name[MAX_SCOREBOARDNAME];
146 int colors; // two 4 bit fields
152 int percent; // 0-256
155 #define CSHIFT_CONTENTS 0
156 #define CSHIFT_DAMAGE 1
157 #define CSHIFT_BONUS 2
158 #define CSHIFT_POWERUP 3
159 #define NUM_CSHIFTS 4
161 #define NAME_LENGTH 64
165 // client_state_t should hold all pieces of the client state
168 #define SIGNONS 4 // signon messages to receive before connected
174 struct model_s *model;
180 #define MAX_MAPSTRING 2048
182 #define MAX_DEMONAME 16
186 ca_dedicated, // a dedicated server with no ability to start a client
187 ca_disconnected, // full screen console with no connection
188 ca_connected // valid netcon, talking to a server
193 // the client_static_t structure is persistant through an arbitrary number
194 // of server connections
200 // personalization data sent to server
201 char mapstring[MAX_QPATH];
202 char spawnparms[MAX_MAPSTRING]; // to restart a level
205 int demonum; // -1 = don't play demos
206 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
208 // demo recording info must be here, because record is started before
209 // entering a map (and clearing client_state_t)
210 qboolean demorecording;
211 qboolean demoplayback;
213 int forcetrack; // -1 = use normal cd track
215 int td_lastframe; // to meter out one message a frame
216 int td_startframe; // host_framecount at start
217 double td_starttime; // realtime at second frame of timedemo (LordHavoc: changed to double)
218 qboolean demopaused; // LordHavoc: pausedemo
221 // connection information
222 int signon; // 0 to SIGNONS
223 struct qsocket_s *netcon;
224 sizebuf_t message; // writing buffer to send to server
228 extern client_static_t cls;
231 // the client_state_t structure is wiped completely at every
236 int movemessages; // since connecting to this server
237 // throw out the first couple, so the player
238 // doesn't accidentally do something the
240 float sendnoptime; // send a clc_nop periodically until connected
241 usercmd_t cmd; // last command sent to the server
243 // information for local display
244 int stats[MAX_CL_STATS]; // health, etc
245 int items; // inventory bit flags
246 float item_gettime[32]; // cl.time of acquiring item, for blinking
247 float faceanimtime; // use anim frame if cl.time < this
249 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
250 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
252 // the client maintains its own idea of view angles, which are
253 // sent to the server each frame. The server sets punchangle when
254 // the view is temporarliy offset, and an angle reset commands at the start
255 // of each level and after teleporting.
256 vec3_t mviewangles[2]; // during demo playback viewangles is lerped
260 vec3_t mvelocity[2]; // update by server, used for lean+bob
262 vec3_t velocity; // lerped between mvelocity[0] and [1]
264 vec3_t punchangle; // temporary offset
265 vec3_t punchvector; // LordHavoc: origin view kick
267 // pitch drifting vars
275 float crouch; // local amount for smoothing stepups
277 qboolean paused; // send over by server
281 int intermission; // don't change view angle, full screen, etc
282 int completed_time; // latched at intermission start
284 double mtime[2]; // the timestamp of last two messages
285 double time; // clients view of time, should be between
286 // servertime and oldservertime to generate
287 // a lerp point for other data
288 double oldtime; // previous cl.time, time-oldtime is used
289 // to decay light values and smooth step ups
294 float last_received_message; // (realtime) for net trouble icon
297 // information that is static for the entire time connected to a server
299 struct model_s *model_precache[MAX_MODELS];
300 struct sfx_s *sound_precache[MAX_SOUNDS];
302 char levelname[40]; // for display on solo scoreboard
303 int viewentity; // cl_entitites[cl.viewentity] = player
307 // refresh related state
308 struct model_s *worldmodel; // cl_entitites[0].model
309 // int num_entities; // held in cl_entities array
310 int num_statics; // held in cl_staticentities array
311 entity_t viewent; // the gun model
313 int cdtrack, looptrack; // cd audio
316 scoreboard_t *scores; // [cl.maxclients]
318 vec3_t viewentorigin;
319 float viewzoom; // LordHavoc: sniping zoom, QC controlled
320 float viewzoomold, viewzoomnew; // for interpolation
322 // entity database stuff
323 vec3_t viewentoriginold, viewentoriginnew;
324 entity_database_t entitydatabase;
328 extern mempool_t *cl_scores_mempool;
333 extern cvar_t cl_name;
334 extern cvar_t cl_color;
335 extern cvar_t cl_pmodel;
337 extern cvar_t cl_upspeed;
338 extern cvar_t cl_forwardspeed;
339 extern cvar_t cl_backspeed;
340 extern cvar_t cl_sidespeed;
342 extern cvar_t cl_movespeedkey;
344 extern cvar_t cl_yawspeed;
345 extern cvar_t cl_pitchspeed;
347 extern cvar_t cl_anglespeedkey;
349 extern cvar_t cl_autofire;
351 extern cvar_t cl_shownet;
352 extern cvar_t cl_nolerp;
354 extern cvar_t cl_pitchdriftspeed;
355 extern cvar_t lookspring;
356 extern cvar_t lookstrafe;
357 extern cvar_t sensitivity;
359 extern cvar_t freelook;
361 extern cvar_t m_pitch;
363 extern cvar_t m_forward;
364 extern cvar_t m_side;
367 // LordHavoc: raised these from 64 and 128 to 512 and 256
368 #define MAX_TEMP_ENTITIES 512 // lightning bolts, effects, etc
369 #define MAX_STATIC_ENTITIES 256 // torches, etc
371 extern client_state_t cl;
373 // FIXME, allocate dynamically
374 extern entity_t cl_entities[MAX_EDICTS];
375 extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
376 extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
377 extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
378 extern beam_t cl_beams[MAX_BEAMS];
380 #include "cl_light.h"
382 //=============================================================================
390 void CL_EstablishConnection (char *host);
392 void CL_Disconnect (void);
393 void CL_Disconnect_f (void);
400 int down[2]; // key nums holding it down
401 int state; // low bit is down state
405 extern kbutton_t in_mlook, in_klook;
406 extern kbutton_t in_strafe;
407 extern kbutton_t in_speed;
409 void CL_InitInput (void);
410 void CL_SendCmd (void);
411 void CL_SendMove (usercmd_t *cmd);
413 void CL_LerpUpdate(entity_t *e);
414 void CL_ParseTEnt (void);
415 void CL_UpdateTEnts (void);
417 entity_t *CL_NewTempEntity (void);
419 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
421 void CL_ClearState (void);
424 int CL_ReadFromServer (void);
425 void CL_WriteToServer (usercmd_t *cmd);
426 void CL_BaseMove (usercmd_t *cmd);
429 float CL_KeyState (kbutton_t *key);
430 char *Key_KeynumToString (int keynum);
435 void CL_StopPlayback (void);
436 int CL_GetMessage (void);
438 void CL_NextDemo (void);
439 void CL_Stop_f (void);
440 void CL_Record_f (void);
441 void CL_PlayDemo_f (void);
442 void CL_TimeDemo_f (void);
447 void CL_Parse_Init(void);
448 void CL_ParseServerMessage(void);
449 void CL_BitProfile_f(void);
454 void V_StartPitchDrift (void);
455 void V_StopPitchDrift (void);
458 float V_CalcRoll (vec3_t angles, vec3_t velocity);
459 void V_UpdateBlends (void);
460 void V_ParseDamage (void);
466 void CL_InitTEnts (void);
472 #define PARTICLE_INVALID 0
473 #define PARTICLE_BILLBOARD 1
474 #define PARTICLE_UPRIGHT_FACING 2
475 #define PARTICLE_ORIENTED_DOUBLESIDED 3
478 typedef struct renderparticle_s
493 void CL_Particles_Clear(void);
494 void CL_Particles_Init(void);
496 void CL_ParseParticleEffect (void);
497 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
498 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
499 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
500 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
501 void CL_PlasmaBurn (vec3_t org);
502 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
503 void CL_Stardust (vec3_t mins, vec3_t maxs, int count);
504 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
505 void CL_Flames (vec3_t org, vec3_t vel, int count);
506 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
507 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
508 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
509 void CL_EntityParticles (entity_t *ent);
510 void CL_BlobExplosion (vec3_t org);
511 void CL_ParticleExplosion (vec3_t org, int smoke);
512 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
513 void CL_LavaSplash (vec3_t org);
514 void CL_TeleportSplash (vec3_t org);
515 void CL_MoveParticles(void);
516 void R_MoveExplosions(void);
517 void R_NewExplosion(vec3_t org);
519 // if contents is not zero, it will impact on content changes
520 // (leafs matching contents are considered empty, others are solid)
521 extern int traceline_endcontents; // set by TraceLine
522 // need to call this sometime before using TraceLine with hitbmodels
523 void TraceLine_ScanForBModels(void);
524 float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels);
526 #include "cl_screen.h"
528 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
533 int x, y, width, height;
540 // fullscreen color blend
544 entity_render_t viewent;
547 entity_render_t **entities;
550 //struct renderparticle_s *particles;
552 qbyte drawqueue[MAX_DRAWQUEUE];
559 extern mempool_t *cl_refdef_mempool;