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;
90 typedef struct frameblend_s
97 // LordHavoc: this struct is intended for the renderer but some fields are
98 // used by the client.
99 typedef struct entity_render_s
105 // transform matrix for model to world
107 // transform matrix for world to model
108 matrix4x4_t inversematrix;
109 // opacity (alpha) of the model
111 // size the model is shown
116 // current uninterpolated animation frame (for things which do not use interpolation)
118 // entity shirt and pants colors
120 // light, particles, etc
127 // interpolated animation
129 // frame that the model is interpolating from
131 // frame that the model is interpolating to
133 // interpolation factor, usually computed from frame2time
135 // time frame1 began playing (for framegroup animations)
137 // time frame2 began playing (for framegroup animations)
140 // calculated by the renderer (but not persistent)
142 // if visframe == r_framecount, it is visible
144 // calculated during R_AddModelEntities
146 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
147 frameblend_t frameblend[4];
149 // caching results of static light traces (this is semi-persistent)
150 double entlightstime;
151 vec3_t entlightsorigin;
154 unsigned short entlights[MAXENTLIGHTS];
158 typedef struct entity_persistent_s
167 // muzzleflash fading
170 // interpolated movement
172 // start time of move
174 // time difference from start to end of move
176 // the move itself, start and end
184 typedef struct entity_s
186 // baseline state (default values)
187 entity_state_t state_baseline;
188 // previous state (interpolating from this)
189 entity_state_t state_previous;
190 // current state (interpolating to this)
191 entity_state_t state_current;
193 // used for regenerating parts of render
194 entity_persistent_t persistent;
196 // the only data the renderer should know about
197 entity_render_t render;
205 // intended velocities
214 char map[MAX_STYLESTRING];
219 char name[MAX_SCOREBOARDNAME];
221 int colors; // two 4 bit fields
227 int percent; // 0-256
230 #define CSHIFT_CONTENTS 0
231 #define CSHIFT_DAMAGE 1
232 #define CSHIFT_BONUS 2
233 #define CSHIFT_POWERUP 3
234 #define CSHIFT_VCSHIFT 4
235 #define NUM_CSHIFTS 5
237 #define NAME_LENGTH 64
241 // client_state_t should hold all pieces of the client state
244 #define SIGNONS 4 // signon messages to receive before connected
247 #define MAX_DEMONAME 16
251 ca_dedicated, // a dedicated server with no ability to start a client
252 ca_disconnected, // full screen console with no connection
253 ca_connected // valid netcon, talking to a server
258 // the client_static_t structure is persistent through an arbitrary number
259 // of server connections
266 // -1 = don't play demos
268 // list of demos in loop
269 char demos[MAX_DEMOS][MAX_DEMONAME];
271 // demo recording info must be here, because record is started before
272 // entering a map (and clearing client_state_t)
273 qboolean demorecording;
274 qboolean demoplayback;
276 // -1 = use normal cd track
279 // to meter out one message a frame
281 // host_framecount at start
283 // realtime at second frame of timedemo (LordHavoc: changed to double)
285 // LordHavoc: pausedemo
288 qboolean connect_trying;
289 int connect_remainingtries;
290 double connect_nextsendtime;
291 lhnetsocket_t *connect_mysocket;
292 lhnetaddress_t connect_address;
294 // connection information
297 // network connection
299 // writing buffer to send to server
304 extern client_static_t cls;
307 // the client_state_t structure is wiped completely at every
312 // true if playing in a local game and no one else is connected
315 // when connecting to the server throw out the first couple move messages
316 // so the player doesn't accidentally do something the first frame
319 // send a clc_nop periodically until connected
322 // last command sent to the server
325 // information for local display
327 int stats[MAX_CL_STATS];
328 // inventory bit flags
330 // cl.time of acquiring item, for blinking
331 float item_gettime[32];
332 // cl.time of changing STAT_ACTIVEWEAPON
334 // use pain anim frame if cl.time < this
337 // color shifts for damage, powerups
338 cshift_t cshifts[NUM_CSHIFTS];
340 cshift_t prev_cshifts[NUM_CSHIFTS];
342 // the client maintains its own idea of view angles, which are
343 // sent to the server each frame. The server sets punchangle when
344 // the view is temporarily offset, and an angle reset commands at the start
345 // of each level and after teleporting.
347 // during demo playback viewangles is lerped between these
348 vec3_t mviewangles[2];
349 // either client controlled, or lerped from demo mviewangles
352 // update by server, used for lean+bob (0 is newest)
354 // lerped between mvelocity[0] and [1]
359 // LordHavoc: origin view kick
362 // pitch drifting vars
370 // local amount for smoothing stepups
378 // don't change view angle, full screen, etc
380 // latched at intermission start
383 // the timestamp of the last two messages
386 // clients view of time, time should be between mtime[0] and mtime[1] to
387 // generate a lerp point for other data, oldtime is the previous frame's
388 // value of time, frametime is the difference between time and oldtime
389 double time, oldtime, frametime;
391 // copy of realtime from last recieved message, for net trouble icon
392 float last_received_message;
394 // information that is static for the entire time connected to a server
395 struct model_s *model_precache[MAX_MODELS];
396 struct sfx_s *sound_precache[MAX_SOUNDS];
398 // for display on solo scoreboard
400 // cl_entitites[cl.viewentity] = player
402 // the real player entity (normally same as viewentity,
403 // different than viewentity if mod uses chasecam or other tricks)
405 // max players that can be in this game
407 // type of game (deathmatch, coop, singleplayer)
410 // refresh related state
412 // cl_entitites[0].model
413 struct model_s *worldmodel;
419 int cdtrack, looptrack;
424 scoreboard_t *scores;
426 // LordHavoc: sniping zoom, QC controlled
429 float viewzoomold, viewzoomnew;
431 // protocol version of the server we're connected to
434 // entity database stuff
435 entity_database_t entitydatabase;
436 entity_database4_t *entitydatabase4;
440 extern mempool_t *cl_scores_mempool;
445 extern cvar_t cl_name;
446 extern cvar_t cl_color;
447 extern cvar_t cl_pmodel;
449 extern cvar_t cl_upspeed;
450 extern cvar_t cl_forwardspeed;
451 extern cvar_t cl_backspeed;
452 extern cvar_t cl_sidespeed;
454 extern cvar_t cl_movespeedkey;
456 extern cvar_t cl_yawspeed;
457 extern cvar_t cl_pitchspeed;
459 extern cvar_t cl_anglespeedkey;
461 extern cvar_t cl_autofire;
463 extern cvar_t cl_shownet;
464 extern cvar_t cl_nolerp;
466 extern cvar_t cl_pitchdriftspeed;
467 extern cvar_t lookspring;
468 extern cvar_t lookstrafe;
469 extern cvar_t sensitivity;
471 extern cvar_t freelook;
473 extern cvar_t m_pitch;
475 extern cvar_t m_forward;
476 extern cvar_t m_side;
478 extern cvar_t r_draweffects;
480 extern cvar_t cl_explosions;
481 extern cvar_t cl_stainmaps;
483 // these are updated by CL_ClearState
484 extern int cl_num_entities;
485 extern int cl_num_static_entities;
486 extern int cl_num_temp_entities;
487 extern int cl_num_brushmodel_entities;
489 extern entity_t *cl_entities;
490 extern qbyte *cl_entities_active;
491 extern entity_t *cl_static_entities;
492 extern entity_t *cl_temp_entities;
493 extern entity_render_t **cl_brushmodel_entities;
494 extern cl_effect_t *cl_effects;
495 extern beam_t *cl_beams;
496 extern dlight_t *cl_dlights;
497 extern lightstyle_t *cl_lightstyle;
500 extern client_state_t cl;
502 extern void CL_AllocDlight (entity_render_t *ent, vec3_t org, float radius, float red, float green, float blue, float decay, float lifetime);
503 extern void CL_DecayLights (void);
505 //=============================================================================
513 void CL_EstablishConnection(const char *host);
515 void CL_Disconnect (void);
516 void CL_Disconnect_f (void);
518 void CL_BoundingBoxForEntity(entity_render_t *ent);
520 extern cvar_t cl_beams_polygons;
521 extern cvar_t cl_beams_relative;
522 extern cvar_t cl_beams_lightatend;
529 int down[2]; // key nums holding it down
530 int state; // low bit is down state
534 extern kbutton_t in_mlook, in_klook;
535 extern kbutton_t in_strafe;
536 extern kbutton_t in_speed;
538 void CL_InitInput (void);
539 void CL_SendCmd (usercmd_t *cmd);
540 void CL_SendMove (usercmd_t *cmd);
542 void CL_LerpUpdate(entity_t *e);
543 void CL_ParseTEnt (void);
544 void CL_RelinkBeams (void);
546 void CL_ClearTempEntities (void);
547 entity_t *CL_NewTempEntity (void);
549 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
551 void CL_ClearState (void);
554 int CL_ReadFromServer (void);
555 void CL_WriteToServer (usercmd_t *cmd);
556 void CL_BaseMove (usercmd_t *cmd);
559 float CL_KeyState (kbutton_t *key);
560 char *Key_KeynumToString (int keynum);
565 void CL_StopPlayback(void);
566 void CL_ReadDemoMessage(void);
567 void CL_WriteDemoMessage(void);
569 void CL_NextDemo(void);
570 void CL_Stop_f(void);
571 void CL_Record_f(void);
572 void CL_PlayDemo_f(void);
573 void CL_TimeDemo_f(void);
578 void CL_Parse_Init(void);
579 void CL_ParseServerMessage(void);
580 void CL_Parse_DumpPacket(void);
585 void V_StartPitchDrift (void);
586 void V_StopPitchDrift (void);
589 float V_CalcRoll (vec3_t angles, vec3_t velocity);
590 void V_UpdateBlends (void);
591 void V_ParseDamage (void);
597 void CL_InitTEnts (void);
603 void CL_Particles_Clear(void);
604 void CL_Particles_Init(void);
606 void CL_ParseParticleEffect (void);
607 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
608 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
609 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
610 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
611 void CL_PlasmaBurn (vec3_t org);
612 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
613 void CL_Stardust (vec3_t mins, vec3_t maxs, int count);
614 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
615 void CL_Flames (vec3_t org, vec3_t vel, int count);
616 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
617 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
618 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
619 void CL_EntityParticles (entity_t *ent);
620 void CL_BlobExplosion (vec3_t org);
621 void CL_ParticleExplosion (vec3_t org);
622 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
623 void CL_LavaSplash (vec3_t org);
624 void CL_TeleportSplash (vec3_t org);
625 void CL_BeamParticle (const vec3_t start, const vec3_t end, vec_t radius, float red, float green, float blue, float alpha, float lifetime);
626 void CL_Tei_Smoke(const vec3_t pos, const vec3_t dir, int count);
627 void CL_Tei_PlasmaHit(const vec3_t pos, const vec3_t dir, int count);
628 void CL_MoveParticles(void);
629 void R_MoveExplosions(void);
630 void R_NewExplosion(vec3_t org);
632 #include "cl_screen.h"
637 int x, y, width, height;
641 matrix4x4_t viewentitymatrix;
643 // fullscreen color blend
646 entity_render_t **entities;
652 int maxdrawqueuesize;
658 extern mempool_t *cl_refdef_mempool;
662 void Host_PerformSpawnServerAndLoadGame(void);