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 #include "matrixlib.h"
27 // LordHavoc: 256 dynamic lights
28 #define MAX_DLIGHTS 256
29 // LordHavoc: this affects the lighting scale of the whole game
30 #define LIGHTOFFSET 1024.0f
31 // max lights shining on one entity
32 #define MAXENTLIGHTS 128
34 extern int cl_max_entities;
35 extern int cl_max_static_entities;
36 extern int cl_max_temp_entities;
37 extern int cl_max_effects;
38 extern int cl_max_beams;
40 typedef struct effect_s
49 // these are for interpolation
59 // draw this as lightning polygons, or a model?
61 struct model_s *model;
64 // if this beam is owned by an entity, this is the beam start relative to
65 // that entity's matrix for per frame start updates
68 // indicates whether relativestart is valid
69 int relativestartvalid;
77 // stop lighting after this time
81 // brightness (not really radius anymore)
83 // drop this each second
85 // the entity that owns this light (can be NULL)
86 struct entity_render_s *ent;
87 // orientation/scaling/location
89 // cubemap number to use on this light
91 // light style which controls intensity of this light
100 typedef struct frameblend_s
107 // LordHavoc: this struct is intended for the renderer but some fields are
108 // used by the client.
109 typedef struct entity_render_s
115 // transform matrix for model to world
117 // transform matrix for world to model
118 matrix4x4_t inversematrix;
119 // opacity (alpha) of the model
121 // size the model is shown
126 // current uninterpolated animation frame (for things which do not use interpolation)
128 // entity shirt and pants colors
130 // light, particles, etc
137 // interpolated animation
139 // frame that the model is interpolating from
141 // frame that the model is interpolating to
143 // interpolation factor, usually computed from frame2time
145 // time frame1 began playing (for framegroup animations)
147 // time frame2 began playing (for framegroup animations)
150 // calculated by the renderer (but not persistent)
152 // if visframe == r_framecount, it is visible
154 // calculated during R_AddModelEntities
156 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
157 frameblend_t frameblend[4];
159 // caching results of static light traces (this is semi-persistent)
160 double entlightstime;
161 vec3_t entlightsorigin;
164 unsigned short entlights[MAXENTLIGHTS];
168 typedef struct entity_persistent_s
177 // muzzleflash fading
180 // interpolated movement
182 // start time of move
184 // time difference from start to end of move
186 // the move itself, start and end
194 typedef struct entity_s
196 // baseline state (default values)
197 entity_state_t state_baseline;
198 // previous state (interpolating from this)
199 entity_state_t state_previous;
200 // current state (interpolating to this)
201 entity_state_t state_current;
203 // used for regenerating parts of render
204 entity_persistent_t persistent;
206 // the only data the renderer should know about
207 entity_render_t render;
215 // intended velocities
224 char map[MAX_STYLESTRING];
229 char name[MAX_SCOREBOARDNAME];
231 int colors; // two 4 bit fields
237 int percent; // 0-256
240 #define CSHIFT_CONTENTS 0
241 #define CSHIFT_DAMAGE 1
242 #define CSHIFT_BONUS 2
243 #define CSHIFT_POWERUP 3
244 #define CSHIFT_VCSHIFT 4
245 #define NUM_CSHIFTS 5
247 #define NAME_LENGTH 64
251 // client_state_t should hold all pieces of the client state
254 #define SIGNONS 4 // signon messages to receive before connected
257 #define MAX_DEMONAME 16
261 ca_dedicated, // a dedicated server with no ability to start a client
262 ca_disconnected, // full screen console with no connection
263 ca_connected // valid netcon, talking to a server
268 // the client_static_t structure is persistent through an arbitrary number
269 // of server connections
276 // -1 = don't play demos
278 // list of demos in loop
279 char demos[MAX_DEMOS][MAX_DEMONAME];
281 // demo recording info must be here, because record is started before
282 // entering a map (and clearing client_state_t)
283 qboolean demorecording;
284 qboolean demoplayback;
286 // -1 = use normal cd track
289 // to meter out one message a frame
291 // host_framecount at start
293 // realtime at second frame of timedemo (LordHavoc: changed to double)
295 // LordHavoc: for measuring maxfps
296 double td_minframetime;
297 // LordHavoc: for measuring minfps
298 double td_maxframetime;
299 // LordHavoc: pausedemo
302 qboolean connect_trying;
303 int connect_remainingtries;
304 double connect_nextsendtime;
305 lhnetsocket_t *connect_mysocket;
306 lhnetaddress_t connect_address;
308 // connection information
311 // network connection
313 // writing buffer to send to server
318 extern client_static_t cls;
321 // the client_state_t structure is wiped completely at every
326 // true if playing in a local game and no one else is connected
329 // when connecting to the server throw out the first couple move messages
330 // so the player doesn't accidentally do something the first frame
333 // send a clc_nop periodically until connected
336 // last command sent to the server
339 // information for local display
341 int stats[MAX_CL_STATS];
342 // inventory bit flags
344 // cl.time of acquiring item, for blinking
345 float item_gettime[32];
346 // cl.time of changing STAT_ACTIVEWEAPON
348 // use pain anim frame if cl.time < this
351 // color shifts for damage, powerups
352 cshift_t cshifts[NUM_CSHIFTS];
354 cshift_t prev_cshifts[NUM_CSHIFTS];
356 // the client maintains its own idea of view angles, which are
357 // sent to the server each frame. The server sets punchangle when
358 // the view is temporarily offset, and an angle reset commands at the start
359 // of each level and after teleporting.
361 // during demo playback viewangles is lerped between these
362 vec3_t mviewangles[2];
363 // either client controlled, or lerped from demo mviewangles
366 // update by server, used for lean+bob (0 is newest)
368 // lerped between mvelocity[0] and [1]
373 // LordHavoc: origin view kick
376 // pitch drifting vars
384 // local amount for smoothing stepups
392 // don't change view angle, full screen, etc
394 // latched at intermission start
397 // the timestamp of the last two messages
400 // clients view of time, time should be between mtime[0] and mtime[1] to
401 // generate a lerp point for other data, oldtime is the previous frame's
402 // value of time, frametime is the difference between time and oldtime
403 double time, oldtime, frametime;
405 // copy of realtime from last recieved message, for net trouble icon
406 float last_received_message;
408 // information that is static for the entire time connected to a server
409 struct model_s *model_precache[MAX_MODELS];
410 struct sfx_s *sound_precache[MAX_SOUNDS];
412 // for display on solo scoreboard
414 // cl_entitites[cl.viewentity] = player
416 // the real player entity (normally same as viewentity,
417 // different than viewentity if mod uses chasecam or other tricks)
419 // max players that can be in this game
421 // type of game (deathmatch, coop, singleplayer)
424 // refresh related state
426 // cl_entitites[0].model
427 struct model_s *worldmodel;
433 int cdtrack, looptrack;
438 scoreboard_t *scores;
440 // LordHavoc: sniping zoom, QC controlled
443 float viewzoomold, viewzoomnew;
445 // protocol version of the server we're connected to
448 // entity database stuff
449 entity_database_t entitydatabase;
450 entity_database4_t *entitydatabase4;
454 extern mempool_t *cl_scores_mempool;
459 extern cvar_t cl_name;
460 extern cvar_t cl_color;
461 extern cvar_t cl_rate;
462 extern cvar_t cl_pmodel;
464 extern cvar_t cl_upspeed;
465 extern cvar_t cl_forwardspeed;
466 extern cvar_t cl_backspeed;
467 extern cvar_t cl_sidespeed;
469 extern cvar_t cl_movespeedkey;
471 extern cvar_t cl_yawspeed;
472 extern cvar_t cl_pitchspeed;
474 extern cvar_t cl_anglespeedkey;
476 extern cvar_t cl_autofire;
478 extern cvar_t cl_shownet;
479 extern cvar_t cl_nolerp;
481 extern cvar_t cl_pitchdriftspeed;
482 extern cvar_t lookspring;
483 extern cvar_t lookstrafe;
484 extern cvar_t sensitivity;
486 extern cvar_t freelook;
488 extern cvar_t m_pitch;
490 extern cvar_t m_forward;
491 extern cvar_t m_side;
493 extern cvar_t r_draweffects;
495 extern cvar_t cl_explosions;
496 extern cvar_t cl_stainmaps;
498 // these are updated by CL_ClearState
499 extern int cl_num_entities;
500 extern int cl_num_static_entities;
501 extern int cl_num_temp_entities;
502 extern int cl_num_brushmodel_entities;
504 extern entity_t *cl_entities;
505 extern qbyte *cl_entities_active;
506 extern entity_t *cl_static_entities;
507 extern entity_t *cl_temp_entities;
508 extern entity_render_t **cl_brushmodel_entities;
509 extern cl_effect_t *cl_effects;
510 extern beam_t *cl_beams;
511 extern dlight_t *cl_dlights;
512 extern lightstyle_t *cl_lightstyle;
515 extern client_state_t cl;
517 extern void CL_AllocDlight (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, int cubemapnum, int style, int shadowenable, vec_t corona);
518 extern void CL_DecayLights (void);
520 //=============================================================================
528 void CL_EstablishConnection(const char *host);
530 void CL_Disconnect (void);
531 void CL_Disconnect_f (void);
533 void CL_BoundingBoxForEntity(entity_render_t *ent);
535 extern cvar_t cl_beams_polygons;
536 extern cvar_t cl_beams_relative;
537 extern cvar_t cl_beams_lightatend;
544 int down[2]; // key nums holding it down
545 int state; // low bit is down state
549 extern kbutton_t in_mlook, in_klook;
550 extern kbutton_t in_strafe;
551 extern kbutton_t in_speed;
553 void CL_InitInput (void);
554 void CL_SendCmd (usercmd_t *cmd);
555 void CL_SendMove (usercmd_t *cmd);
557 void CL_LerpUpdate(entity_t *e);
558 void CL_ParseTEnt (void);
559 void CL_RelinkBeams (void);
561 void CL_ClearTempEntities (void);
562 entity_t *CL_NewTempEntity (void);
564 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
566 void CL_ClearState (void);
569 int CL_ReadFromServer (void);
570 void CL_WriteToServer (usercmd_t *cmd);
571 void CL_BaseMove (usercmd_t *cmd);
574 float CL_KeyState (kbutton_t *key);
575 const char *Key_KeynumToString (int keynum);
580 void CL_StopPlayback(void);
581 void CL_ReadDemoMessage(void);
582 void CL_WriteDemoMessage(void);
584 void CL_NextDemo(void);
585 void CL_Stop_f(void);
586 void CL_Record_f(void);
587 void CL_PlayDemo_f(void);
588 void CL_TimeDemo_f(void);
593 void CL_Parse_Init(void);
594 void CL_ParseServerMessage(void);
595 void CL_Parse_DumpPacket(void);
600 void V_StartPitchDrift (void);
601 void V_StopPitchDrift (void);
604 float V_CalcRoll (vec3_t angles, vec3_t velocity);
605 void V_UpdateBlends (void);
606 void V_ParseDamage (void);
612 void CL_InitTEnts (void);
618 void CL_Particles_Clear(void);
619 void CL_Particles_Init(void);
621 void CL_ParseParticleEffect (void);
622 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
623 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
624 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
625 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
626 void CL_PlasmaBurn (vec3_t org);
627 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
628 void CL_Stardust (vec3_t mins, vec3_t maxs, int count);
629 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
630 void CL_Flames (vec3_t org, vec3_t vel, int count);
631 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
632 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
633 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
634 void CL_EntityParticles (entity_t *ent);
635 void CL_BlobExplosion (vec3_t org);
636 void CL_ParticleExplosion (vec3_t org);
637 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
638 void CL_LavaSplash (vec3_t org);
639 void CL_TeleportSplash (vec3_t org);
640 void CL_BeamParticle (const vec3_t start, const vec3_t end, vec_t radius, float red, float green, float blue, float alpha, float lifetime);
641 void CL_Tei_Smoke(const vec3_t pos, const vec3_t dir, int count);
642 void CL_Tei_PlasmaHit(const vec3_t pos, const vec3_t dir, int count);
643 void CL_MoveParticles(void);
644 void R_MoveExplosions(void);
645 void R_NewExplosion(vec3_t org);
647 #include "cl_screen.h"
652 int x, y, width, height;
656 matrix4x4_t viewentitymatrix;
658 // fullscreen color blend
661 entity_render_t **entities;
667 int maxdrawqueuesize;
673 extern mempool_t *cl_refdef_mempool;