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
32 vec3_t origin; // location
33 vec3_t angles; // orientation
34 float alpha; // opacity (alpha) of the model
35 float scale; // size the model is shown
37 model_t *model; // NULL = no model
38 int frame; // current uninterpolated animation frame (for things which do not use interpolation)
39 int colormap; // entity shirt and pants colors
40 int effects; // light, particles, etc
41 int skinnum; // for Alias models
42 int flags; // render flags
44 // these are copied from the persistent data
45 int frame1; // frame that the model is interpolating from
46 int frame2; // frame that the model is interpolating to
47 double framelerp; // interpolation factor, usually computed from frame2time
48 double frame1time; // time frame1 began playing (for framegroup animations)
49 double frame2time; // time frame2 began playing (for framegroup animations)
51 // calculated by the renderer (but not persistent)
52 int visframe; // if visframe == r_framecount, it is visible
53 vec3_t mins, maxs; // calculated during R_AddModelEntities
54 frameblend_t frameblend[4]; // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
58 typedef struct entity_persistent_s
61 vec3_t trail_origin; // trail rendering
62 float trail_time; // trail rendering
64 // interpolated animation
65 int modelindex; // lerp resets when model changes
66 int frame1; // frame that the model is interpolating from
67 int frame2; // frame that the model is interpolating to
68 double framelerp; // interpolation factor, usually computed from frame2time
69 double frame1time; // time frame1 began playing (for framegroup animations)
70 double frame2time; // time frame2 began playing (for framegroup animations)
74 typedef struct entity_s
76 entity_state_t state_baseline; // baseline state (default values)
77 entity_state_t state_previous; // previous state (interpolating from this)
78 entity_state_t state_current; // current state (interpolating to this)
80 entity_persistent_t persistent; // used for regenerating parts of render
82 entity_render_t render; // the only data the renderer should know about
90 // intended velocities
99 char map[MAX_STYLESTRING];
104 char name[MAX_SCOREBOARDNAME];
107 int colors; // two 4 bit fields
113 int percent; // 0-256
116 #define CSHIFT_CONTENTS 0
117 #define CSHIFT_DAMAGE 1
118 #define CSHIFT_BONUS 2
119 #define CSHIFT_POWERUP 3
120 #define NUM_CSHIFTS 4
122 #define NAME_LENGTH 64
126 // client_state_t should hold all pieces of the client state
129 #define SIGNONS 4 // signon messages to receive before connected
135 struct model_s *model;
141 #define MAX_MAPSTRING 2048
143 #define MAX_DEMONAME 16
147 ca_dedicated, // a dedicated server with no ability to start a client
148 ca_disconnected, // full screen console with no connection
149 ca_connected // valid netcon, talking to a server
154 // the client_static_t structure is persistant through an arbitrary number
155 // of server connections
161 // personalization data sent to server
162 char mapstring[MAX_QPATH];
163 char spawnparms[MAX_MAPSTRING]; // to restart a level
166 int demonum; // -1 = don't play demos
167 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
169 // demo recording info must be here, because record is started before
170 // entering a map (and clearing client_state_t)
171 qboolean demorecording;
172 qboolean demoplayback;
174 int forcetrack; // -1 = use normal cd track
176 int td_lastframe; // to meter out one message a frame
177 int td_startframe; // host_framecount at start
178 double td_starttime; // realtime at second frame of timedemo (LordHavoc: changed to double)
179 qboolean demopaused; // LordHavoc: pausedemo
182 // connection information
183 int signon; // 0 to SIGNONS
184 struct qsocket_s *netcon;
185 sizebuf_t message; // writing buffer to send to server
189 extern client_static_t cls;
192 // the client_state_t structure is wiped completely at every
197 int movemessages; // since connecting to this server
198 // throw out the first couple, so the player
199 // doesn't accidentally do something the
201 float sendnoptime; // send a clc_nop periodically until connected
202 usercmd_t cmd; // last command sent to the server
204 // information for local display
205 int stats[MAX_CL_STATS]; // health, etc
206 int items; // inventory bit flags
207 float item_gettime[32]; // cl.time of acquiring item, for blinking
208 float faceanimtime; // use anim frame if cl.time < this
210 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
211 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
213 // the client maintains its own idea of view angles, which are
214 // sent to the server each frame. The server sets punchangle when
215 // the view is temporarliy offset, and an angle reset commands at the start
216 // of each level and after teleporting.
217 vec3_t mviewangles[2]; // during demo playback viewangles is lerped
221 vec3_t mvelocity[2]; // update by server, used for lean+bob
223 vec3_t velocity; // lerped between mvelocity[0] and [1]
225 vec3_t punchangle; // temporary offset
226 vec3_t punchvector; // LordHavoc: origin view kick
228 // pitch drifting vars
236 float crouch; // local amount for smoothing stepups
238 qboolean paused; // send over by server
242 int intermission; // don't change view angle, full screen, etc
243 int completed_time; // latched at intermission start
245 double mtime[2]; // the timestamp of last two messages
246 double time; // clients view of time, should be between
247 // servertime and oldservertime to generate
248 // a lerp point for other data
249 double oldtime; // previous cl.time, time-oldtime is used
250 // to decay light values and smooth step ups
255 float last_received_message; // (realtime) for net trouble icon
258 // information that is static for the entire time connected to a server
260 struct model_s *model_precache[MAX_MODELS];
261 struct sfx_s *sound_precache[MAX_SOUNDS];
263 char levelname[40]; // for display on solo scoreboard
264 int viewentity; // cl_entitites[cl.viewentity] = player
268 // refresh related state
269 struct model_s *worldmodel; // cl_entitites[0].model
270 // int num_entities; // held in cl_entities array
271 int num_statics; // held in cl_staticentities array
272 entity_t viewent; // the gun model
274 int cdtrack, looptrack; // cd audio
277 scoreboard_t *scores; // [cl.maxclients]
279 vec3_t viewentorigin;
280 float viewzoom; // LordHavoc: sniping zoom, QC controlled
281 float viewzoomold, viewzoomnew; // for interpolation
283 // entity database stuff
284 vec3_t viewentoriginold, viewentoriginnew;
285 entity_database_t entitydatabase;
289 extern mempool_t *cl_scores_mempool;
294 extern cvar_t cl_name;
295 extern cvar_t cl_color;
296 extern cvar_t cl_pmodel;
298 extern cvar_t cl_upspeed;
299 extern cvar_t cl_forwardspeed;
300 extern cvar_t cl_backspeed;
301 extern cvar_t cl_sidespeed;
303 extern cvar_t cl_movespeedkey;
305 extern cvar_t cl_yawspeed;
306 extern cvar_t cl_pitchspeed;
308 extern cvar_t cl_anglespeedkey;
310 extern cvar_t cl_autofire;
312 extern cvar_t cl_shownet;
313 extern cvar_t cl_nolerp;
315 extern cvar_t cl_pitchdriftspeed;
316 extern cvar_t lookspring;
317 extern cvar_t lookstrafe;
318 extern cvar_t sensitivity;
320 extern cvar_t freelook;
322 extern cvar_t m_pitch;
324 extern cvar_t m_forward;
325 extern cvar_t m_side;
328 // LordHavoc: raised these from 64 and 128 to 512 and 256
329 #define MAX_TEMP_ENTITIES 512 // lightning bolts, effects, etc
330 #define MAX_STATIC_ENTITIES 256 // torches, etc
332 extern client_state_t cl;
334 // FIXME, allocate dynamically
335 extern entity_t cl_entities[MAX_EDICTS];
336 extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
337 extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
338 extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
339 extern beam_t cl_beams[MAX_BEAMS];
341 #include "cl_light.h"
343 //=============================================================================
351 void CL_EstablishConnection (char *host);
353 void CL_Disconnect (void);
354 void CL_Disconnect_f (void);
361 int down[2]; // key nums holding it down
362 int state; // low bit is down state
366 extern kbutton_t in_mlook, in_klook;
367 extern kbutton_t in_strafe;
368 extern kbutton_t in_speed;
370 void CL_InitInput (void);
371 void CL_SendCmd (void);
372 void CL_SendMove (usercmd_t *cmd);
374 void CL_LerpUpdate(entity_t *e);
375 void CL_ParseTEnt (void);
376 void CL_UpdateTEnts (void);
378 entity_t *CL_NewTempEntity (void);
380 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
382 void CL_ClearState (void);
385 int CL_ReadFromServer (void);
386 void CL_WriteToServer (usercmd_t *cmd);
387 void CL_BaseMove (usercmd_t *cmd);
390 float CL_KeyState (kbutton_t *key);
391 char *Key_KeynumToString (int keynum);
396 void CL_StopPlayback (void);
397 int CL_GetMessage (void);
399 void CL_NextDemo (void);
400 void CL_Stop_f (void);
401 void CL_Record_f (void);
402 void CL_PlayDemo_f (void);
403 void CL_TimeDemo_f (void);
408 void CL_Parse_Init(void);
409 void CL_ParseServerMessage(void);
410 void CL_BitProfile_f(void);
415 void V_StartPitchDrift (void);
416 void V_StopPitchDrift (void);
419 float V_CalcRoll (vec3_t angles, vec3_t velocity);
420 void V_UpdateBlends (void);
421 void V_ParseDamage (void);
427 void CL_InitTEnts (void);
433 #define PARTICLE_INVALID 0
434 #define PARTICLE_BILLBOARD 1
435 #define PARTICLE_UPRIGHT_FACING 2
436 #define PARTICLE_ORIENTED_DOUBLESIDED 3
439 typedef struct renderparticle_s
454 void CL_Particles_Clear(void);
455 void CL_Particles_Init(void);
457 void CL_ParseParticleEffect (void);
458 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
459 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
460 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
461 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
462 void CL_PlasmaBurn (vec3_t org);
463 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
464 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
465 void CL_Flames (vec3_t org, vec3_t vel, int count);
466 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
467 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
468 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
469 void CL_EntityParticles (entity_t *ent);
470 void CL_BlobExplosion (vec3_t org);
471 void CL_ParticleExplosion (vec3_t org, int smoke);
472 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
473 void CL_LavaSplash (vec3_t org);
474 void CL_TeleportSplash (vec3_t org);
475 void CL_MoveParticles(void);
476 void R_MoveExplosions(void);
477 void R_NewExplosion(vec3_t org);
479 // if contents is not zero, it will impact on content changes
480 // (leafs matching contents are considered empty, others are solid)
481 extern int traceline_endcontents; // set by TraceLine
482 // need to call this sometime before using TraceLine with hitbmodels
483 void TraceLine_ScanForBModels(void);
484 float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal, int contents, int hitbmodels);
486 #include "cl_screen.h"
488 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
493 int x, y, width, height;
500 // fullscreen color blend
504 entity_render_t viewent;
507 entity_render_t **entities;
510 //struct renderparticle_s *particles;
512 qbyte drawqueue[MAX_DRAWQUEUE];
519 extern mempool_t *cl_refdef_mempool;