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.
25 typedef struct frameblend_s
32 #define MAXENTLIGHTS 128
34 // LordHavoc: disregard the following warning, entlights stuff is semi-persistent...
35 // LordHavoc: nothing in this structure is persistent, it may be overwritten by the client every frame, for persistent data use entity_lerp_t.
36 typedef struct entity_render_s
42 // opacity (alpha) of the model
44 // size the model is shown
49 // current uninterpolated animation frame (for things which do not use interpolation)
51 // entity shirt and pants colors
53 // light, particles, etc
60 // these are copied from the persistent data
62 // frame that the model is interpolating from
64 // frame that the model is interpolating to
66 // interpolation factor, usually computed from frame2time
68 // time frame1 began playing (for framegroup animations)
70 // time frame2 began playing (for framegroup animations)
73 // calculated by the renderer (but not persistent)
75 // if visframe == r_framecount, it is visible
77 // calculated during R_AddModelEntities
79 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
80 frameblend_t frameblend[4];
82 // caching results of static light traces (this is semi-persistent)
84 vec3_t entlightsorigin;
86 unsigned short entlights[MAXENTLIGHTS];
90 typedef struct entity_persistent_s
100 // muzzleflash fading
103 // interpolated animation
105 // lerp resets when model changes
107 // frame that the model is interpolating from
109 // frame that the model is interpolating to
111 // interpolation factor, usually computed from frame2time
113 // time frame1 began playing (for framegroup animations)
115 // time frame2 began playing (for framegroup animations)
120 typedef struct entity_s
122 // baseline state (default values)
123 entity_state_t state_baseline;
124 // previous state (interpolating from this)
125 entity_state_t state_previous;
126 // current state (interpolating to this)
127 entity_state_t state_current;
129 // used for regenerating parts of render
130 entity_persistent_t persistent;
132 // the only data the renderer should know about
133 entity_render_t render;
141 // intended velocities
150 char map[MAX_STYLESTRING];
155 char name[MAX_SCOREBOARDNAME];
158 int colors; // two 4 bit fields
164 int percent; // 0-256
167 #define CSHIFT_CONTENTS 0
168 #define CSHIFT_DAMAGE 1
169 #define CSHIFT_BONUS 2
170 #define CSHIFT_POWERUP 3
171 #define NUM_CSHIFTS 4
173 #define NAME_LENGTH 64
177 // client_state_t should hold all pieces of the client state
180 #define SIGNONS 4 // signon messages to receive before connected
186 struct model_s *model;
192 #define MAX_MAPSTRING 2048
194 #define MAX_DEMONAME 16
198 ca_dedicated, // a dedicated server with no ability to start a client
199 ca_disconnected, // full screen console with no connection
200 ca_connected // valid netcon, talking to a server
205 // the client_static_t structure is persistent through an arbitrary number
206 // of server connections
212 // personalization data sent to server
213 char mapstring[MAX_QPATH];
214 char spawnparms[MAX_MAPSTRING]; // to restart a level
217 int demonum; // -1 = don't play demos
218 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
220 // demo recording info must be here, because record is started before
221 // entering a map (and clearing client_state_t)
222 qboolean demorecording;
223 qboolean demoplayback;
225 int forcetrack; // -1 = use normal cd track
227 int td_lastframe; // to meter out one message a frame
228 int td_startframe; // host_framecount at start
229 double td_starttime; // realtime at second frame of timedemo (LordHavoc: changed to double)
230 qboolean demopaused; // LordHavoc: pausedemo
233 // connection information
234 int signon; // 0 to SIGNONS
235 struct qsocket_s *netcon;
236 sizebuf_t message; // writing buffer to send to server
240 extern client_static_t cls;
243 // the client_state_t structure is wiped completely at every
248 int movemessages; // since connecting to this server
249 // throw out the first couple, so the player
250 // doesn't accidentally do something the
252 float sendnoptime; // send a clc_nop periodically until connected
253 usercmd_t cmd; // last command sent to the server
255 // information for local display
256 int stats[MAX_CL_STATS]; // health, etc
257 int items; // inventory bit flags
258 float item_gettime[32]; // cl.time of acquiring item, for blinking
259 float faceanimtime; // use anim frame if cl.time < this
261 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
262 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
264 // the client maintains its own idea of view angles, which are
265 // sent to the server each frame. The server sets punchangle when
266 // the view is temporarliy offset, and an angle reset commands at the start
267 // of each level and after teleporting.
268 vec3_t mviewangles[2]; // during demo playback viewangles is lerped
272 vec3_t mvelocity[2]; // update by server, used for lean+bob
274 vec3_t velocity; // lerped between mvelocity[0] and [1]
276 vec3_t punchangle; // temporary offset
277 vec3_t punchvector; // LordHavoc: origin view kick
279 // pitch drifting vars
287 float crouch; // local amount for smoothing stepups
289 qboolean paused; // send over by server
293 int intermission; // don't change view angle, full screen, etc
294 int completed_time; // latched at intermission start
296 double mtime[2]; // the timestamp of last two messages
297 double time; // clients view of time, should be between
298 // servertime and oldservertime to generate
299 // a lerp point for other data
300 double oldtime; // previous cl.time, time-oldtime is used
301 // to decay light values and smooth step ups
306 float last_received_message; // (realtime) for net trouble icon
309 // information that is static for the entire time connected to a server
311 struct model_s *model_precache[MAX_MODELS];
312 struct sfx_s *sound_precache[MAX_SOUNDS];
314 char levelname[40]; // for display on solo scoreboard
315 int viewentity; // cl_entitites[cl.viewentity] = player
319 // refresh related state
320 struct model_s *worldmodel; // cl_entitites[0].model
321 int num_statics; // held in cl_staticentities array
322 entity_t viewent; // the gun model
324 int cdtrack, looptrack; // cd audio
327 scoreboard_t *scores; // [cl.maxclients]
329 vec3_t viewentorigin;
330 float viewzoom; // LordHavoc: sniping zoom, QC controlled
331 float viewzoomold, viewzoomnew; // for interpolation
333 // entity database stuff
334 vec3_t viewentoriginold, viewentoriginnew;
335 entity_database_t entitydatabase;
339 extern mempool_t *cl_scores_mempool;
344 extern cvar_t cl_name;
345 extern cvar_t cl_color;
346 extern cvar_t cl_pmodel;
348 extern cvar_t cl_upspeed;
349 extern cvar_t cl_forwardspeed;
350 extern cvar_t cl_backspeed;
351 extern cvar_t cl_sidespeed;
353 extern cvar_t cl_movespeedkey;
355 extern cvar_t cl_yawspeed;
356 extern cvar_t cl_pitchspeed;
358 extern cvar_t cl_anglespeedkey;
360 extern cvar_t cl_autofire;
362 extern cvar_t cl_shownet;
363 extern cvar_t cl_nolerp;
365 extern cvar_t cl_pitchdriftspeed;
366 extern cvar_t lookspring;
367 extern cvar_t lookstrafe;
368 extern cvar_t sensitivity;
370 extern cvar_t freelook;
372 extern cvar_t m_pitch;
374 extern cvar_t m_forward;
375 extern cvar_t m_side;
377 extern cvar_t r_draweffects;
379 extern cvar_t cl_explosions;
380 extern cvar_t cl_stainmaps;
383 // LordHavoc: raised these from 64 and 128 to 512 and 256
384 #define MAX_TEMP_ENTITIES 512 // lightning bolts, effects, etc
385 #define MAX_STATIC_ENTITIES 256 // torches, etc
387 extern client_state_t cl;
389 // FIXME, allocate dynamically
390 extern entity_t cl_entities[MAX_EDICTS];
391 extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
392 extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
393 extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
394 extern beam_t cl_beams[MAX_BEAMS];
396 #include "cl_light.h"
398 //=============================================================================
406 void CL_EstablishConnection (char *host);
408 void CL_Disconnect (void);
409 void CL_Disconnect_f (void);
416 int down[2]; // key nums holding it down
417 int state; // low bit is down state
421 extern kbutton_t in_mlook, in_klook;
422 extern kbutton_t in_strafe;
423 extern kbutton_t in_speed;
425 void CL_InitInput (void);
426 void CL_SendCmd (void);
427 void CL_SendMove (usercmd_t *cmd);
429 void CL_LerpUpdate(entity_t *e);
430 void CL_ParseTEnt (void);
431 void CL_UpdateTEnts (void);
433 entity_t *CL_NewTempEntity (void);
435 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
437 void CL_ClearState (void);
440 int CL_ReadFromServer (void);
441 void CL_WriteToServer (usercmd_t *cmd);
442 void CL_BaseMove (usercmd_t *cmd);
445 float CL_KeyState (kbutton_t *key);
446 char *Key_KeynumToString (int keynum);
451 void CL_StopPlayback (void);
452 int CL_GetMessage (void);
454 void CL_NextDemo (void);
455 void CL_Stop_f (void);
456 void CL_Record_f (void);
457 void CL_PlayDemo_f (void);
458 void CL_TimeDemo_f (void);
463 void CL_Parse_Init(void);
464 void CL_ParseServerMessage(void);
465 void CL_BitProfile_f(void);
470 void V_StartPitchDrift (void);
471 void V_StopPitchDrift (void);
474 float V_CalcRoll (vec3_t angles, vec3_t velocity);
475 void V_UpdateBlends (void);
476 void V_ParseDamage (void);
482 void CL_InitTEnts (void);
488 #define PARTICLE_INVALID 0
489 #define PARTICLE_BILLBOARD 1
490 #define PARTICLE_UPRIGHT_FACING 2
491 #define PARTICLE_ORIENTED_DOUBLESIDED 3
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 #include "cl_screen.h"
521 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
526 int x, y, width, height;
533 // fullscreen color blend
537 entity_render_t viewent;
540 entity_render_t **entities;
542 qbyte drawqueue[MAX_DRAWQUEUE];
549 extern mempool_t *cl_refdef_mempool;