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 // LordHavoc: nothing in this structure is persistant, it may be overwritten by the client every frame, for persistant data use entity_lerp_t.
33 typedef struct entity_render_s
39 // opacity (alpha) of the model
41 // size the model is shown
46 // current uninterpolated animation frame (for things which do not use interpolation)
48 // entity shirt and pants colors
50 // light, particles, etc
57 // these are copied from the persistent data
59 // frame that the model is interpolating from
61 // frame that the model is interpolating to
63 // interpolation factor, usually computed from frame2time
65 // time frame1 began playing (for framegroup animations)
67 // time frame2 began playing (for framegroup animations)
70 // calculated by the renderer (but not persistent)
72 // if visframe == r_framecount, it is visible
74 // calculated during R_AddModelEntities
76 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
77 frameblend_t frameblend[4];
81 typedef struct entity_persistent_s
94 // interpolated animation
96 // lerp resets when model changes
98 // frame that the model is interpolating from
100 // frame that the model is interpolating to
102 // interpolation factor, usually computed from frame2time
104 // time frame1 began playing (for framegroup animations)
106 // time frame2 began playing (for framegroup animations)
111 typedef struct entity_s
113 // baseline state (default values)
114 entity_state_t state_baseline;
115 // previous state (interpolating from this)
116 entity_state_t state_previous;
117 // current state (interpolating to this)
118 entity_state_t state_current;
120 // used for regenerating parts of render
121 entity_persistent_t persistent;
123 // the only data the renderer should know about
124 entity_render_t render;
132 // intended velocities
141 char map[MAX_STYLESTRING];
146 char name[MAX_SCOREBOARDNAME];
149 int colors; // two 4 bit fields
155 int percent; // 0-256
158 #define CSHIFT_CONTENTS 0
159 #define CSHIFT_DAMAGE 1
160 #define CSHIFT_BONUS 2
161 #define CSHIFT_POWERUP 3
162 #define NUM_CSHIFTS 4
164 #define NAME_LENGTH 64
168 // client_state_t should hold all pieces of the client state
171 #define SIGNONS 4 // signon messages to receive before connected
177 struct model_s *model;
183 #define MAX_MAPSTRING 2048
185 #define MAX_DEMONAME 16
189 ca_dedicated, // a dedicated server with no ability to start a client
190 ca_disconnected, // full screen console with no connection
191 ca_connected // valid netcon, talking to a server
196 // the client_static_t structure is persistant through an arbitrary number
197 // of server connections
203 // personalization data sent to server
204 char mapstring[MAX_QPATH];
205 char spawnparms[MAX_MAPSTRING]; // to restart a level
208 int demonum; // -1 = don't play demos
209 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
211 // demo recording info must be here, because record is started before
212 // entering a map (and clearing client_state_t)
213 qboolean demorecording;
214 qboolean demoplayback;
216 int forcetrack; // -1 = use normal cd track
218 int td_lastframe; // to meter out one message a frame
219 int td_startframe; // host_framecount at start
220 double td_starttime; // realtime at second frame of timedemo (LordHavoc: changed to double)
221 qboolean demopaused; // LordHavoc: pausedemo
224 // connection information
225 int signon; // 0 to SIGNONS
226 struct qsocket_s *netcon;
227 sizebuf_t message; // writing buffer to send to server
231 extern client_static_t cls;
234 // the client_state_t structure is wiped completely at every
239 int movemessages; // since connecting to this server
240 // throw out the first couple, so the player
241 // doesn't accidentally do something the
243 float sendnoptime; // send a clc_nop periodically until connected
244 usercmd_t cmd; // last command sent to the server
246 // information for local display
247 int stats[MAX_CL_STATS]; // health, etc
248 int items; // inventory bit flags
249 float item_gettime[32]; // cl.time of acquiring item, for blinking
250 float faceanimtime; // use anim frame if cl.time < this
252 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
253 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
255 // the client maintains its own idea of view angles, which are
256 // sent to the server each frame. The server sets punchangle when
257 // the view is temporarliy offset, and an angle reset commands at the start
258 // of each level and after teleporting.
259 vec3_t mviewangles[2]; // during demo playback viewangles is lerped
263 vec3_t mvelocity[2]; // update by server, used for lean+bob
265 vec3_t velocity; // lerped between mvelocity[0] and [1]
267 vec3_t punchangle; // temporary offset
268 vec3_t punchvector; // LordHavoc: origin view kick
270 // pitch drifting vars
278 float crouch; // local amount for smoothing stepups
280 qboolean paused; // send over by server
284 int intermission; // don't change view angle, full screen, etc
285 int completed_time; // latched at intermission start
287 double mtime[2]; // the timestamp of last two messages
288 double time; // clients view of time, should be between
289 // servertime and oldservertime to generate
290 // a lerp point for other data
291 double oldtime; // previous cl.time, time-oldtime is used
292 // to decay light values and smooth step ups
297 float last_received_message; // (realtime) for net trouble icon
300 // information that is static for the entire time connected to a server
302 struct model_s *model_precache[MAX_MODELS];
303 struct sfx_s *sound_precache[MAX_SOUNDS];
305 char levelname[40]; // for display on solo scoreboard
306 int viewentity; // cl_entitites[cl.viewentity] = player
310 // refresh related state
311 struct model_s *worldmodel; // cl_entitites[0].model
312 int num_statics; // held in cl_staticentities array
313 entity_t viewent; // the gun model
315 int cdtrack, looptrack; // cd audio
318 scoreboard_t *scores; // [cl.maxclients]
320 vec3_t viewentorigin;
321 float viewzoom; // LordHavoc: sniping zoom, QC controlled
322 float viewzoomold, viewzoomnew; // for interpolation
324 // entity database stuff
325 vec3_t viewentoriginold, viewentoriginnew;
326 entity_database_t entitydatabase;
330 extern mempool_t *cl_scores_mempool;
335 extern cvar_t cl_name;
336 extern cvar_t cl_color;
337 extern cvar_t cl_pmodel;
339 extern cvar_t cl_upspeed;
340 extern cvar_t cl_forwardspeed;
341 extern cvar_t cl_backspeed;
342 extern cvar_t cl_sidespeed;
344 extern cvar_t cl_movespeedkey;
346 extern cvar_t cl_yawspeed;
347 extern cvar_t cl_pitchspeed;
349 extern cvar_t cl_anglespeedkey;
351 extern cvar_t cl_autofire;
353 extern cvar_t cl_shownet;
354 extern cvar_t cl_nolerp;
356 extern cvar_t cl_pitchdriftspeed;
357 extern cvar_t lookspring;
358 extern cvar_t lookstrafe;
359 extern cvar_t sensitivity;
361 extern cvar_t freelook;
363 extern cvar_t m_pitch;
365 extern cvar_t m_forward;
366 extern cvar_t m_side;
369 // LordHavoc: raised these from 64 and 128 to 512 and 256
370 #define MAX_TEMP_ENTITIES 512 // lightning bolts, effects, etc
371 #define MAX_STATIC_ENTITIES 256 // torches, etc
373 extern client_state_t cl;
375 // FIXME, allocate dynamically
376 extern entity_t cl_entities[MAX_EDICTS];
377 extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
378 extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
379 extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
380 extern beam_t cl_beams[MAX_BEAMS];
382 #include "cl_light.h"
384 //=============================================================================
392 void CL_EstablishConnection (char *host);
394 void CL_Disconnect (void);
395 void CL_Disconnect_f (void);
402 int down[2]; // key nums holding it down
403 int state; // low bit is down state
407 extern kbutton_t in_mlook, in_klook;
408 extern kbutton_t in_strafe;
409 extern kbutton_t in_speed;
411 void CL_InitInput (void);
412 void CL_SendCmd (void);
413 void CL_SendMove (usercmd_t *cmd);
415 void CL_LerpUpdate(entity_t *e);
416 void CL_ParseTEnt (void);
417 void CL_UpdateTEnts (void);
419 entity_t *CL_NewTempEntity (void);
421 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
423 void CL_ClearState (void);
426 int CL_ReadFromServer (void);
427 void CL_WriteToServer (usercmd_t *cmd);
428 void CL_BaseMove (usercmd_t *cmd);
431 float CL_KeyState (kbutton_t *key);
432 char *Key_KeynumToString (int keynum);
437 void CL_StopPlayback (void);
438 int CL_GetMessage (void);
440 void CL_NextDemo (void);
441 void CL_Stop_f (void);
442 void CL_Record_f (void);
443 void CL_PlayDemo_f (void);
444 void CL_TimeDemo_f (void);
449 void CL_Parse_Init(void);
450 void CL_ParseServerMessage(void);
451 void CL_BitProfile_f(void);
456 void V_StartPitchDrift (void);
457 void V_StopPitchDrift (void);
460 float V_CalcRoll (vec3_t angles, vec3_t velocity);
461 void V_UpdateBlends (void);
462 void V_ParseDamage (void);
468 void CL_InitTEnts (void);
474 #define PARTICLE_INVALID 0
475 #define PARTICLE_BILLBOARD 1
476 #define PARTICLE_UPRIGHT_FACING 2
477 #define PARTICLE_ORIENTED_DOUBLESIDED 3
479 void CL_Particles_Clear(void);
480 void CL_Particles_Init(void);
482 void CL_ParseParticleEffect (void);
483 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
484 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
485 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
486 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
487 void CL_PlasmaBurn (vec3_t org);
488 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
489 void CL_Stardust (vec3_t mins, vec3_t maxs, int count);
490 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
491 void CL_Flames (vec3_t org, vec3_t vel, int count);
492 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
493 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
494 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
495 void CL_EntityParticles (entity_t *ent);
496 void CL_BlobExplosion (vec3_t org);
497 void CL_ParticleExplosion (vec3_t org, int smoke);
498 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
499 void CL_LavaSplash (vec3_t org);
500 void CL_TeleportSplash (vec3_t org);
501 void CL_MoveParticles(void);
502 void R_MoveExplosions(void);
503 void R_NewExplosion(vec3_t org);
505 #include "cl_screen.h"
507 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
512 int x, y, width, height;
519 // fullscreen color blend
523 entity_render_t viewent;
526 entity_render_t **entities;
528 qbyte drawqueue[MAX_DRAWQUEUE];
535 extern mempool_t *cl_refdef_mempool;