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"
30 #include "cl_particles.h"
33 // flags for rtlight rendering
34 #define LIGHTFLAG_NORMALMODE 1
35 #define LIGHTFLAG_REALTIMEMODE 2
37 typedef struct tridecal_s
39 // color and initial alpha value
40 float texcoord2f[3][2];
43 float plane[4]; // backface culling
44 // how long this decal has lived so far (the actual fade begins at cl_decals_time)
46 // if >= 0 this indicates the decal should follow an animated triangle
48 // for visibility culling
50 // old decals are killed to obey cl_decals_max
51 unsigned int decalsequence;
55 typedef struct decalsystem_s
58 double lastupdatetime;
67 unsigned short *element3s;
71 typedef struct effect_s
80 // these are for interpolation
90 // draw this as lightning polygons, or a model?
92 struct model_s *model;
98 typedef struct rtlight_particle_s
105 typedef struct rtlight_s
107 // note that the world to light matrices are inversely scaled (divided) by lightradius
110 /// matrix for transforming light filter coordinates to world coordinates
111 matrix4x4_t matrix_lighttoworld;
112 /// matrix for transforming world coordinates to light filter coordinates
113 matrix4x4_t matrix_worldtolight;
114 /// typically 1 1 1, can be lower (dim) or higher (overbright)
116 /// size of the light (remove?)
119 char cubemapname[64];
120 /// light style to monitor for brightness
122 /// whether light should render shadows (see castshadows for whether it actually does this frame)
124 /// intensity of corona to render
126 /// radius scale of corona to render (1.0 means same as light radius)
127 vec_t coronasizescale;
128 /// ambient intensity to render
130 /// diffuse intensity to render
132 /// specular intensity to render
134 /// LIGHTFLAG_* flags
137 // generated properties
138 /// used only for casting shadows
143 /// when r_shadow_culllights_trace is set, this is refreshed by each successful trace.
146 // rendering properties, updated each time a light is rendered
147 // this is rtlight->color * d_lightstylevalue
149 /// used by corona updates, due to occlusion query
150 float corona_visibility;
151 unsigned int corona_queryindex_visiblepixels;
152 unsigned int corona_queryindex_allpixels;
153 /// this is R_GetCubemap(rtlight->cubemapname)
154 rtexture_t *currentcubemap;
155 /// set by R_Shadow_PrepareLight to decide whether R_Shadow_DrawLight should draw it
157 /// set by R_Shadow_PrepareLight to indicate whether R_Shadow_DrawShadowMaps should do anything
159 /// these fields are set by R_Shadow_PrepareLight for later drawing
160 int cached_numlightentities;
161 int cached_numlightentities_noselfshadow;
162 int cached_numshadowentities;
163 int cached_numshadowentities_noselfshadow;
164 int cached_numsurfaces;
165 struct entity_render_s **cached_lightentities;
166 struct entity_render_s **cached_lightentities_noselfshadow;
167 struct entity_render_s **cached_shadowentities;
168 struct entity_render_s **cached_shadowentities_noselfshadow;
169 unsigned char *cached_shadowtrispvs;
170 unsigned char *cached_lighttrispvs;
171 int *cached_surfacelist;
172 // reduced light cullbox from GetLightInfo
173 vec3_t cached_cullmins;
174 vec3_t cached_cullmaxs;
175 // current shadow-caster culling planes based on view
176 // (any geometry outside these planes can not contribute to the visible
177 // shadows in any way, and thus can be culled safely)
178 int cached_numfrustumplanes;
179 mplane_t cached_frustumplanes[5]; // see R_Shadow_ComputeShadowCasterCullingPlanes
181 /// static light info
182 /// true if this light should be compiled as a static light
184 /// true if this is a compiled world light, cleared if the light changes
186 /// the size that this light should have (assuming no scene LOD kicking in to reduce it)
187 int shadowmapsidesize;
188 /// position of this light in the shadowmap atlas
189 int shadowmapatlasposition[2];
190 /// size of one side of this light in the shadowmap atlas (for omnidirectional shadowmaps this is the min corner of a 2x3 arrangement, or a 4x3 arrangement in the case of noselfshadow entities being present)
191 int shadowmapatlassidesize;
192 /// optimized and culled mesh to render for world entity shadows
193 shadowmesh_t *static_meshchain_shadow_shadowmap;
194 /// used for visibility testing (more exact than bbox)
196 int static_numleafpvsbytes;
197 int *static_leaflist;
198 unsigned char *static_leafpvs;
199 /// surfaces seen by light
200 int static_numsurfaces;
201 int *static_surfacelist;
202 /// flag bits indicating which triangles of the world model should cast
203 /// shadows, and which ones should be lit
205 /// this avoids redundantly scanning the triangles in each surface twice
206 /// for whether they should cast shadows, once in culling and once in the
207 /// actual shadowmarklist production.
208 int static_numshadowtrispvsbytes;
209 unsigned char *static_shadowtrispvs;
210 /// this allows the lighting batch code to skip backfaces andother culled
211 /// triangles not relevant for lighting
212 /// (important on big surfaces such as terrain)
213 int static_numlighttrispvsbytes;
214 unsigned char *static_lighttrispvs;
215 /// masks of all shadowmap sides that have any potential static receivers or casters
216 int static_shadowmap_receivers;
217 int static_shadowmap_casters;
218 /// particle-tracing cache for global illumination
219 int particlecache_numparticles;
220 int particlecache_maxparticles;
221 int particlecache_updateparticle;
222 rtlight_particle_t *particlecache_particles;
224 /// bouncegrid light info
225 float bouncegrid_photoncolor[3];
226 float bouncegrid_photons;
228 int bouncegrid_traces;
229 float bouncegrid_effectiveradius;
233 typedef struct dlight_s
235 // destroy light after this time
238 // the entity that owns this light (can be NULL)
240 struct entity_render_s *ent;
242 // (worldlight: saved to .rtlights file)
244 // worldlight orientation
246 // (worldlight: saved to .rtlights file)
248 // dlight orientation/scaling/location
252 // (worldlight: saved to .rtlights file)
254 // cubemap name to use on this light
255 // (worldlight: saved to .rtlights file)
256 char cubemapname[64];
257 // make light flash while selected
260 // brightness (not really radius anymore)
261 // (worldlight: saved to .rtlights file)
263 // drop intensity this much each second
266 // intensity value which is dropped over time
269 // initial values for intensity to modify
273 // light style which controls intensity of this light
274 // (worldlight: saved to .rtlights file)
277 // (worldlight: saved to .rtlights file)
280 // (worldlight: saved to .rtlights file)
282 // radius scale of corona to render (1.0 means same as light radius)
283 // (worldlight: saved to .rtlights file)
284 vec_t coronasizescale;
285 // ambient intensity to render
286 // (worldlight: saved to .rtlights file)
288 // diffuse intensity to render
289 // (worldlight: saved to .rtlights file)
291 // specular intensity to render
292 // (worldlight: saved to .rtlights file)
295 // (worldlight: saved to .rtlights file)
297 // linked list of world lights
299 struct dlight_s *next;
300 // embedded rtlight struct for renderer
306 // this is derived from processing of the framegroupblend array
307 // note: technically each framegroupblend can produce two of these, but that
308 // never happens in practice because no one blends between more than 2
309 // framegroups at once
310 #define MAX_FRAMEBLENDS (MAX_FRAMEGROUPBLENDS * 2)
311 typedef struct frameblend_s
318 // LadyHavoc: this struct is intended for the renderer but some fields are
319 // used by the client.
321 // The renderer should not rely on any changes to this struct to be persistent
322 // across multiple frames because temp entities are wiped every frame, but it
323 // is acceptable to cache things in this struct that are not critical.
325 // For example the r_cullentities_trace code does such caching.
326 typedef struct entity_render_s
332 // transform matrix for model to world
334 // transform matrix for world to model
335 matrix4x4_t inversematrix;
336 // opacity (alpha) of the model
338 // size the model is shown
340 // transparent sorting offset
341 float transparent_offset;
345 // number of the entity represents, or 0 for non-network entities
347 // literal colormap colors for renderer, if both are 0 0 0 it is not colormapped
348 vec3_t colormap_pantscolor;
349 vec3_t colormap_shirtcolor;
350 // light, particles, etc
352 // qw CTF flags and other internal-use-only effect bits
359 // colormod tinting of models
363 // interpolated animation - active framegroups and blend factors
364 framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
366 // time of last model change (for shader animations)
369 // calculated by the renderer (but not persistent)
371 // calculated during R_AddModelEntities
373 // subframe numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use subframeblend[0].subframe
374 frameblend_t frameblend[MAX_FRAMEBLENDS];
375 // skeletal animation data (if skeleton.relativetransforms is not NULL, it overrides frameblend)
376 skeleton_t *skeleton;
378 // animation cache (pointers allocated using R_FrameData_Alloc)
379 // ONLY valid during R_RenderView! may be NULL (not cached)
380 float *animcache_vertex3f;
381 r_meshbuffer_t *animcache_vertex3f_vertexbuffer;
382 int animcache_vertex3f_bufferoffset;
383 float *animcache_normal3f;
384 r_meshbuffer_t *animcache_normal3f_vertexbuffer;
385 int animcache_normal3f_bufferoffset;
386 float *animcache_svector3f;
387 r_meshbuffer_t *animcache_svector3f_vertexbuffer;
388 int animcache_svector3f_bufferoffset;
389 float *animcache_tvector3f;
390 r_meshbuffer_t *animcache_tvector3f_vertexbuffer;
391 int animcache_tvector3f_bufferoffset;
392 // gpu-skinning shader needs transforms in a certain format, we have to
393 // upload this to a uniform buffer for the shader to use, and also keep a
394 // backup copy in system memory for the dynamic batch fallback code
395 // if this is not NULL, the other animcache variables are NULL
396 float *animcache_skeletaltransform3x4;
397 r_meshbuffer_t *animcache_skeletaltransform3x4buffer;
398 int animcache_skeletaltransform3x4offset;
399 int animcache_skeletaltransform3x4size;
401 // CL_UpdateEntityShading reads these fields
402 // used only if RENDER_CUSTOMIZEDMODELLIGHT is set
403 vec3_t custommodellight_ambient;
404 vec3_t custommodellight_diffuse;
405 vec3_t custommodellight_lightdir;
406 // CSQC entities get their shading from the root of their attachment chain
407 float custommodellight_origin[3];
409 // derived lighting parameters (CL_UpdateEntityShading)
411 // used by MATERIALFLAG_FULLBRIGHT which is MATERIALFLAG_MODELLIGHT with
412 // this as ambient color, along with MATERIALFLAG_NORTLIGHT
413 float render_fullbright[3];
414 // color tint for the base pass glow textures if any
415 float render_glowmod[3];
416 // MATERIALFLAG_MODELLIGHT uses these parameters
417 float render_modellight_ambient[3];
418 float render_modellight_diffuse[3];
419 float render_modellight_lightdir_world[3];
420 float render_modellight_lightdir_local[3];
421 float render_modellight_specular[3];
422 // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
423 float render_lightmap_ambient[3];
424 float render_lightmap_diffuse[3];
425 float render_lightmap_specular[3];
426 // rtlights use these colors for the materials on this entity
427 float render_rtlight_diffuse[3];
428 float render_rtlight_specular[3];
429 // ignore lightmap and use fixed lighting settings on this entity (e.g. FULLBRIGHT)
430 qbool render_modellight_forced;
431 // do not process per pixel lights on this entity at all (like MATERIALFLAG_NORTLIGHT)
432 qbool render_rtlight_disabled;
433 // use the 3D lightmap from q3bsp on this entity
434 qbool render_lightgrid;
436 // storage of decals on this entity
437 // (note: if allowdecals is set, be sure to call R_DecalSystem_Reset on removal!)
439 decalsystem_t decalsystem;
441 // FIELDS UPDATED BY RENDERER:
442 // last time visible during trace culling
443 double last_trace_visibility;
445 // user wavefunc parameters (from csqc)
446 vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
450 typedef struct entity_persistent_s
452 vec3_t trail_origin; // previous position for particle trail spawning
453 vec3_t oldorigin; // lerp
454 vec3_t oldangles; // lerp
455 vec3_t neworigin; // lerp
456 vec3_t newangles; // lerp
457 vec_t lerpstarttime; // lerp
458 vec_t lerpdeltatime; // lerp
459 float muzzleflash; // muzzleflash intensity, fades over time
460 float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
461 qbool trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
465 typedef struct entity_s
467 // baseline state (default values)
468 entity_state_t state_baseline;
469 // previous state (interpolating from this)
470 entity_state_t state_previous;
471 // current state (interpolating to this)
472 entity_state_t state_current;
474 // used for regenerating parts of render
475 entity_persistent_t persistent;
477 // the only data the renderer should know about
478 entity_render_t render;
482 typedef struct usercmd_s
486 // intended velocities
491 vec3_t cursor_screen;
494 vec3_t cursor_impact;
495 vec3_t cursor_normal;
496 vec_t cursor_fraction;
497 int cursor_entitynumber;
499 double time; // time the move is executed for (cl_movement: clienttime, non-cl_movement: receivetime)
500 double receivetime; // time the move was received at
501 double clienttime; // time to which server state the move corresponds to
502 int msec; // for predicted moves
505 unsigned int sequence;
506 qbool applied; // if false we're still accumulating a move
507 qbool predicted; // if true the sequence should be sent as 0
509 // derived properties
516 typedef struct lightstyle_s
519 char map[MAX_STYLESTRING];
522 typedef struct scoreboard_s
524 char name[MAX_SCOREBOARDNAME];
526 int colors; // two 4 bit fields
529 char qw_userinfo[MAX_USERINFO_STRING];
536 char qw_skin[MAX_QPATH];
539 typedef struct cshift_s
542 float percent; // 0-255
543 float alphafade; // (any speed)
546 #define CSHIFT_CONTENTS 0
547 #define CSHIFT_DAMAGE 1
548 #define CSHIFT_BONUS 2
549 #define CSHIFT_POWERUP 3
550 #define CSHIFT_VCSHIFT 4
551 #define NUM_CSHIFTS 5
553 #define NAME_LENGTH 64
557 // client_state_t should hold all pieces of the client state
560 #define SIGNONS 4 // signon messages to receive before connected
562 typedef enum cactive_e
564 ca_uninitialized, // during early startup
565 ca_dedicated, // a dedicated server with no ability to start a client
566 ca_disconnected, // full screen console with no connection
567 ca_connected // valid netcon, talking to a server
571 typedef enum qw_downloadtype_e
581 #define CL_MAX_DOWNLOADACKS 4
583 typedef struct cl_downloadack_s
589 typedef struct cl_soundstats_s
593 int latency_milliseconds;
598 // the client_static_t structure is persistent through an arbitrary number
599 // of server connections
601 typedef struct client_static_s
605 // all client memory allocations go in these pools
606 mempool_t *levelmempool;
607 mempool_t *permanentmempool;
610 // -1 = don't play demos
612 // list of demos in loop
613 char demos[MAX_DEMOS][MAX_DEMONAME];
614 // the actively playing demo (set by CL_PlayDemo_f)
615 char demoname[MAX_QPATH];
617 // demo recording info must be here, because record is started before
618 // entering a map (and clearing client_state_t)
620 fs_offset_t demo_lastcsprogssize;
621 int demo_lastcsprogscrc;
623 qbool demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo
625 // -1 = use normal cd track
628 // realtime at second frame of timedemo (LadyHavoc: changed to double)
630 int td_frames; // total frames parsed
631 double td_onesecondnexttime;
632 double td_onesecondframes;
633 double td_onesecondrealtime;
634 double td_onesecondminfps;
635 double td_onesecondmaxfps;
636 double td_onesecondavgfps;
637 int td_onesecondavgcount;
638 // LadyHavoc: pausedemo
641 // sound mixer statistics for showsound display
642 cl_soundstats_t soundstats;
644 qbool connect_trying;
645 int connect_remainingtries;
646 double connect_nextsendtime;
647 lhnetsocket_t *connect_mysocket;
648 lhnetaddress_t connect_address;
649 lhnetaddress_t rcon_address;
650 // protocol version of the server we're connected to
651 // (kept outside client_state_t because it's used between levels)
652 protocolversion_t protocol;
656 lhnetaddress_t rcon_addresses[MAX_RCONS];
657 char rcon_commands[MAX_RCONS][MAX_INPUTLINE];
658 double rcon_timeout[MAX_RCONS];
661 // connection information
664 // network connection
667 // download information
668 // (note: qw_download variables are also used)
669 cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
671 // input sequence numbers are not reset on level change, only connect
672 unsigned int servermovesequence;
674 // quakeworld stuff below
676 // value of "qport" cvar at time of connection
678 // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
679 unsigned int qw_incoming_sequence;
680 unsigned int qw_outgoing_sequence;
682 // current file download buffer (only saved when file is completed)
683 char qw_downloadname[MAX_QPATH];
684 unsigned char *qw_downloadmemory;
685 int qw_downloadmemorycursize;
686 int qw_downloadmemorymaxsize;
687 int qw_downloadnumber;
688 int qw_downloadpercent;
689 qw_downloadtype_t qw_downloadtype;
690 // transfer rate display
691 double qw_downloadspeedtime;
692 int qw_downloadspeedcount;
693 int qw_downloadspeedrate;
694 qbool qw_download_deflate;
696 // current file upload buffer (for uploading screenshots to server)
697 unsigned char *qw_uploaddata;
702 // this normally contains the following keys in quakeworld:
703 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
704 char userinfo[MAX_USERINFO_STRING];
706 // extra user info for the "connect" command
707 char connect_userinfo[MAX_USERINFO_STRING];
709 #ifdef CONFIG_VIDEO_CAPTURE
710 // video capture stuff
711 capturevideostate_t capturevideo;
717 // ProQuake compatibility stuff
718 int proquake_servermod; // 0 = not proquake, 1 = proquake
719 int proquake_serverversion; // actual proquake server version * 10 (3.40 = 34, etc)
720 int proquake_serverflags; // 0 (PQF_CHEATFREE not supported)
722 // don't write-then-read csprogs.dat (useful for demo playback)
723 unsigned char *caughtcsprogsdata;
724 fs_offset_t caughtcsprogsdatasize;
726 int r_speeds_graph_length;
727 int r_speeds_graph_current;
728 int *r_speeds_graph_data;
731 int r_speeds_graph_datamin[r_stat_count];
732 int r_speeds_graph_datamax[r_stat_count];
736 extern client_static_t cls;
742 qbool drawenginesbar;
746 typedef enum cl_parsingtextmode_e
748 CL_PARSETEXTMODE_NONE,
749 CL_PARSETEXTMODE_PING,
750 CL_PARSETEXTMODE_STATUS,
751 CL_PARSETEXTMODE_STATUS_PLAYERID,
752 CL_PARSETEXTMODE_STATUS_PLAYERIP
754 cl_parsingtextmode_t;
756 typedef struct cl_locnode_s
758 struct cl_locnode_s *next;
764 typedef struct showlmp_s
775 // the client_state_t structure is wiped completely at every
778 typedef struct client_state_s
780 // true if playing in a local game and no one else is connected
783 // send a clc_nop periodically until connected
786 // current input being accumulated by mouse/joystick/etc input
788 // latest moves sent to the server that have not been confirmed yet
789 usercmd_t movecmd[CL_MAX_USERCMDS];
791 // information for local display
793 int stats[MAX_CL_STATS];
794 float *statsf; // points to stats[] array
795 // last known inventory bit flags, for blinking
797 // cl.time of acquiring item, for blinking
798 float item_gettime[32];
799 // last known STAT_ACTIVEWEAPON
801 // cl.time of changing STAT_ACTIVEWEAPON
803 // use pain anim frame if cl.time < this
805 // for stair smoothing
807 double stairsmoothtime;
809 // color shifts for damage, powerups
810 cshift_t cshifts[NUM_CSHIFTS];
812 cshift_t prev_cshifts[NUM_CSHIFTS];
814 // the client maintains its own idea of view angles, which are
815 // sent to the server each frame. The server sets punchangle when
816 // the view is temporarily offset, and an angle reset commands at the start
817 // of each level and after teleporting.
819 // mviewangles is read from demo
820 // viewangles is either client controlled or lerped from mviewangles
821 vec3_t mviewangles[2], viewangles;
822 // update by server, used by qc to do weapon recoil
823 vec3_t mpunchangle[2], punchangle;
824 // update by server, can be used by mods to kick view around
825 vec3_t mpunchvector[2], punchvector;
826 // update by server, used for lean+bob (0 is newest)
827 vec3_t mvelocity[2], velocity;
828 // update by server, can be used by mods for zooming
829 vec_t mviewzoom[2], viewzoom;
830 // if true interpolation the mviewangles and other interpolation of the
831 // player is disabled until the next network packet
832 // this is used primarily by teleporters, and when spectating players
833 // special checking of the old fixangle[1] is used to differentiate
834 // between teleporting and spectating
837 // client movement simulation
838 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
839 // set by CL_ClientMovement_Replay functions
840 qbool movement_predicted;
841 // if true the CL_ClientMovement_Replay function will update origin, etc
842 qbool movement_replay;
843 // simulated data (this is valid even if cl.movement is false)
844 vec3_t movement_origin;
845 vec3_t movement_velocity;
846 // whether the replay should allow a jump at the first sequence
847 qbool movement_replay_canjump;
849 // previous gun angles (for leaning effects)
850 vec3_t gunangles_prev;
851 vec3_t gunangles_highpass;
852 vec3_t gunangles_adjustment_lowpass;
853 vec3_t gunangles_adjustment_highpass;
854 // previous gun angles (for leaning effects)
856 vec3_t gunorg_highpass;
857 vec3_t gunorg_adjustment_lowpass;
858 vec3_t gunorg_adjustment_highpass;
860 // pitch drifting vars
867 //[515]: added for csqc purposes
868 float sensitivityscale;
869 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
870 qbool csqc_wantsmousemove;
871 struct model_s *csqc_model_precache[MAX_MODELS];
873 // local amount for smoothing stepups
883 double lastongroundtime;
884 double hitgroundtime;
888 double calcrefdef_prevtime;
890 // don't change view angle, full screen, etc
892 // latched at intermission start
893 double completed_time;
895 // the timestamp of the last two messages
898 // clients view of time, time should be between mtime[0] and mtime[1] to
899 // generate a lerp point for other data, oldtime is the previous frame's
900 // value of time, frametime is the difference between time and oldtime
901 // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
902 // is only forcefully limited when a packet is received
903 double time, oldtime;
904 // how long it has been since the previous client frame in real time
905 // (not game time, for that use cl.time - cl.oldtime)
906 double realframetime;
908 // fade var for fading while dead
911 // motionblur alpha level variable
912 float motionbluralpha;
914 // copy of realtime from last recieved message, for net trouble icon
915 float last_received_message;
917 // information that is static for the entire time connected to a server
918 struct model_s *model_precache[MAX_MODELS];
919 struct sfx_s *sound_precache[MAX_SOUNDS];
921 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
922 char model_name[MAX_MODELS][MAX_QPATH];
923 char sound_name[MAX_SOUNDS][MAX_QPATH];
925 // for display on solo scoreboard
926 char worldmessage[40]; // map title (not related to filename)
927 // variants of map name
928 char worldbasename[MAX_QPATH]; // %s
929 char worldname[MAX_QPATH]; // maps/%s.bsp
930 char worldnamenoextension[MAX_QPATH]; // maps/%s
931 // cl_entitites[cl.viewentity] = player
933 // the real player entity (normally same as viewentity,
934 // different than viewentity if mod uses chasecam or other tricks)
935 int realplayerentity;
936 // this is updated to match cl.viewentity whenever it is in the clients
937 // range, basically this is used in preference to cl.realplayerentity for
938 // most purposes because when spectating another player it should show
939 // their information rather than yours
941 // max players that can be in this game
943 // type of game (deathmatch, coop, singleplayer)
946 // models and sounds used by engine code (particularly cl_parse.c)
947 dp_model_t *model_bolt;
948 dp_model_t *model_bolt2;
949 dp_model_t *model_bolt3;
950 dp_model_t *model_beam;
952 sfx_t *sfx_knighthit;
958 // indicates that the file "sound/misc/talk2.wav" was found (for use by team chat messages)
959 qbool foundteamchatsound;
961 // refresh related state
963 // cl_entitites[0].model
964 struct model_s *worldmodel;
970 int cdtrack, looptrack;
975 scoreboard_t *scores;
977 // keep track of svc_print parsing state (analyzes ping reports and status reports)
978 cl_parsingtextmode_t parsingtextmode;
979 int parsingtextplayerindex;
980 // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
981 // (which could eat the wrong ping report if the player issues one
982 // manually, but they would still see a ping report, just a later one
983 // caused by the scoreboard code rather than the one they intentionally
985 int parsingtextexpectingpingforscores;
987 // entity database stuff
988 // latest received entity frame numbers
989 #define LATESTFRAMENUMS 32
990 int latestframenumsposition;
991 int latestframenums[LATESTFRAMENUMS];
992 unsigned int latestsendnums[LATESTFRAMENUMS];
993 entityframe_database_t *entitydatabase;
994 entityframe4_database_t *entitydatabase4;
995 entityframeqw_database_t *entitydatabaseqw;
997 // keep track of quake entities because they need to be killed if they get stale
999 unsigned char isquakeentity[MAX_EDICTS];
1001 // bounding boxes for clientside movement
1002 vec3_t playerstandmins;
1003 vec3_t playerstandmaxs;
1004 vec3_t playercrouchmins;
1005 vec3_t playercrouchmaxs;
1007 // old decals are killed based on this
1008 unsigned int decalsequence;
1011 int max_csqcrenderentities;
1012 int max_static_entities;
1017 int max_brushmodel_entities;
1022 entity_render_t *csqcrenderentities;
1023 unsigned char *entities_active;
1024 entity_t *static_entities;
1025 cl_effect_t *effects;
1028 lightstyle_t *lightstyle;
1029 int *brushmodel_entities;
1030 particle_t *particles;
1031 showlmp_t *showlmps;
1034 int num_static_entities;
1035 int num_brushmodel_entities;
1043 double particles_updatetime;
1044 double decals_updatetime;
1048 // cl_serverextension_download feature
1049 int loadmodel_current;
1050 int downloadmodel_current;
1051 int loadmodel_total;
1052 int loadsound_current;
1053 int downloadsound_current;
1054 int loadsound_total;
1062 // local copy of the server infostring
1063 char qw_serverinfo[MAX_SERVERINFO_STRING];
1065 // time of last qw "pings" command sent to server while showing scores
1066 double last_ping_request;
1068 // used during connect
1071 // updated from serverinfo
1074 // unused: indicates whether the player is spectating
1075 // use cl.scores[cl.playerentity-1].qw_spectator instead
1076 //qbool qw_spectator;
1078 // last time an input packet was sent
1079 double lastpackettime;
1081 // movement parameters for client prediction
1082 unsigned int moveflags;
1083 float movevars_wallfriction;
1084 float movevars_waterfriction;
1085 float movevars_friction;
1086 float movevars_timescale;
1087 float movevars_gravity;
1088 float movevars_stopspeed;
1089 float movevars_maxspeed;
1090 float movevars_spectatormaxspeed;
1091 float movevars_accelerate;
1092 float movevars_airaccelerate;
1093 float movevars_wateraccelerate;
1094 float movevars_entgravity;
1095 float movevars_jumpvelocity;
1096 float movevars_edgefriction;
1097 float movevars_maxairspeed;
1098 float movevars_stepheight;
1099 float movevars_airaccel_qw;
1100 float movevars_airaccel_qw_stretchfactor;
1101 float movevars_airaccel_sideways_friction;
1102 float movevars_airstopaccelerate;
1103 float movevars_airstrafeaccelerate;
1104 float movevars_maxairstrafespeed;
1105 float movevars_airstrafeaccel_qw;
1106 float movevars_aircontrol;
1107 float movevars_aircontrol_power;
1108 float movevars_aircontrol_penalty;
1109 float movevars_warsowbunny_airforwardaccel;
1110 float movevars_warsowbunny_accel;
1111 float movevars_warsowbunny_topspeed;
1112 float movevars_warsowbunny_turnaccel;
1113 float movevars_warsowbunny_backtosideratio;
1114 float movevars_ticrate;
1115 float movevars_airspeedlimit_nonqw;
1117 // models used by qw protocol
1118 int qw_modelindex_spike;
1119 int qw_modelindex_player;
1120 int qw_modelindex_flag;
1121 int qw_modelindex_s_explod;
1123 vec3_t qw_intermission_origin;
1124 vec3_t qw_intermission_angles;
1126 // 255 is the most nails the QW protocol could send
1128 vec_t qw_nails[255][6];
1130 float qw_weaponkick;
1132 unsigned int qw_validsequence;
1134 unsigned int qw_deltasequence[QW_UPDATE_BACKUP];
1137 // server entity number corresponding to a clientside entity
1138 unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
1140 vec3_t csqc_vieworigin;
1141 vec3_t csqc_viewangles;
1142 vec3_t csqc_vieworiginfromengine;
1143 vec3_t csqc_viewanglesfromengine;
1144 matrix4x4_t csqc_viewmodelmatrixfromengine;
1145 qbool csqc_usecsqclistener;
1146 matrix4x4_t csqc_listenermatrix;
1147 char csqc_printtextbuf[MAX_INPUTLINE];
1149 // collision culling data
1152 // loc file stuff (points and boxes describing locations in the level)
1153 cl_locnode_t *locnodes;
1154 // this is updated to cl.movement_origin whenever health is < 1
1155 // used by %d print in say/say_team messages if cl_locs_enable is on
1156 vec3_t lastdeathorigin;
1158 // processing buffer used by R_BuildLightMap, reallocated as needed,
1159 // freed on each level change
1160 size_t buildlightmapmemorysize;
1161 unsigned char *buildlightmapmemory;
1163 // used by EntityState5_ReadUpdate
1164 skeleton_t *engineskeletonobjects;
1171 extern cvar_t cl_name;
1172 extern cvar_t cl_color;
1173 extern cvar_t cl_rate;
1174 extern cvar_t cl_rate_burstsize;
1175 extern cvar_t cl_pmodel;
1176 extern cvar_t cl_playermodel;
1177 extern cvar_t cl_playerskin;
1179 extern cvar_t rcon_password;
1180 extern cvar_t rcon_address;
1182 extern cvar_t cl_upspeed;
1183 extern cvar_t cl_forwardspeed;
1184 extern cvar_t cl_backspeed;
1185 extern cvar_t cl_sidespeed;
1187 extern cvar_t cl_movespeedkey;
1189 extern cvar_t cl_yawspeed;
1190 extern cvar_t cl_pitchspeed;
1192 extern cvar_t cl_anglespeedkey;
1194 extern cvar_t cl_autofire;
1196 extern cvar_t cl_shownet;
1197 extern cvar_t cl_nolerp;
1198 extern cvar_t cl_nettimesyncfactor;
1199 extern cvar_t cl_nettimesyncboundmode;
1200 extern cvar_t cl_nettimesyncboundtolerance;
1202 extern cvar_t cl_pitchdriftspeed;
1203 extern cvar_t lookspring;
1204 extern cvar_t lookstrafe;
1205 extern cvar_t sensitivity;
1207 extern cvar_t freelook;
1209 extern cvar_t m_pitch;
1210 extern cvar_t m_yaw;
1211 extern cvar_t m_forward;
1212 extern cvar_t m_side;
1214 extern cvar_t cl_autodemo;
1215 extern cvar_t cl_autodemo_nameformat;
1216 extern cvar_t cl_autodemo_delete;
1218 extern cvar_t r_draweffects;
1220 extern cvar_t cl_explosions_alpha_start;
1221 extern cvar_t cl_explosions_alpha_end;
1222 extern cvar_t cl_explosions_size_start;
1223 extern cvar_t cl_explosions_size_end;
1224 extern cvar_t cl_explosions_lifetime;
1225 extern cvar_t cl_stainmaps;
1226 extern cvar_t cl_stainmaps_clearonload;
1228 extern cvar_t cl_prydoncursor;
1229 extern cvar_t cl_prydoncursor_notrace;
1231 extern cvar_t cl_locs_enable;
1233 extern client_state_t cl;
1235 extern void CL_AllocLightFlash (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, char *cubemapname, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
1237 cl_locnode_t *CL_Locs_FindNearest(const vec3_t point);
1238 void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point);
1240 //=============================================================================
1246 double CL_Frame(double time);
1248 void CL_Shutdown (void);
1249 void CL_Init (void);
1251 void CL_EstablishConnection(const char *host, int firstarg);
1253 void CL_Disconnect (void);
1254 void CL_Disconnect_f(cmd_state_t *cmd);
1256 void CL_UpdateRenderEntity(entity_render_t *ent);
1257 void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
1258 void CL_UpdateViewEntities(void);
1263 typedef struct kbutton_s
1265 int down[2]; // key nums holding it down
1266 int state; // low bit is down state
1270 extern kbutton_t in_mlook, in_klook;
1271 extern kbutton_t in_strafe;
1272 extern kbutton_t in_speed;
1274 void CL_InitInput (void);
1275 void CL_SendMove (void);
1277 void CL_ValidateState(entity_state_t *s);
1278 void CL_MoveLerpEntityStates(entity_t *ent);
1279 void CL_LerpUpdate(entity_t *e);
1280 void CL_ParseTEnt (void);
1281 void CL_NewBeam (int ent, vec3_t start, vec3_t end, dp_model_t *m, int lightning);
1282 void CL_RelinkBeams (void);
1283 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1284 void CL_ClientMovement_Replay(void);
1286 void CL_ClearTempEntities (void);
1287 entity_render_t *CL_NewTempEntity (double shadertime);
1289 void CL_Effect(vec3_t org, dp_model_t *model, int startframe, int framecount, float framerate);
1291 void CL_ClearState (void);
1292 void CL_ExpandEntities(int num);
1293 void CL_ExpandCSQCRenderEntities(int num);
1294 void CL_SetInfo(const char *key, const char *value, qbool send, qbool allowstarkey, qbool allowmodel, qbool quiet);
1297 void CL_UpdateWorld (void);
1298 void CL_WriteToServer (void);
1299 void CL_Input (void);
1300 extern int cl_ignoremousemoves;
1303 float CL_KeyState (kbutton_t *key);
1308 /// adds the string as a clc_stringcmd to the client message.
1309 /// (used when there is no reason to generate a local command to do it)
1310 void CL_ForwardToServer (const char *s);
1312 /// adds the current command line as a clc_stringcmd to the client message.
1313 /// things like godmode, noclip, etc, are commands directed to the server,
1314 /// so when they are typed in at the console, they will need to be forwarded.
1315 void CL_ForwardToServer_f (cmd_state_t *cmd);
1316 void CL_InitCommands(void);
1322 void CL_StopPlayback(void);
1323 void CL_ReadDemoMessage(void);
1324 void CL_WriteDemoMessage(sizebuf_t *mesage);
1326 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
1327 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
1329 void CL_NextDemo(void);
1330 void CL_Stop_f(cmd_state_t *cmd);
1331 void CL_Record_f(cmd_state_t *cmd);
1332 void CL_PlayDemo_f(cmd_state_t *cmd);
1333 void CL_TimeDemo_f(cmd_state_t *cmd);
1335 void CL_Demo_Init(void);
1338 #include "cl_screen.h"
1340 extern qbool sb_showscores;
1342 typedef enum waterlevel_e
1346 WATERLEVEL_SWIMMING,
1347 WATERLEVEL_SUBMERGED
1351 typedef struct cl_clientmovement_state_s
1353 // entity to be ignored for movement
1354 struct prvm_edict_s *self;
1358 // current bounding box (different if crouched vs standing)
1361 // currently on the ground
1363 // currently crouching
1365 // what kind of water (SUPERCONTENTS_LAVA for instance)
1368 waterlevel_t waterlevel;
1369 // weird hacks when jumping out of water
1370 // (this is in seconds and counts down to 0)
1371 float waterjumptime;
1376 cl_clientmovement_state_t;
1377 void CL_ClientMovement_PlayerMove_Frame(cl_clientmovement_state_t *s);
1379 // warpzone prediction hack (CSQC builtin)
1380 void CL_RotateMoves(const matrix4x4_t *m);
1382 typedef enum meshname_e {
1383 MESH_SCENE, // CSQC R_PolygonBegin, potentially also engine particles and debug stuff
1387 extern entity_t cl_meshentities[NUM_MESHENTITIES];
1388 extern dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
1389 extern const char *cl_meshentitynames[NUM_MESHENTITIES];
1390 #define CL_Mesh_Scene() (&cl_meshentitymodels[MESH_SCENE])
1391 #define CL_Mesh_UI() (&cl_meshentitymodels[MESH_UI])
1392 void CL_MeshEntities_Scene_Clear(void);
1393 void CL_MeshEntities_Scene_AddRenderEntity(void);
1394 void CL_MeshEntities_Scene_FinalizeRenderEntity(void);
1395 void CL_UpdateEntityShading(void);
1397 void CL_NewFrameReceived(int num);
1398 void CL_ParseEntityLump(char *entitystring);
1399 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
1400 void CL_RelinkLightFlashes(void);
1401 void CL_Beam_AddPolygons(const beam_t *b);
1402 void CL_UpdateMoveVars(void);
1403 void CL_Locs_Reload_f(cmd_state_t *cmd);