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"
28 // NOTE: r_stat_name[] must match this indexing
35 r_stat_entities_surfaces,
36 r_stat_entities_triangles,
39 r_stat_world_surfaces,
40 r_stat_world_triangles,
41 r_stat_lightmapupdates,
42 r_stat_lightmapupdatepixels,
47 r_stat_draws_vertices,
48 r_stat_draws_elements,
51 r_stat_lights_scissored,
52 r_stat_lights_lighttriangles,
53 r_stat_lights_shadowtriangles,
54 r_stat_lights_dynamicshadowtriangles,
55 r_stat_bouncegrid_lights,
56 r_stat_bouncegrid_particles,
57 r_stat_bouncegrid_traces,
58 r_stat_bouncegrid_hits,
59 r_stat_bouncegrid_splats,
60 r_stat_bouncegrid_bounces,
61 r_stat_photoncache_animated,
62 r_stat_photoncache_cached,
63 r_stat_photoncache_traced,
65 r_stat_bloom_copypixels,
66 r_stat_bloom_drawpixels,
67 r_stat_indexbufferuploadcount,
68 r_stat_indexbufferuploadsize,
69 r_stat_vertexbufferuploadcount,
70 r_stat_vertexbufferuploadsize,
71 r_stat_framedatacurrent,
73 r_stat_bufferdatacurrent_vertex, // R_BUFFERDATA_ types are added to this index
74 r_stat_bufferdatacurrent_index16,
75 r_stat_bufferdatacurrent_index32,
76 r_stat_bufferdatacurrent_uniform,
77 r_stat_bufferdatasize_vertex, // R_BUFFERDATA_ types are added to this index
78 r_stat_bufferdatasize_index16,
79 r_stat_bufferdatasize_index32,
80 r_stat_bufferdatasize_uniform,
81 r_stat_animcache_vertexmesh_count,
82 r_stat_animcache_vertexmesh_vertices,
83 r_stat_animcache_vertexmesh_maxvertices,
84 r_stat_animcache_skeletal_count,
85 r_stat_animcache_skeletal_bones,
86 r_stat_animcache_skeletal_maxbones,
87 r_stat_animcache_shade_count,
88 r_stat_animcache_shade_vertices,
89 r_stat_animcache_shade_maxvertices,
90 r_stat_animcache_shape_count,
91 r_stat_animcache_shape_vertices,
92 r_stat_animcache_shape_maxvertices,
94 r_stat_batch_withgaps,
95 r_stat_batch_surfaces,
96 r_stat_batch_vertices,
97 r_stat_batch_triangles,
98 r_stat_batch_fast_batches,
99 r_stat_batch_fast_surfaces,
100 r_stat_batch_fast_vertices,
101 r_stat_batch_fast_triangles,
102 r_stat_batch_copytriangles_batches,
103 r_stat_batch_copytriangles_surfaces,
104 r_stat_batch_copytriangles_vertices,
105 r_stat_batch_copytriangles_triangles,
106 r_stat_batch_dynamic_batches,
107 r_stat_batch_dynamic_surfaces,
108 r_stat_batch_dynamic_vertices,
109 r_stat_batch_dynamic_triangles,
110 r_stat_batch_dynamicskeletal_batches,
111 r_stat_batch_dynamicskeletal_surfaces,
112 r_stat_batch_dynamicskeletal_vertices,
113 r_stat_batch_dynamicskeletal_triangles,
114 r_stat_batch_dynamic_batches_because_cvar,
115 r_stat_batch_dynamic_surfaces_because_cvar,
116 r_stat_batch_dynamic_vertices_because_cvar,
117 r_stat_batch_dynamic_triangles_because_cvar,
118 r_stat_batch_dynamic_batches_because_lightmapvertex,
119 r_stat_batch_dynamic_surfaces_because_lightmapvertex,
120 r_stat_batch_dynamic_vertices_because_lightmapvertex,
121 r_stat_batch_dynamic_triangles_because_lightmapvertex,
122 r_stat_batch_dynamic_batches_because_deformvertexes_autosprite,
123 r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite,
124 r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite,
125 r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite,
126 r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2,
127 r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2,
128 r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2,
129 r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2,
130 r_stat_batch_dynamic_batches_because_deformvertexes_normal,
131 r_stat_batch_dynamic_surfaces_because_deformvertexes_normal,
132 r_stat_batch_dynamic_vertices_because_deformvertexes_normal,
133 r_stat_batch_dynamic_triangles_because_deformvertexes_normal,
134 r_stat_batch_dynamic_batches_because_deformvertexes_wave,
135 r_stat_batch_dynamic_surfaces_because_deformvertexes_wave,
136 r_stat_batch_dynamic_vertices_because_deformvertexes_wave,
137 r_stat_batch_dynamic_triangles_because_deformvertexes_wave,
138 r_stat_batch_dynamic_batches_because_deformvertexes_bulge,
139 r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge,
140 r_stat_batch_dynamic_vertices_because_deformvertexes_bulge,
141 r_stat_batch_dynamic_triangles_because_deformvertexes_bulge,
142 r_stat_batch_dynamic_batches_because_deformvertexes_move,
143 r_stat_batch_dynamic_surfaces_because_deformvertexes_move,
144 r_stat_batch_dynamic_vertices_because_deformvertexes_move,
145 r_stat_batch_dynamic_triangles_because_deformvertexes_move,
146 r_stat_batch_dynamic_batches_because_tcgen_lightmap,
147 r_stat_batch_dynamic_surfaces_because_tcgen_lightmap,
148 r_stat_batch_dynamic_vertices_because_tcgen_lightmap,
149 r_stat_batch_dynamic_triangles_because_tcgen_lightmap,
150 r_stat_batch_dynamic_batches_because_tcgen_vector,
151 r_stat_batch_dynamic_surfaces_because_tcgen_vector,
152 r_stat_batch_dynamic_vertices_because_tcgen_vector,
153 r_stat_batch_dynamic_triangles_because_tcgen_vector,
154 r_stat_batch_dynamic_batches_because_tcgen_environment,
155 r_stat_batch_dynamic_surfaces_because_tcgen_environment,
156 r_stat_batch_dynamic_vertices_because_tcgen_environment,
157 r_stat_batch_dynamic_triangles_because_tcgen_environment,
158 r_stat_batch_dynamic_batches_because_tcmod_turbulent,
159 r_stat_batch_dynamic_surfaces_because_tcmod_turbulent,
160 r_stat_batch_dynamic_vertices_because_tcmod_turbulent,
161 r_stat_batch_dynamic_triangles_because_tcmod_turbulent,
162 r_stat_batch_dynamic_batches_because_interleavedarrays,
163 r_stat_batch_dynamic_surfaces_because_interleavedarrays,
164 r_stat_batch_dynamic_vertices_because_interleavedarrays,
165 r_stat_batch_dynamic_triangles_because_interleavedarrays,
166 r_stat_batch_dynamic_batches_because_nogaps,
167 r_stat_batch_dynamic_surfaces_because_nogaps,
168 r_stat_batch_dynamic_vertices_because_nogaps,
169 r_stat_batch_dynamic_triangles_because_nogaps,
170 r_stat_batch_dynamic_batches_because_derived,
171 r_stat_batch_dynamic_surfaces_because_derived,
172 r_stat_batch_dynamic_vertices_because_derived,
173 r_stat_batch_dynamic_triangles_because_derived,
174 r_stat_batch_entitycache_count,
175 r_stat_batch_entitycache_surfaces,
176 r_stat_batch_entitycache_vertices,
177 r_stat_batch_entitycache_triangles,
178 r_stat_batch_entityanimate_count,
179 r_stat_batch_entityanimate_surfaces,
180 r_stat_batch_entityanimate_vertices,
181 r_stat_batch_entityanimate_triangles,
182 r_stat_batch_entityskeletal_count,
183 r_stat_batch_entityskeletal_surfaces,
184 r_stat_batch_entityskeletal_vertices,
185 r_stat_batch_entityskeletal_triangles,
186 r_stat_batch_entitystatic_count,
187 r_stat_batch_entitystatic_surfaces,
188 r_stat_batch_entitystatic_vertices,
189 r_stat_batch_entitystatic_triangles,
190 r_stat_batch_entitycustom_count,
191 r_stat_batch_entitycustom_surfaces,
192 r_stat_batch_entitycustom_vertices,
193 r_stat_batch_entitycustom_triangles,
194 r_stat_count // size of array
198 // flags for rtlight rendering
199 #define LIGHTFLAG_NORMALMODE 1
200 #define LIGHTFLAG_REALTIMEMODE 2
202 typedef struct tridecal_s
204 // color and initial alpha value
205 float texcoord2f[3][2];
206 float vertex3f[3][3];
208 float plane[4]; // backface culling
209 // how long this decal has lived so far (the actual fade begins at cl_decals_time)
211 // if >= 0 this indicates the decal should follow an animated triangle
213 // for visibility culling
215 // old decals are killed to obey cl_decals_max
216 unsigned int decalsequence;
220 typedef struct decalsystem_s
223 double lastupdatetime;
232 unsigned short *element3s;
236 typedef struct effect_s
245 // these are for interpolation
252 typedef struct beam_s
255 // draw this as lightning polygons, or a model?
257 struct model_s *model;
263 typedef struct rtlight_particle_s
270 typedef struct rtlight_s
272 // shadow volumes are done entirely in model space, so there are no matrices for dealing with them... they just use the origin
274 // note that the world to light matrices are inversely scaled (divided) by lightradius
277 /// matrix for transforming light filter coordinates to world coordinates
278 matrix4x4_t matrix_lighttoworld;
279 /// matrix for transforming world coordinates to light filter coordinates
280 matrix4x4_t matrix_worldtolight;
281 /// typically 1 1 1, can be lower (dim) or higher (overbright)
283 /// size of the light (remove?)
286 char cubemapname[64];
287 /// light style to monitor for brightness
289 /// whether light should render shadows (see castshadows for whether it actually does this frame)
291 /// intensity of corona to render
293 /// radius scale of corona to render (1.0 means same as light radius)
294 vec_t coronasizescale;
295 /// ambient intensity to render
297 /// diffuse intensity to render
299 /// specular intensity to render
301 /// LIGHTFLAG_* flags
304 // generated properties
305 /// used only for shadow volumes
310 /// when r_shadow_culllights_trace is set, this is refreshed by each successful trace.
313 // rendering properties, updated each time a light is rendered
314 // this is rtlight->color * d_lightstylevalue
316 /// used by corona updates, due to occlusion query
317 float corona_visibility;
318 unsigned int corona_queryindex_visiblepixels;
319 unsigned int corona_queryindex_allpixels;
320 /// this is R_GetCubemap(rtlight->cubemapname)
321 rtexture_t *currentcubemap;
322 /// set by R_Shadow_PrepareLight to decide whether R_Shadow_DrawLight should draw it
324 /// set by R_Shadow_PrepareLight to indicate whether R_Shadow_DrawShadowMaps should do anything
325 qboolean castshadows;
326 /// these fields are set by R_Shadow_PrepareLight for later drawing
327 int cached_numlightentities;
328 int cached_numlightentities_noselfshadow;
329 int cached_numshadowentities;
330 int cached_numshadowentities_noselfshadow;
331 int cached_numsurfaces;
332 struct entity_render_s **cached_lightentities;
333 struct entity_render_s **cached_lightentities_noselfshadow;
334 struct entity_render_s **cached_shadowentities;
335 struct entity_render_s **cached_shadowentities_noselfshadow;
336 unsigned char *cached_shadowtrispvs;
337 unsigned char *cached_lighttrispvs;
338 int *cached_surfacelist;
339 // reduced light cullbox from GetLightInfo
340 vec3_t cached_cullmins;
341 vec3_t cached_cullmaxs;
342 // current shadow-caster culling planes based on view
343 // (any geometry outside these planes can not contribute to the visible
344 // shadows in any way, and thus can be culled safely)
345 int cached_numfrustumplanes;
346 mplane_t cached_frustumplanes[5]; // see R_Shadow_ComputeShadowCasterCullingPlanes
348 /// static light info
349 /// true if this light should be compiled as a static light
351 /// true if this is a compiled world light, cleared if the light changes
353 /// the shadowing mode used to compile this light
355 /// the size that this light should have (assuming no scene LOD kicking in to reduce it)
356 int shadowmapsidesize;
357 /// position of this light in the shadowmap atlas
358 int shadowmapatlasposition[2];
359 /// 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)
360 int shadowmapatlassidesize;
361 /// premade shadow volumes to render for world entity
362 shadowmesh_t *static_meshchain_shadow_zpass;
363 shadowmesh_t *static_meshchain_shadow_zfail;
364 shadowmesh_t *static_meshchain_shadow_shadowmap;
365 /// used for visibility testing (more exact than bbox)
367 int static_numleafpvsbytes;
368 int *static_leaflist;
369 unsigned char *static_leafpvs;
370 /// surfaces seen by light
371 int static_numsurfaces;
372 int *static_surfacelist;
373 /// flag bits indicating which triangles of the world model should cast
374 /// shadows, and which ones should be lit
376 /// this avoids redundantly scanning the triangles in each surface twice
377 /// for whether they should cast shadows, once in culling and once in the
378 /// actual shadowmarklist production.
379 int static_numshadowtrispvsbytes;
380 unsigned char *static_shadowtrispvs;
381 /// this allows the lighting batch code to skip backfaces andother culled
382 /// triangles not relevant for lighting
383 /// (important on big surfaces such as terrain)
384 int static_numlighttrispvsbytes;
385 unsigned char *static_lighttrispvs;
386 /// masks of all shadowmap sides that have any potential static receivers or casters
387 int static_shadowmap_receivers;
388 int static_shadowmap_casters;
389 /// particle-tracing cache for global illumination
390 int particlecache_numparticles;
391 int particlecache_maxparticles;
392 int particlecache_updateparticle;
393 rtlight_particle_t *particlecache_particles;
395 /// bouncegrid light info
396 float bouncegrid_photoncolor[3];
397 float bouncegrid_photons;
399 int bouncegrid_traces;
400 float bouncegrid_effectiveradius;
404 typedef struct dlight_s
406 // destroy light after this time
409 // the entity that owns this light (can be NULL)
411 struct entity_render_s *ent;
413 // (worldlight: saved to .rtlights file)
415 // worldlight orientation
417 // (worldlight: saved to .rtlights file)
419 // dlight orientation/scaling/location
423 // (worldlight: saved to .rtlights file)
425 // cubemap name to use on this light
426 // (worldlight: saved to .rtlights file)
427 char cubemapname[64];
428 // make light flash while selected
431 // brightness (not really radius anymore)
432 // (worldlight: saved to .rtlights file)
434 // drop intensity this much each second
437 // intensity value which is dropped over time
440 // initial values for intensity to modify
444 // light style which controls intensity of this light
445 // (worldlight: saved to .rtlights file)
448 // (worldlight: saved to .rtlights file)
451 // (worldlight: saved to .rtlights file)
453 // radius scale of corona to render (1.0 means same as light radius)
454 // (worldlight: saved to .rtlights file)
455 vec_t coronasizescale;
456 // ambient intensity to render
457 // (worldlight: saved to .rtlights file)
459 // diffuse intensity to render
460 // (worldlight: saved to .rtlights file)
462 // specular intensity to render
463 // (worldlight: saved to .rtlights file)
466 // (worldlight: saved to .rtlights file)
468 // linked list of world lights
470 struct dlight_s *next;
471 // embedded rtlight struct for renderer
477 // this is derived from processing of the framegroupblend array
478 // note: technically each framegroupblend can produce two of these, but that
479 // never happens in practice because no one blends between more than 2
480 // framegroups at once
481 #define MAX_FRAMEBLENDS (MAX_FRAMEGROUPBLENDS * 2)
482 typedef struct frameblend_s
489 // LordHavoc: this struct is intended for the renderer but some fields are
490 // used by the client.
492 // The renderer should not rely on any changes to this struct to be persistent
493 // across multiple frames because temp entities are wiped every frame, but it
494 // is acceptable to cache things in this struct that are not critical.
496 // For example the r_cullentities_trace code does such caching.
497 typedef struct entity_render_s
503 // transform matrix for model to world
505 // transform matrix for world to model
506 matrix4x4_t inversematrix;
507 // opacity (alpha) of the model
509 // size the model is shown
511 // transparent sorting offset
512 float transparent_offset;
516 // number of the entity represents, or 0 for non-network entities
518 // literal colormap colors for renderer, if both are 0 0 0 it is not colormapped
519 vec3_t colormap_pantscolor;
520 vec3_t colormap_shirtcolor;
521 // light, particles, etc
523 // qw CTF flags and other internal-use-only effect bits
530 // colormod tinting of models
534 // interpolated animation - active framegroups and blend factors
535 framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
537 // time of last model change (for shader animations)
540 // calculated by the renderer (but not persistent)
542 // calculated during R_AddModelEntities
544 // subframe numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use subframeblend[0].subframe
545 frameblend_t frameblend[MAX_FRAMEBLENDS];
546 // skeletal animation data (if skeleton.relativetransforms is not NULL, it overrides frameblend)
547 skeleton_t *skeleton;
549 // animation cache (pointers allocated using R_FrameData_Alloc)
550 // ONLY valid during R_RenderView! may be NULL (not cached)
551 float *animcache_vertex3f;
552 r_meshbuffer_t *animcache_vertex3f_vertexbuffer;
553 int animcache_vertex3f_bufferoffset;
554 float *animcache_normal3f;
555 r_meshbuffer_t *animcache_normal3f_vertexbuffer;
556 int animcache_normal3f_bufferoffset;
557 float *animcache_svector3f;
558 r_meshbuffer_t *animcache_svector3f_vertexbuffer;
559 int animcache_svector3f_bufferoffset;
560 float *animcache_tvector3f;
561 r_meshbuffer_t *animcache_tvector3f_vertexbuffer;
562 int animcache_tvector3f_bufferoffset;
563 // interleaved arrays for rendering and dynamic vertex buffers for them
564 r_vertexmesh_t *animcache_vertexmesh;
565 r_meshbuffer_t *animcache_vertexmesh_vertexbuffer;
566 int animcache_vertexmesh_bufferoffset;
567 // gpu-skinning shader needs transforms in a certain format, we have to
568 // upload this to a uniform buffer for the shader to use, and also keep a
569 // backup copy in system memory for the dynamic batch fallback code
570 // if this is not NULL, the other animcache variables are NULL
571 float *animcache_skeletaltransform3x4;
572 r_meshbuffer_t *animcache_skeletaltransform3x4buffer;
573 int animcache_skeletaltransform3x4offset;
574 int animcache_skeletaltransform3x4size;
576 // current lighting from map (updated ONLY by client code, not renderer)
577 vec3_t modellight_ambient;
578 vec3_t modellight_diffuse; // q3bsp
579 vec3_t modellight_lightdir; // q3bsp
581 // storage of decals on this entity
582 // (note: if allowdecals is set, be sure to call R_DecalSystem_Reset on removal!)
584 decalsystem_t decalsystem;
586 // FIELDS UPDATED BY RENDERER:
587 // last time visible during trace culling
588 double last_trace_visibility;
590 // user wavefunc parameters (from csqc)
591 vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
595 typedef struct entity_persistent_s
597 vec3_t trail_origin; // previous position for particle trail spawning
598 vec3_t oldorigin; // lerp
599 vec3_t oldangles; // lerp
600 vec3_t neworigin; // lerp
601 vec3_t newangles; // lerp
602 vec_t lerpstarttime; // lerp
603 vec_t lerpdeltatime; // lerp
604 float muzzleflash; // muzzleflash intensity, fades over time
605 float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
606 qboolean trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
610 typedef struct entity_s
612 // baseline state (default values)
613 entity_state_t state_baseline;
614 // previous state (interpolating from this)
615 entity_state_t state_previous;
616 // current state (interpolating to this)
617 entity_state_t state_current;
619 // used for regenerating parts of render
620 entity_persistent_t persistent;
622 // the only data the renderer should know about
623 entity_render_t render;
627 typedef struct usercmd_s
631 // intended velocities
636 vec3_t cursor_screen;
639 vec3_t cursor_impact;
640 vec3_t cursor_normal;
641 vec_t cursor_fraction;
642 int cursor_entitynumber;
644 double time; // time the move is executed for (cl_movement: clienttime, non-cl_movement: receivetime)
645 double receivetime; // time the move was received at
646 double clienttime; // time to which server state the move corresponds to
647 int msec; // for predicted moves
650 unsigned int sequence;
651 qboolean applied; // if false we're still accumulating a move
652 qboolean predicted; // if true the sequence should be sent as 0
654 // derived properties
661 typedef struct lightstyle_s
664 char map[MAX_STYLESTRING];
667 typedef struct scoreboard_s
669 char name[MAX_SCOREBOARDNAME];
671 int colors; // two 4 bit fields
674 char qw_userinfo[MAX_USERINFO_STRING];
681 char qw_skin[MAX_QPATH];
684 typedef struct cshift_s
687 float percent; // 0-255
688 float alphafade; // (any speed)
691 #define CSHIFT_CONTENTS 0
692 #define CSHIFT_DAMAGE 1
693 #define CSHIFT_BONUS 2
694 #define CSHIFT_POWERUP 3
695 #define CSHIFT_VCSHIFT 4
696 #define NUM_CSHIFTS 5
698 #define NAME_LENGTH 64
702 // client_state_t should hold all pieces of the client state
705 #define SIGNONS 4 // signon messages to receive before connected
707 typedef enum cactive_e
709 ca_uninitialized, // during early startup
710 ca_dedicated, // a dedicated server with no ability to start a client
711 ca_disconnected, // full screen console with no connection
712 ca_connected // valid netcon, talking to a server
716 typedef enum qw_downloadtype_e
726 typedef enum capturevideoformat_e
728 CAPTUREVIDEOFORMAT_AVI_I420,
729 CAPTUREVIDEOFORMAT_OGG_VORBIS_THEORA
731 capturevideoformat_t;
733 typedef struct capturevideostate_s
735 double startrealtime;
748 int soundsampleframe;
749 unsigned char *screenbuffer;
750 unsigned char *outbuffer;
751 char basename[MAX_QPATH];
754 // precomputed RGB to YUV tables
755 // converts the RGB values to YUV (see cap_avi.c for how to use them)
756 short rgbtoyuvscaletable[3][3][256];
757 unsigned char yuvnormalizetable[3][256];
759 // precomputed gamma ramp (only needed if the capturevideo module uses RGB output)
760 // note: to map from these values to RGB24, you have to multiply by 255.0/65535.0, then add 0.5, then cast to integer
761 unsigned short vidramp[256 * 3];
763 // stuff to be filled in by the video format module
764 capturevideoformat_t format;
765 const char *formatextension;
768 // cls.capturevideo.videofile = FS_OpenRealFile(va(vabuf, sizeof(vabuf), "%s.%s", cls.capturevideo.basename, cls.capturevideo.formatextension), "wb", false);
769 void (*endvideo) (void);
770 void (*videoframes) (int num);
771 void (*soundframe) (const portable_sampleframe_t *paintbuffer, size_t length);
773 // format specific data
774 void *formatspecific;
778 #define CL_MAX_DOWNLOADACKS 4
780 typedef struct cl_downloadack_s
786 typedef struct cl_soundstats_s
790 int latency_milliseconds;
795 // the client_static_t structure is persistent through an arbitrary number
796 // of server connections
798 typedef struct client_static_s
802 // all client memory allocations go in these pools
803 mempool_t *levelmempool;
804 mempool_t *permanentmempool;
807 // -1 = don't play demos
809 // list of demos in loop
810 char demos[MAX_DEMOS][MAX_DEMONAME];
811 // the actively playing demo (set by CL_PlayDemo_f)
812 char demoname[MAX_QPATH];
814 // demo recording info must be here, because record is started before
815 // entering a map (and clearing client_state_t)
816 qboolean demorecording;
817 fs_offset_t demo_lastcsprogssize;
818 int demo_lastcsprogscrc;
819 qboolean demoplayback;
820 qboolean demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo
822 // -1 = use normal cd track
825 // realtime at second frame of timedemo (LordHavoc: changed to double)
827 int td_frames; // total frames parsed
828 double td_onesecondnexttime;
829 double td_onesecondframes;
830 double td_onesecondrealtime;
831 double td_onesecondminfps;
832 double td_onesecondmaxfps;
833 double td_onesecondavgfps;
834 int td_onesecondavgcount;
835 // LordHavoc: pausedemo
838 // sound mixer statistics for showsound display
839 cl_soundstats_t soundstats;
841 qboolean connect_trying;
842 int connect_remainingtries;
843 double connect_nextsendtime;
844 lhnetsocket_t *connect_mysocket;
845 lhnetaddress_t connect_address;
846 lhnetaddress_t rcon_address;
847 // protocol version of the server we're connected to
848 // (kept outside client_state_t because it's used between levels)
849 protocolversion_t protocol;
853 lhnetaddress_t rcon_addresses[MAX_RCONS];
854 char rcon_commands[MAX_RCONS][MAX_INPUTLINE];
855 double rcon_timeout[MAX_RCONS];
858 // connection information
861 // network connection
864 // download information
865 // (note: qw_download variables are also used)
866 cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
868 // input sequence numbers are not reset on level change, only connect
869 unsigned int servermovesequence;
871 // quakeworld stuff below
873 // value of "qport" cvar at time of connection
875 // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
876 unsigned int qw_incoming_sequence;
877 unsigned int qw_outgoing_sequence;
879 // current file download buffer (only saved when file is completed)
880 char qw_downloadname[MAX_QPATH];
881 unsigned char *qw_downloadmemory;
882 int qw_downloadmemorycursize;
883 int qw_downloadmemorymaxsize;
884 int qw_downloadnumber;
885 int qw_downloadpercent;
886 qw_downloadtype_t qw_downloadtype;
887 // transfer rate display
888 double qw_downloadspeedtime;
889 int qw_downloadspeedcount;
890 int qw_downloadspeedrate;
891 qboolean qw_download_deflate;
893 // current file upload buffer (for uploading screenshots to server)
894 unsigned char *qw_uploaddata;
899 // this normally contains the following keys in quakeworld:
900 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
901 char userinfo[MAX_USERINFO_STRING];
903 // extra user info for the "connect" command
904 char connect_userinfo[MAX_USERINFO_STRING];
906 // video capture stuff
907 capturevideostate_t capturevideo;
912 // ProQuake compatibility stuff
913 int proquake_servermod; // 0 = not proquake, 1 = proquake
914 int proquake_serverversion; // actual proquake server version * 10 (3.40 = 34, etc)
915 int proquake_serverflags; // 0 (PQF_CHEATFREE not supported)
917 // don't write-then-read csprogs.dat (useful for demo playback)
918 unsigned char *caughtcsprogsdata;
919 fs_offset_t caughtcsprogsdatasize;
921 int r_speeds_graph_length;
922 int r_speeds_graph_current;
923 int *r_speeds_graph_data;
926 int r_speeds_graph_datamin[r_stat_count];
927 int r_speeds_graph_datamax[r_stat_count];
931 extern client_static_t cls;
937 qboolean drawenginesbar;
938 qboolean drawcrosshair;
943 PARTICLE_BILLBOARD = 0,
945 PARTICLE_ORIENTED_DOUBLESIDED = 2,
948 PARTICLE_INVALID = -1
961 typedef struct particletype_s
964 porientation_t orientation;
971 pt_dead, pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total
975 typedef struct decal_s
977 // fields used by rendering: (44 bytes)
978 unsigned short typeindex;
979 unsigned short texnum;
980 unsigned int decalsequence;
984 float alpha; // 0-255
985 unsigned char color[3];
986 unsigned char unused1;
987 int clusterindex; // cheap culling by pvs
989 // fields not used by rendering: (36 bytes in 32bit, 40 bytes in 64bit)
990 float time2; // used for decal fade
991 unsigned int owner; // decal stuck to this entity
992 dp_model_t *ownermodel; // model the decal is stuck to (used to make sure the entity is still alive)
993 vec3_t relativeorigin; // decal at this location in entity's coordinate space
994 vec3_t relativenormal; // decal oriented this way relative to entity's coordinate space
998 typedef struct particle_s
1000 // for faster batch rendering, particles are rendered in groups by effect (resulting in less perfect sorting but far less state changes)
1002 // fields used by rendering: (48 bytes)
1003 vec3_t sortorigin; // sort by this group origin, not particle org
1005 vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam
1007 float alpha; // 0-255
1008 float stretch; // only for sparks
1010 // fields not used by rendering: (44 bytes)
1013 float sizeincrease; // rate of size change per second
1014 float alphafade; // how much alpha reduces per second
1015 float time2; // used for snow fluttering and decal fade
1016 float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical)
1017 float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
1018 float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
1019 float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
1020 // float delayedcollisions; // time that p->bounce becomes active
1021 float delayedspawn; // time that particle appears and begins moving
1022 float die; // time when this particle should be removed, regardless of alpha
1024 // short variables grouped to save memory (4 bytes)
1025 short angle; // base rotation of particle
1026 short spin; // geometry rotation speed around the particle center normal
1028 // byte variables grouped to save memory (12 bytes)
1029 unsigned char color[3];
1030 unsigned char qualityreduction; // enables skipping of this particle according to r_refdef.view.qualityreduction
1031 unsigned char typeindex;
1032 unsigned char blendmode;
1033 unsigned char orientation;
1034 unsigned char texnum;
1035 unsigned char staincolor[3];
1036 signed char staintexnum;
1040 typedef enum cl_parsingtextmode_e
1042 CL_PARSETEXTMODE_NONE,
1043 CL_PARSETEXTMODE_PING,
1044 CL_PARSETEXTMODE_STATUS,
1045 CL_PARSETEXTMODE_STATUS_PLAYERID,
1046 CL_PARSETEXTMODE_STATUS_PLAYERIP
1048 cl_parsingtextmode_t;
1050 typedef struct cl_locnode_s
1052 struct cl_locnode_s *next;
1058 typedef struct showlmp_s
1069 // the client_state_t structure is wiped completely at every
1072 typedef struct client_state_s
1074 // true if playing in a local game and no one else is connected
1077 // send a clc_nop periodically until connected
1080 // current input being accumulated by mouse/joystick/etc input
1082 // latest moves sent to the server that have not been confirmed yet
1083 usercmd_t movecmd[CL_MAX_USERCMDS];
1085 // information for local display
1087 int stats[MAX_CL_STATS];
1088 float *statsf; // points to stats[] array
1089 // last known inventory bit flags, for blinking
1091 // cl.time of acquiring item, for blinking
1092 float item_gettime[32];
1093 // last known STAT_ACTIVEWEAPON
1095 // cl.time of changing STAT_ACTIVEWEAPON
1097 // use pain anim frame if cl.time < this
1099 // for stair smoothing
1101 double stairsmoothtime;
1103 // color shifts for damage, powerups
1104 cshift_t cshifts[NUM_CSHIFTS];
1105 // and content types
1106 cshift_t prev_cshifts[NUM_CSHIFTS];
1108 // the client maintains its own idea of view angles, which are
1109 // sent to the server each frame. The server sets punchangle when
1110 // the view is temporarily offset, and an angle reset commands at the start
1111 // of each level and after teleporting.
1113 // mviewangles is read from demo
1114 // viewangles is either client controlled or lerped from mviewangles
1115 vec3_t mviewangles[2], viewangles;
1116 // update by server, used by qc to do weapon recoil
1117 vec3_t mpunchangle[2], punchangle;
1118 // update by server, can be used by mods to kick view around
1119 vec3_t mpunchvector[2], punchvector;
1120 // update by server, used for lean+bob (0 is newest)
1121 vec3_t mvelocity[2], velocity;
1122 // update by server, can be used by mods for zooming
1123 vec_t mviewzoom[2], viewzoom;
1124 // if true interpolation the mviewangles and other interpolation of the
1125 // player is disabled until the next network packet
1126 // this is used primarily by teleporters, and when spectating players
1127 // special checking of the old fixangle[1] is used to differentiate
1128 // between teleporting and spectating
1129 qboolean fixangle[2];
1131 // client movement simulation
1132 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
1133 // set by CL_ClientMovement_Replay functions
1134 qboolean movement_predicted;
1135 // if true the CL_ClientMovement_Replay function will update origin, etc
1136 qboolean movement_replay;
1137 // simulated data (this is valid even if cl.movement is false)
1138 vec3_t movement_origin;
1139 vec3_t movement_velocity;
1140 // whether the replay should allow a jump at the first sequence
1141 qboolean movement_replay_canjump;
1143 // previous gun angles (for leaning effects)
1144 vec3_t gunangles_prev;
1145 vec3_t gunangles_highpass;
1146 vec3_t gunangles_adjustment_lowpass;
1147 vec3_t gunangles_adjustment_highpass;
1148 // previous gun angles (for leaning effects)
1150 vec3_t gunorg_highpass;
1151 vec3_t gunorg_adjustment_lowpass;
1152 vec3_t gunorg_adjustment_highpass;
1154 // pitch drifting vars
1161 //[515]: added for csqc purposes
1162 float sensitivityscale;
1163 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
1164 qboolean csqc_wantsmousemove;
1165 qboolean csqc_paused; // vortex: int because could be flags
1166 struct model_s *csqc_model_precache[MAX_MODELS];
1168 // local amount for smoothing stepups
1177 qboolean oldonground;
1178 double lastongroundtime;
1179 double hitgroundtime;
1181 float bobfall_speed;
1182 float bobfall_swing;
1183 double calcrefdef_prevtime;
1185 // don't change view angle, full screen, etc
1187 // latched at intermission start
1188 double completed_time;
1190 // the timestamp of the last two messages
1193 // clients view of time, time should be between mtime[0] and mtime[1] to
1194 // generate a lerp point for other data, oldtime is the previous frame's
1195 // value of time, frametime is the difference between time and oldtime
1196 // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
1197 // is only forcefully limited when a packet is received
1198 double time, oldtime;
1199 // how long it has been since the previous client frame in real time
1200 // (not game time, for that use cl.time - cl.oldtime)
1201 double realframetime;
1203 // fade var for fading while dead
1206 // motionblur alpha level variable
1207 float motionbluralpha;
1209 // copy of realtime from last recieved message, for net trouble icon
1210 float last_received_message;
1212 // information that is static for the entire time connected to a server
1213 struct model_s *model_precache[MAX_MODELS];
1214 struct sfx_s *sound_precache[MAX_SOUNDS];
1216 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
1217 char model_name[MAX_MODELS][MAX_QPATH];
1218 char sound_name[MAX_SOUNDS][MAX_QPATH];
1220 // for display on solo scoreboard
1221 char worldmessage[40]; // map title (not related to filename)
1222 // variants of map name
1223 char worldbasename[MAX_QPATH]; // %s
1224 char worldname[MAX_QPATH]; // maps/%s.bsp
1225 char worldnamenoextension[MAX_QPATH]; // maps/%s
1226 // cl_entitites[cl.viewentity] = player
1228 // the real player entity (normally same as viewentity,
1229 // different than viewentity if mod uses chasecam or other tricks)
1230 int realplayerentity;
1231 // this is updated to match cl.viewentity whenever it is in the clients
1232 // range, basically this is used in preference to cl.realplayerentity for
1233 // most purposes because when spectating another player it should show
1234 // their information rather than yours
1236 // max players that can be in this game
1238 // type of game (deathmatch, coop, singleplayer)
1241 // models and sounds used by engine code (particularly cl_parse.c)
1242 dp_model_t *model_bolt;
1243 dp_model_t *model_bolt2;
1244 dp_model_t *model_bolt3;
1245 dp_model_t *model_beam;
1247 sfx_t *sfx_knighthit;
1253 // indicates that the file "sound/misc/talk2.wav" was found (for use by team chat messages)
1254 qboolean foundtalk2wav;
1256 // refresh related state
1258 // cl_entitites[0].model
1259 struct model_s *worldmodel;
1265 int cdtrack, looptrack;
1270 scoreboard_t *scores;
1272 // keep track of svc_print parsing state (analyzes ping reports and status reports)
1273 cl_parsingtextmode_t parsingtextmode;
1274 int parsingtextplayerindex;
1275 // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
1276 // (which could eat the wrong ping report if the player issues one
1277 // manually, but they would still see a ping report, just a later one
1278 // caused by the scoreboard code rather than the one they intentionally
1280 int parsingtextexpectingpingforscores;
1282 // entity database stuff
1283 // latest received entity frame numbers
1284 #define LATESTFRAMENUMS 32
1285 int latestframenumsposition;
1286 int latestframenums[LATESTFRAMENUMS];
1287 unsigned int latestsendnums[LATESTFRAMENUMS];
1288 entityframe_database_t *entitydatabase;
1289 entityframe4_database_t *entitydatabase4;
1290 entityframeqw_database_t *entitydatabaseqw;
1292 // keep track of quake entities because they need to be killed if they get stale
1293 int lastquakeentity;
1294 unsigned char isquakeentity[MAX_EDICTS];
1296 // bounding boxes for clientside movement
1297 vec3_t playerstandmins;
1298 vec3_t playerstandmaxs;
1299 vec3_t playercrouchmins;
1300 vec3_t playercrouchmaxs;
1302 // old decals are killed based on this
1303 unsigned int decalsequence;
1306 int max_csqcrenderentities;
1307 int max_static_entities;
1312 int max_brushmodel_entities;
1318 entity_render_t *csqcrenderentities;
1319 unsigned char *entities_active;
1320 entity_t *static_entities;
1321 cl_effect_t *effects;
1324 lightstyle_t *lightstyle;
1325 int *brushmodel_entities;
1326 particle_t *particles;
1328 showlmp_t *showlmps;
1331 int num_static_entities;
1332 int num_brushmodel_entities;
1340 double particles_updatetime;
1341 double decals_updatetime;
1345 // cl_serverextension_download feature
1346 int loadmodel_current;
1347 int downloadmodel_current;
1348 int loadmodel_total;
1349 int loadsound_current;
1350 int downloadsound_current;
1351 int loadsound_total;
1352 qboolean downloadcsqc;
1355 qboolean loadfinished;
1359 // local copy of the server infostring
1360 char qw_serverinfo[MAX_SERVERINFO_STRING];
1362 // time of last qw "pings" command sent to server while showing scores
1363 double last_ping_request;
1365 // used during connect
1368 // updated from serverinfo
1371 // unused: indicates whether the player is spectating
1372 // use cl.scores[cl.playerentity-1].qw_spectator instead
1373 //qboolean qw_spectator;
1375 // last time an input packet was sent
1376 double lastpackettime;
1378 // movement parameters for client prediction
1379 unsigned int moveflags;
1380 float movevars_wallfriction;
1381 float movevars_waterfriction;
1382 float movevars_friction;
1383 float movevars_timescale;
1384 float movevars_gravity;
1385 float movevars_stopspeed;
1386 float movevars_maxspeed;
1387 float movevars_spectatormaxspeed;
1388 float movevars_accelerate;
1389 float movevars_airaccelerate;
1390 float movevars_wateraccelerate;
1391 float movevars_entgravity;
1392 float movevars_jumpvelocity;
1393 float movevars_edgefriction;
1394 float movevars_maxairspeed;
1395 float movevars_stepheight;
1396 float movevars_airaccel_qw;
1397 float movevars_airaccel_qw_stretchfactor;
1398 float movevars_airaccel_sideways_friction;
1399 float movevars_airstopaccelerate;
1400 float movevars_airstrafeaccelerate;
1401 float movevars_maxairstrafespeed;
1402 float movevars_airstrafeaccel_qw;
1403 float movevars_aircontrol;
1404 float movevars_aircontrol_power;
1405 float movevars_aircontrol_penalty;
1406 float movevars_warsowbunny_airforwardaccel;
1407 float movevars_warsowbunny_accel;
1408 float movevars_warsowbunny_topspeed;
1409 float movevars_warsowbunny_turnaccel;
1410 float movevars_warsowbunny_backtosideratio;
1411 float movevars_ticrate;
1412 float movevars_airspeedlimit_nonqw;
1414 // models used by qw protocol
1415 int qw_modelindex_spike;
1416 int qw_modelindex_player;
1417 int qw_modelindex_flag;
1418 int qw_modelindex_s_explod;
1420 vec3_t qw_intermission_origin;
1421 vec3_t qw_intermission_angles;
1423 // 255 is the most nails the QW protocol could send
1425 vec_t qw_nails[255][6];
1427 float qw_weaponkick;
1429 unsigned int qw_validsequence;
1431 unsigned int qw_deltasequence[QW_UPDATE_BACKUP];
1434 // server entity number corresponding to a clientside entity
1435 unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
1436 qboolean csqc_loaded;
1437 vec3_t csqc_vieworigin;
1438 vec3_t csqc_viewangles;
1439 vec3_t csqc_vieworiginfromengine;
1440 vec3_t csqc_viewanglesfromengine;
1441 matrix4x4_t csqc_viewmodelmatrixfromengine;
1442 qboolean csqc_usecsqclistener;
1443 matrix4x4_t csqc_listenermatrix;
1444 char csqc_printtextbuf[MAX_INPUTLINE];
1446 // collision culling data
1449 // loc file stuff (points and boxes describing locations in the level)
1450 cl_locnode_t *locnodes;
1451 // this is updated to cl.movement_origin whenever health is < 1
1452 // used by %d print in say/say_team messages if cl_locs_enable is on
1453 vec3_t lastdeathorigin;
1455 // processing buffer used by R_BuildLightMap, reallocated as needed,
1456 // freed on each level change
1457 size_t buildlightmapmemorysize;
1458 unsigned char *buildlightmapmemory;
1460 // used by EntityState5_ReadUpdate
1461 skeleton_t *engineskeletonobjects;
1468 extern cvar_t cl_name;
1469 extern cvar_t cl_color;
1470 extern cvar_t cl_rate;
1471 extern cvar_t cl_rate_burstsize;
1472 extern cvar_t cl_pmodel;
1473 extern cvar_t cl_playermodel;
1474 extern cvar_t cl_playerskin;
1476 extern cvar_t rcon_password;
1477 extern cvar_t rcon_address;
1479 extern cvar_t cl_upspeed;
1480 extern cvar_t cl_forwardspeed;
1481 extern cvar_t cl_backspeed;
1482 extern cvar_t cl_sidespeed;
1484 extern cvar_t cl_movespeedkey;
1486 extern cvar_t cl_yawspeed;
1487 extern cvar_t cl_pitchspeed;
1489 extern cvar_t cl_anglespeedkey;
1491 extern cvar_t cl_autofire;
1493 extern cvar_t cl_shownet;
1494 extern cvar_t cl_nolerp;
1495 extern cvar_t cl_nettimesyncfactor;
1496 extern cvar_t cl_nettimesyncboundmode;
1497 extern cvar_t cl_nettimesyncboundtolerance;
1499 extern cvar_t cl_pitchdriftspeed;
1500 extern cvar_t lookspring;
1501 extern cvar_t lookstrafe;
1502 extern cvar_t sensitivity;
1504 extern cvar_t freelook;
1506 extern cvar_t m_pitch;
1507 extern cvar_t m_yaw;
1508 extern cvar_t m_forward;
1509 extern cvar_t m_side;
1511 extern cvar_t cl_autodemo;
1512 extern cvar_t cl_autodemo_nameformat;
1513 extern cvar_t cl_autodemo_delete;
1515 extern cvar_t r_draweffects;
1517 extern cvar_t cl_explosions_alpha_start;
1518 extern cvar_t cl_explosions_alpha_end;
1519 extern cvar_t cl_explosions_size_start;
1520 extern cvar_t cl_explosions_size_end;
1521 extern cvar_t cl_explosions_lifetime;
1522 extern cvar_t cl_stainmaps;
1523 extern cvar_t cl_stainmaps_clearonload;
1525 extern cvar_t cl_prydoncursor;
1526 extern cvar_t cl_prydoncursor_notrace;
1528 extern cvar_t cl_locs_enable;
1530 extern client_state_t cl;
1532 extern void CL_AllocLightFlash (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, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
1534 cl_locnode_t *CL_Locs_FindNearest(const vec3_t point);
1535 void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point);
1537 //=============================================================================
1543 void CL_Shutdown (void);
1544 void CL_Init (void);
1546 void CL_EstablishConnection(const char *host, int firstarg);
1548 void CL_Disconnect (void);
1549 void CL_Disconnect_f (void);
1551 void CL_UpdateRenderEntity(entity_render_t *ent);
1552 void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
1553 void CL_UpdateViewEntities(void);
1558 typedef struct kbutton_s
1560 int down[2]; // key nums holding it down
1561 int state; // low bit is down state
1565 extern kbutton_t in_mlook, in_klook;
1566 extern kbutton_t in_strafe;
1567 extern kbutton_t in_speed;
1569 void CL_InitInput (void);
1570 void CL_SendMove (void);
1572 void CL_ValidateState(entity_state_t *s);
1573 void CL_MoveLerpEntityStates(entity_t *ent);
1574 void CL_LerpUpdate(entity_t *e);
1575 void CL_ParseTEnt (void);
1576 void CL_NewBeam (int ent, vec3_t start, vec3_t end, dp_model_t *m, int lightning);
1577 void CL_RelinkBeams (void);
1578 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1579 void CL_ClientMovement_Replay(void);
1581 void CL_ClearTempEntities (void);
1582 entity_render_t *CL_NewTempEntity (double shadertime);
1584 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
1586 void CL_ClearState (void);
1587 void CL_ExpandEntities(int num);
1588 void CL_ExpandCSQCRenderEntities(int num);
1589 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet);
1592 void CL_UpdateWorld (void);
1593 void CL_WriteToServer (void);
1594 void CL_Input (void);
1595 extern int cl_ignoremousemoves;
1598 float CL_KeyState (kbutton_t *key);
1599 const char *Key_KeynumToString (int keynum, char *buf, size_t buflength);
1600 int Key_StringToKeynum (const char *str);
1605 void CL_StopPlayback(void);
1606 void CL_ReadDemoMessage(void);
1607 void CL_WriteDemoMessage(sizebuf_t *mesage);
1609 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
1610 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
1612 void CL_NextDemo(void);
1613 void CL_Stop_f(void);
1614 void CL_Record_f(void);
1615 void CL_PlayDemo_f(void);
1616 void CL_TimeDemo_f(void);
1621 void CL_Parse_Init(void);
1622 void CL_Parse_Shutdown(void);
1623 void CL_ParseServerMessage(void);
1624 void CL_Parse_DumpPacket(void);
1625 void CL_Parse_ErrorCleanUp(void);
1626 void QW_CL_StartUpload(unsigned char *data, int size);
1627 extern cvar_t qport;
1628 void CL_KeepaliveMessage(qboolean readmessages); // call this during loading of large content
1633 void V_StartPitchDrift (void);
1634 void V_StopPitchDrift (void);
1637 float V_CalcRoll (const vec3_t angles, const vec3_t velocity);
1638 void V_UpdateBlends (void);
1639 void V_ParseDamage (void);
1645 extern cvar_t cl_particles;
1646 extern cvar_t cl_particles_quality;
1647 extern cvar_t cl_particles_size;
1648 extern cvar_t cl_particles_quake;
1649 extern cvar_t cl_particles_blood;
1650 extern cvar_t cl_particles_blood_alpha;
1651 extern cvar_t cl_particles_blood_decal_alpha;
1652 extern cvar_t cl_particles_blood_decal_scalemin;
1653 extern cvar_t cl_particles_blood_decal_scalemax;
1654 extern cvar_t cl_particles_blood_bloodhack;
1655 extern cvar_t cl_particles_bulletimpacts;
1656 extern cvar_t cl_particles_explosions_sparks;
1657 extern cvar_t cl_particles_explosions_shell;
1658 extern cvar_t cl_particles_rain;
1659 extern cvar_t cl_particles_snow;
1660 extern cvar_t cl_particles_smoke;
1661 extern cvar_t cl_particles_smoke_alpha;
1662 extern cvar_t cl_particles_smoke_alphafade;
1663 extern cvar_t cl_particles_sparks;
1664 extern cvar_t cl_particles_bubbles;
1665 extern cvar_t cl_decals;
1666 extern cvar_t cl_decals_time;
1667 extern cvar_t cl_decals_fadetime;
1669 void CL_Particles_Clear(void);
1670 void CL_Particles_Init(void);
1671 void CL_Particles_Shutdown(void);
1672 particle_t *CL_NewParticle(const vec3_t sortorigin, unsigned short ptypeindex, int pcolor1, int pcolor2, int ptex, float psize, float psizeincrease, float palpha, float palphafade, float pgravity, float pbounce, float px, float py, float pz, float pvx, float pvy, float pvz, float pairfriction, float pliquidfriction, float originjitter, float velocityjitter, qboolean pqualityreduction, float lifetime, float stretch, pblend_t blendmode, porientation_t orientation, int staincolor1, int staincolor2, int staintex, float stainalpha, float stainsize, float angle, float spin, float tint[4]);
1674 typedef enum effectnameindex_s
1678 EFFECT_TE_GUNSHOTQUAD,
1680 EFFECT_TE_SPIKEQUAD,
1681 EFFECT_TE_SUPERSPIKE,
1682 EFFECT_TE_SUPERSPIKEQUAD,
1684 EFFECT_TE_KNIGHTSPIKE,
1685 EFFECT_TE_EXPLOSION,
1686 EFFECT_TE_EXPLOSIONQUAD,
1687 EFFECT_TE_TAREXPLOSION,
1689 EFFECT_TE_LAVASPLASH,
1690 EFFECT_TE_SMALLFLASH,
1695 EFFECT_TE_PLASMABURN,
1697 EFFECT_TE_TEI_SMOKE,
1698 EFFECT_TE_TEI_BIGEXPLOSION,
1699 EFFECT_TE_TEI_PLASMAHIT,
1705 EFFECT_TR_SLIGHTBLOOD,
1706 EFFECT_TR_KNIGHTSPIKE,
1707 EFFECT_TR_VORESPIKE,
1708 EFFECT_TR_NEHAHRASMOKE,
1709 EFFECT_TR_NEXUIZPLASMA,
1710 EFFECT_TR_GLOWTRAIL,
1711 EFFECT_SVC_PARTICLE,
1716 int CL_ParticleEffectIndexForName(const char *name);
1717 const char *CL_ParticleEffectNameForIndex(int i);
1718 void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor);
1719 void CL_ParticleTrail(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles, float tintmins[4], float tintmaxs[4], float fade);
1720 void CL_ParticleBox(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles, float tintmins[4], float tintmaxs[4], float fade);
1721 void CL_ParseParticleEffect (void);
1722 void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel);
1723 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
1724 void CL_EntityParticles (const entity_t *ent);
1725 void CL_ParticleExplosion (const vec3_t org);
1726 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
1727 void R_NewExplosion(const vec3_t org);
1729 #include "cl_screen.h"
1731 extern qboolean sb_showscores;
1733 float RSurf_FogVertex(const vec3_t p);
1734 float RSurf_FogPoint(const vec3_t p);
1736 typedef enum r_viewport_type_e
1738 R_VIEWPORTTYPE_ORTHO,
1739 R_VIEWPORTTYPE_PERSPECTIVE,
1740 R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP,
1741 R_VIEWPORTTYPE_PERSPECTIVECUBESIDE,
1742 R_VIEWPORTTYPE_TOTAL
1746 typedef struct r_viewport_s
1748 matrix4x4_t cameramatrix; // from entity (transforms from camera entity to world)
1749 matrix4x4_t viewmatrix; // actual matrix for rendering (transforms to viewspace)
1750 matrix4x4_t projectmatrix; // actual projection matrix (transforms from viewspace to screen)
1757 r_viewport_type_t type;
1758 float screentodepth[2]; // used by deferred renderer to calculate linear depth from device depth coordinates
1762 typedef struct r_refdef_view_s
1764 // view information (changes multiple times per frame)
1765 // if any of these variables change then r_refdef.viewcache must be regenerated
1766 // by calling R_View_Update
1767 // (which also updates viewport, scissor, colormask)
1769 // it is safe and expected to copy this into a structure on the stack and
1770 // call the renderer recursively, then restore from the stack afterward
1771 // (as long as R_View_Update is called)
1773 // eye position information
1774 matrix4x4_t matrix, inverse_matrix;
1780 int numfrustumplanes;
1781 mplane_t frustum[6];
1782 qboolean useclipplane;
1783 qboolean usecustompvs; // uses r_refdef.viewcache.pvsbits as-is rather than computing it
1785 float frustum_x, frustum_y;
1786 vec3_t frustumcorner[4];
1787 // if turned off it renders an ortho view
1789 float ortho_x, ortho_y;
1791 // screen area to render in
1798 r_viewport_t viewport; // note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and height
1800 // which color components to allow (for anaglyph glasses)
1803 // global RGB color multiplier for rendering
1806 // whether to call R_ClearScreen before rendering stuff
1808 // if true, don't clear or do any post process effects (bloom, etc)
1810 // if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor)
1813 // whether to draw r_showtris and such, this is only true for the main
1814 // view render, all secondary renders (mirrors, portals, cameras,
1815 // distortion effects, etc) omit such debugging information
1818 // these define which values to use in GL_CullFace calls to request frontface or backface culling
1822 // render quality (0 to 1) - affects r_drawparticles_drawdistance and others
1827 typedef struct r_refdef_viewcache_s
1829 // updated by gl_main_newmap()
1831 int world_numclusters;
1832 int world_numclusterbytes;
1834 int world_numsurfaces;
1836 // these properties are generated by R_View_Update()
1838 // which entities are currently visible for this viewpoint
1839 // (the used range is 0...r_refdef.scene.numentities)
1840 unsigned char *entityvisible;
1842 // flag arrays used for visibility checking on world model
1843 // (all other entities have no per-surface/per-leaf visibility checks)
1844 unsigned char *world_pvsbits;
1845 unsigned char *world_leafvisible;
1846 unsigned char *world_surfacevisible;
1847 // if true, the view is currently in a leaf without pvs data
1848 qboolean world_novis;
1850 r_refdef_viewcache_t;
1852 // TODO: really think about which fields should go into scene and which one should stay in refdef [1/7/2008 Black]
1853 // maybe also refactor some of the functions to support different setting sources (ie. fogenabled, etc.) for different scenes
1854 typedef struct r_refdef_scene_s {
1855 // whether to call S_ExtraUpdate during render to reduce sound chop
1856 qboolean extraupdate;
1858 // (client gameworld) time for rendering time based effects
1862 entity_render_t *worldentity;
1864 // same as worldentity->model
1865 dp_model_t *worldmodel;
1867 // renderable entities (excluding world)
1868 entity_render_t **entities;
1872 // field of temporary entities that is reset each (client) frame
1873 entity_render_t *tempentities;
1874 int numtempentities;
1875 int maxtempentities;
1876 qboolean expandtempentities;
1878 // renderable dynamic lights
1879 rtlight_t *lights[MAX_DLIGHTS];
1880 rtlight_t templights[MAX_DLIGHTS];
1883 // intensities for light styles right now, controls rtlights
1884 float rtlightstylevalue[MAX_LIGHTSTYLES]; // float fraction of base light value
1885 // 8.8bit fixed point intensities for light styles
1886 // controls intensity lightmap layers
1887 unsigned short lightstylevalue[MAX_LIGHTSTYLES]; // 8.8 fraction of base light value
1892 qboolean rtworldshadows;
1894 qboolean rtdlightshadows;
1897 typedef struct r_refdef_s
1899 // these fields define the basic rendering information for the world
1900 // but not the view, which could change multiple times in one rendered
1901 // frame (for example when rendering textures for certain effects)
1903 // these are set for water warping before
1904 // frustum_x/frustum_y are calculated
1905 float frustumscale_x, frustumscale_y;
1907 // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
1908 r_refdef_view_t view;
1909 r_refdef_viewcache_t viewcache;
1911 // minimum visible distance (pixels closer than this disappear)
1913 // maximum visible distance (pixels further than this disappear in 16bpp modes,
1914 // in 32bpp an infinite-farclip matrix is used instead)
1917 // fullscreen color blend
1920 r_refdef_scene_t scene;
1923 float fogplaneviewdist;
1924 qboolean fogplaneviewabove;
1925 float fogheightfade;
1928 float fograngerecip;
1929 float fogmasktabledistmultiplier;
1930 #define FOGMASKTABLEWIDTH 1024
1931 float fogmasktable[FOGMASKTABLEWIDTH];
1932 float fogmasktable_start, fogmasktable_alpha, fogmasktable_range, fogmasktable_density;
1941 float fog_fadedepth;
1942 qboolean fogenabled;
1943 qboolean oldgl_fogenable;
1945 // new flexible texture height fog (overrides normal fog)
1946 char fog_height_texturename[64]; // note: must be 64 for the sscanf code
1947 unsigned char *fog_height_table1d;
1948 unsigned char *fog_height_table2d;
1949 int fog_height_tablesize; // enable
1950 float fog_height_tablescale;
1951 float fog_height_texcoordscale;
1952 char fogheighttexturename[64]; // detects changes to active fog height texture
1954 int draw2dstage; // 0 = no, 1 = yes, other value = needs setting up again
1956 // true during envmap command capture
1959 // brightness of world lightmaps and related lighting
1960 // (often reduced when world rtlights are enabled)
1961 float lightmapintensity;
1962 // whether to draw world lights realtime, dlights realtime, and their shadows
1963 float polygonfactor;
1964 float polygonoffset;
1965 float shadowpolygonfactor;
1966 float shadowpolygonoffset;
1968 // how long R_RenderView took on the previous frame
1969 double lastdrawscreentime;
1971 // rendering stats for r_speeds display
1972 // (these are incremented in many places)
1973 int stats[r_stat_count];
1977 extern r_refdef_t r_refdef;
1979 typedef enum waterlevel_e
1983 WATERLEVEL_SWIMMING,
1984 WATERLEVEL_SUBMERGED
1988 typedef struct cl_clientmovement_state_s
1990 // entity to be ignored for movement
1991 struct prvm_edict_s *self;
1995 // current bounding box (different if crouched vs standing)
1998 // currently on the ground
2000 // currently crouching
2002 // what kind of water (SUPERCONTENTS_LAVA for instance)
2005 waterlevel_t waterlevel;
2006 // weird hacks when jumping out of water
2007 // (this is in seconds and counts down to 0)
2008 float waterjumptime;
2013 cl_clientmovement_state_t;
2014 void CL_ClientMovement_PlayerMove_Frame(cl_clientmovement_state_t *s);
2016 // warpzone prediction hack (CSQC builtin)
2017 void CL_RotateMoves(const matrix4x4_t *m);
2019 typedef enum meshname_e {
2026 extern entity_t cl_meshentities[NUM_MESHENTITIES];
2027 extern dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
2028 extern const char *cl_meshentitynames[NUM_MESHENTITIES];
2029 #define CL_Mesh_Debug() (&cl_meshentitymodels[MESH_DEBUG])
2030 #define CL_Mesh_CSQC() (&cl_meshentitymodels[MESH_CSQCPOLYGONS])
2031 #define CL_Mesh_Particles() (&cl_meshentitymodels[MESH_PARTICLES])
2032 #define CL_Mesh_UI() (&cl_meshentitymodels[MESH_UI])
2033 void CL_MeshEntities_AddToScene(void);
2034 void CL_MeshEntities_Reset(void);
2036 void CL_NewFrameReceived(int num);
2037 void CL_ParseEntityLump(char *entitystring);
2038 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
2039 void CL_RelinkLightFlashes(void);
2040 void CL_Beam_AddPolygons(const beam_t *b);
2041 void Sbar_ShowFPS(void);
2042 void Sbar_ShowFPS_Update(void);
2043 void Host_SaveConfig(void);
2044 void Host_LoadConfig_f(void);
2045 void CL_UpdateMoveVars(void);
2046 void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length);
2047 void V_DriftPitch(void);
2048 void V_FadeViewFlashs(void);
2049 void V_CalcViewBlend(void);
2050 void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight, qboolean cldead, qboolean clintermission, const vec3_t clvelocity);
2051 void V_CalcRefdef(void);
2052 void CL_Locs_Reload_f(void);