]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - client.h
CSQC polygonbegin functionality now uses the CL_MeshEntities system, this finally...
[xonotic/darkplaces.git] / client.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20 // client.h
21
22 #ifndef CLIENT_H
23 #define CLIENT_H
24
25 #include "matrixlib.h"
26 #include "snd_main.h"
27
28 // NOTE: r_stat_name[] must match this indexing
29 typedef enum r_stat_e
30 {
31         r_stat_timedelta,
32         r_stat_quality,
33         r_stat_renders,
34         r_stat_entities,
35         r_stat_entities_surfaces,
36         r_stat_entities_triangles,
37         r_stat_world_leafs,
38         r_stat_world_portals,
39         r_stat_world_surfaces,
40         r_stat_world_triangles,
41         r_stat_lightmapupdates,
42         r_stat_lightmapupdatepixels,
43         r_stat_particles,
44         r_stat_drawndecals,
45         r_stat_totaldecals,
46         r_stat_draws,
47         r_stat_draws_vertices,
48         r_stat_draws_elements,
49         r_stat_lights,
50         r_stat_lights_clears,
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,
64         r_stat_bloom,
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,
72         r_stat_framedatasize,
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,
93         r_stat_batch_batches,
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
195 }
196 r_stat_t;
197
198 // flags for rtlight rendering
199 #define LIGHTFLAG_NORMALMODE 1
200 #define LIGHTFLAG_REALTIMEMODE 2
201
202 typedef struct tridecal_s
203 {
204         // color and initial alpha value
205         float                   texcoord2f[3][2];
206         float                   vertex3f[3][3];
207         float                   color4f[3][4];
208         float                   plane[4]; // backface culling
209         // how long this decal has lived so far (the actual fade begins at cl_decals_time)
210         float                   lived;
211         // if >= 0 this indicates the decal should follow an animated triangle
212         int                             triangleindex;
213         // for visibility culling
214         int                             surfaceindex;
215         // old decals are killed to obey cl_decals_max
216         unsigned int    decalsequence;
217 }
218 tridecal_t;
219
220 typedef struct decalsystem_s
221 {
222         dp_model_t *model;
223         double lastupdatetime;
224         int maxdecals;
225         int freedecal;
226         int numdecals;
227         tridecal_t *decals;
228         float *vertex3f;
229         float *texcoord2f;
230         float *color4f;
231         int *element3i;
232         unsigned short *element3s;
233 }
234 decalsystem_t;
235
236 typedef struct effect_s
237 {
238         int active;
239         vec3_t origin;
240         double starttime;
241         float framerate;
242         int modelindex;
243         int startframe;
244         int endframe;
245         // these are for interpolation
246         int frame;
247         double frame1time;
248         double frame2time;
249 }
250 cl_effect_t;
251
252 typedef struct beam_s
253 {
254         int             entity;
255         // draw this as lightning polygons, or a model?
256         int             lightning;
257         struct model_s  *model;
258         float   endtime;
259         vec3_t  start, end;
260 }
261 beam_t;
262
263 typedef struct rtlight_particle_s
264 {
265         float origin[3];
266         float color[3];
267 }
268 rtlight_particle_t;
269
270 typedef struct rtlight_s
271 {
272         // shadow volumes are done entirely in model space, so there are no matrices for dealing with them...  they just use the origin
273
274         // note that the world to light matrices are inversely scaled (divided) by lightradius
275
276         // core properties
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)
282         vec3_t color;
283         /// size of the light (remove?)
284         vec_t radius;
285         /// light filter
286         char cubemapname[64];
287         /// light style to monitor for brightness
288         int style;
289         /// whether light should render shadows (see castshadows for whether it actually does this frame)
290         int shadow;
291         /// intensity of corona to render
292         vec_t corona;
293         /// radius scale of corona to render (1.0 means same as light radius)
294         vec_t coronasizescale;
295         /// ambient intensity to render
296         vec_t ambientscale;
297         /// diffuse intensity to render
298         vec_t diffusescale;
299         /// specular intensity to render
300         vec_t specularscale;
301         /// LIGHTFLAG_* flags
302         int flags;
303
304         // generated properties
305         /// used only for shadow volumes
306         vec3_t shadoworigin;
307         /// culling
308         vec3_t cullmins;
309         vec3_t cullmaxs;
310         /// when r_shadow_culllights_trace is set, this is refreshed by each successful trace.
311         double trace_timer;
312
313         // rendering properties, updated each time a light is rendered
314         // this is rtlight->color * d_lightstylevalue
315         vec3_t currentcolor;
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
323         qboolean draw;
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
347
348         /// static light info
349         /// true if this light should be compiled as a static light
350         int isstatic;
351         /// true if this is a compiled world light, cleared if the light changes
352         int compiled;
353         /// the shadowing mode used to compile this light
354         int shadowmode;
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)
366         int static_numleafs;
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
375         ///
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;
394
395         /// bouncegrid light info
396         float bouncegrid_photoncolor[3];
397         float bouncegrid_photons;
398         int bouncegrid_hits;
399         int bouncegrid_traces;
400         float bouncegrid_effectiveradius;
401 }
402 rtlight_t;
403
404 typedef struct dlight_s
405 {
406         // destroy light after this time
407         // (dlight only)
408         vec_t die;
409         // the entity that owns this light (can be NULL)
410         // (dlight only)
411         struct entity_render_s *ent;
412         // location
413         // (worldlight: saved to .rtlights file)
414         vec3_t origin;
415         // worldlight orientation
416         // (worldlight only)
417         // (worldlight: saved to .rtlights file)
418         vec3_t angles;
419         // dlight orientation/scaling/location
420         // (dlight only)
421         matrix4x4_t matrix;
422         // color of light
423         // (worldlight: saved to .rtlights file)
424         vec3_t color;
425         // cubemap name to use on this light
426         // (worldlight: saved to .rtlights file)
427         char cubemapname[64];
428         // make light flash while selected
429         // (worldlight only)
430         int selected;
431         // brightness (not really radius anymore)
432         // (worldlight: saved to .rtlights file)
433         vec_t radius;
434         // drop intensity this much each second
435         // (dlight only)
436         vec_t decay;
437         // intensity value which is dropped over time
438         // (dlight only)
439         vec_t intensity;
440         // initial values for intensity to modify
441         // (dlight only)
442         vec_t initialradius;
443         vec3_t initialcolor;
444         // light style which controls intensity of this light
445         // (worldlight: saved to .rtlights file)
446         int style;
447         // cast shadows
448         // (worldlight: saved to .rtlights file)
449         int shadow;
450         // corona intensity
451         // (worldlight: saved to .rtlights file)
452         vec_t corona;
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)
458         vec_t ambientscale;
459         // diffuse intensity to render
460         // (worldlight: saved to .rtlights file)
461         vec_t diffusescale;
462         // specular intensity to render
463         // (worldlight: saved to .rtlights file)
464         vec_t specularscale;
465         // LIGHTFLAG_* flags
466         // (worldlight: saved to .rtlights file)
467         int flags;
468         // linked list of world lights
469         // (worldlight only)
470         struct dlight_s *next;
471         // embedded rtlight struct for renderer
472         // (worldlight only)
473         rtlight_t rtlight;
474 }
475 dlight_t;
476
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
483 {
484         int subframe;
485         float lerp;
486 }
487 frameblend_t;
488
489 // LordHavoc: this struct is intended for the renderer but some fields are
490 // used by the client.
491 //
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.
495 //
496 // For example the r_cullentities_trace code does such caching.
497 typedef struct entity_render_s
498 {
499         // location
500         //vec3_t origin;
501         // orientation
502         //vec3_t angles;
503         // transform matrix for model to world
504         matrix4x4_t matrix;
505         // transform matrix for world to model
506         matrix4x4_t inversematrix;
507         // opacity (alpha) of the model
508         float alpha;
509         // size the model is shown
510         float scale;
511         // transparent sorting offset
512         float transparent_offset;
513
514         // NULL = no model
515         dp_model_t *model;
516         // number of the entity represents, or 0 for non-network entities
517         int entitynumber;
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
522         int effects;
523         // qw CTF flags and other internal-use-only effect bits
524         int internaleffects;
525         // for Alias models
526         int skinnum;
527         // render flags
528         int flags;
529
530         // colormod tinting of models
531         float colormod[3];
532         float glowmod[3];
533
534         // interpolated animation - active framegroups and blend factors
535         framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
536
537         // time of last model change (for shader animations)
538         double shadertime;
539
540         // calculated by the renderer (but not persistent)
541
542         // calculated during R_AddModelEntities
543         vec3_t mins, maxs;
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;
548
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;
575
576         // CL_UpdateEntityShading reads these fields
577         // used only if RENDER_CUSTOMIZEDMODELLIGHT is set
578         vec3_t custommodellight_ambient;
579         vec3_t custommodellight_diffuse;
580         vec3_t custommodellight_lightdir;
581         // CSQC entities get their shading from the root of their attachment chain
582         float custommodellight_origin[3];
583
584         // derived lighting parameters (CL_UpdateEntityShading)
585
586         // used by MATERIALFLAG_FULLBRIGHT which is MATERIALFLAG_MODELLIGHT with
587         // this as ambient color, along with MATERIALFLAG_NORTLIGHT
588         float render_fullbright[3];
589         // color tint for the base pass glow textures if any
590         float render_glowmod[3];
591         // MATERIALFLAG_MODELLIGHT uses these parameters
592         float render_modellight_ambient[3];
593         float render_modellight_diffuse[3];
594         float render_modellight_lightdir[3];
595         float render_modellight_specular[3];
596         // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
597         float render_lightmap_ambient[3];
598         float render_lightmap_diffuse[3];
599         float render_lightmap_specular[3];
600         // rtlights use these colors for the materials on this entity
601         float render_rtlight_diffuse[3];
602         float render_rtlight_specular[3];
603         // ignore lightmap and use lightgrid on this entity (e.g. FULLBRIGHT)
604         qboolean render_modellight_forced;
605         // do not process per pixel lights on this entity at all (like MATERIALFLAG_NORTLIGHT)
606         qboolean render_rtlight_disabled;
607
608         // storage of decals on this entity
609         // (note: if allowdecals is set, be sure to call R_DecalSystem_Reset on removal!)
610         int allowdecals;
611         decalsystem_t decalsystem;
612
613         // FIELDS UPDATED BY RENDERER:
614         // last time visible during trace culling
615         double last_trace_visibility;
616
617         // user wavefunc parameters (from csqc)
618         vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
619 }
620 entity_render_t;
621
622 typedef struct entity_persistent_s
623 {
624         vec3_t trail_origin; // previous position for particle trail spawning
625         vec3_t oldorigin; // lerp
626         vec3_t oldangles; // lerp
627         vec3_t neworigin; // lerp
628         vec3_t newangles; // lerp
629         vec_t lerpstarttime; // lerp
630         vec_t lerpdeltatime; // lerp
631         float muzzleflash; // muzzleflash intensity, fades over time
632         float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
633         qboolean trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
634 }
635 entity_persistent_t;
636
637 typedef struct entity_s
638 {
639         // baseline state (default values)
640         entity_state_t state_baseline;
641         // previous state (interpolating from this)
642         entity_state_t state_previous;
643         // current state (interpolating to this)
644         entity_state_t state_current;
645
646         // used for regenerating parts of render
647         entity_persistent_t persistent;
648
649         // the only data the renderer should know about
650         entity_render_t render;
651 }
652 entity_t;
653
654 typedef struct usercmd_s
655 {
656         vec3_t  viewangles;
657
658 // intended velocities
659         float   forwardmove;
660         float   sidemove;
661         float   upmove;
662
663         vec3_t  cursor_screen;
664         vec3_t  cursor_start;
665         vec3_t  cursor_end;
666         vec3_t  cursor_impact;
667         vec3_t  cursor_normal;
668         vec_t   cursor_fraction;
669         int             cursor_entitynumber;
670
671         double time; // time the move is executed for (cl_movement: clienttime, non-cl_movement: receivetime)
672         double receivetime; // time the move was received at
673         double clienttime; // time to which server state the move corresponds to
674         int msec; // for predicted moves
675         int buttons;
676         int impulse;
677         unsigned int sequence;
678         qboolean applied; // if false we're still accumulating a move
679         qboolean predicted; // if true the sequence should be sent as 0
680
681         // derived properties
682         double frametime;
683         qboolean canjump;
684         qboolean jump;
685         qboolean crouch;
686 } usercmd_t;
687
688 typedef struct lightstyle_s
689 {
690         int             length;
691         char    map[MAX_STYLESTRING];
692 } lightstyle_t;
693
694 typedef struct scoreboard_s
695 {
696         char    name[MAX_SCOREBOARDNAME];
697         int             frags;
698         int             colors; // two 4 bit fields
699         // QW fields:
700         int             qw_userid;
701         char    qw_userinfo[MAX_USERINFO_STRING];
702         float   qw_entertime;
703         int             qw_ping;
704         int             qw_packetloss;
705         int             qw_movementloss;
706         int             qw_spectator;
707         char    qw_team[8];
708         char    qw_skin[MAX_QPATH];
709 } scoreboard_t;
710
711 typedef struct cshift_s
712 {
713         float   destcolor[3];
714         float   percent;                // 0-255
715         float   alphafade;      // (any speed)
716 } cshift_t;
717
718 #define CSHIFT_CONTENTS 0
719 #define CSHIFT_DAMAGE   1
720 #define CSHIFT_BONUS    2
721 #define CSHIFT_POWERUP  3
722 #define CSHIFT_VCSHIFT  4
723 #define NUM_CSHIFTS             5
724
725 #define NAME_LENGTH     64
726
727
728 //
729 // client_state_t should hold all pieces of the client state
730 //
731
732 #define SIGNONS         4                       // signon messages to receive before connected
733
734 typedef enum cactive_e
735 {
736         ca_uninitialized,       // during early startup
737         ca_dedicated,           // a dedicated server with no ability to start a client
738         ca_disconnected,        // full screen console with no connection
739         ca_connected            // valid netcon, talking to a server
740 }
741 cactive_t;
742
743 typedef enum qw_downloadtype_e
744 {
745         dl_none,
746         dl_single,
747         dl_skin,
748         dl_model,
749         dl_sound
750 }
751 qw_downloadtype_t;
752
753 typedef enum capturevideoformat_e
754 {
755         CAPTUREVIDEOFORMAT_AVI_I420,
756         CAPTUREVIDEOFORMAT_OGG_VORBIS_THEORA
757 }
758 capturevideoformat_t;
759
760 typedef struct capturevideostate_s
761 {
762         double startrealtime;
763         double framerate;
764         int framestep;
765         int framestepframe;
766         qboolean active;
767         qboolean realtime;
768         qboolean error;
769         int soundrate;
770         int soundchannels;
771         int frame;
772         double starttime;
773         double lastfpstime;
774         int lastfpsframe;
775         int soundsampleframe;
776         unsigned char *screenbuffer;
777         unsigned char *outbuffer;
778         char basename[MAX_QPATH];
779         int width, height;
780
781         // precomputed RGB to YUV tables
782         // converts the RGB values to YUV (see cap_avi.c for how to use them)
783         short rgbtoyuvscaletable[3][3][256];
784         unsigned char yuvnormalizetable[3][256];
785
786         // precomputed gamma ramp (only needed if the capturevideo module uses RGB output)
787         // 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
788         unsigned short vidramp[256 * 3];
789
790         // stuff to be filled in by the video format module
791         capturevideoformat_t format;
792         const char *formatextension;
793         qfile_t *videofile;
794                 // always use this:
795                 //   cls.capturevideo.videofile = FS_OpenRealFile(va(vabuf, sizeof(vabuf), "%s.%s", cls.capturevideo.basename, cls.capturevideo.formatextension), "wb", false);
796         void (*endvideo) (void);
797         void (*videoframes) (int num);
798         void (*soundframe) (const portable_sampleframe_t *paintbuffer, size_t length);
799
800         // format specific data
801         void *formatspecific;
802 }
803 capturevideostate_t;
804
805 #define CL_MAX_DOWNLOADACKS 4
806
807 typedef struct cl_downloadack_s
808 {
809         int start, size;
810 }
811 cl_downloadack_t;
812
813 typedef struct cl_soundstats_s
814 {
815         int mixedsounds;
816         int totalsounds;
817         int latency_milliseconds;
818 }
819 cl_soundstats_t;
820
821 //
822 // the client_static_t structure is persistent through an arbitrary number
823 // of server connections
824 //
825 typedef struct client_static_s
826 {
827         cactive_t state;
828
829         // all client memory allocations go in these pools
830         mempool_t *levelmempool;
831         mempool_t *permanentmempool;
832
833 // demo loop control
834         // -1 = don't play demos
835         int demonum;
836         // list of demos in loop
837         char demos[MAX_DEMOS][MAX_DEMONAME];
838         // the actively playing demo (set by CL_PlayDemo_f)
839         char demoname[MAX_QPATH];
840
841 // demo recording info must be here, because record is started before
842 // entering a map (and clearing client_state_t)
843         qboolean demorecording;
844         fs_offset_t demo_lastcsprogssize;
845         int demo_lastcsprogscrc;
846         qboolean demoplayback;
847         qboolean demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo
848         qboolean timedemo;
849         // -1 = use normal cd track
850         int forcetrack;
851         qfile_t *demofile;
852         // realtime at second frame of timedemo (LordHavoc: changed to double)
853         double td_starttime;
854         int td_frames; // total frames parsed
855         double td_onesecondnexttime;
856         double td_onesecondframes;
857         double td_onesecondrealtime;
858         double td_onesecondminfps;
859         double td_onesecondmaxfps;
860         double td_onesecondavgfps;
861         int td_onesecondavgcount;
862         // LordHavoc: pausedemo
863         qboolean demopaused;
864
865         // sound mixer statistics for showsound display
866         cl_soundstats_t soundstats;
867
868         qboolean connect_trying;
869         int connect_remainingtries;
870         double connect_nextsendtime;
871         lhnetsocket_t *connect_mysocket;
872         lhnetaddress_t connect_address;
873         lhnetaddress_t rcon_address;
874         // protocol version of the server we're connected to
875         // (kept outside client_state_t because it's used between levels)
876         protocolversion_t protocol;
877
878 #define MAX_RCONS 16
879         int rcon_trying;
880         lhnetaddress_t rcon_addresses[MAX_RCONS];
881         char rcon_commands[MAX_RCONS][MAX_INPUTLINE];
882         double rcon_timeout[MAX_RCONS];
883         int rcon_ringpos;
884
885 // connection information
886         // 0 to SIGNONS
887         int signon;
888         // network connection
889         netconn_t *netcon;
890
891         // download information
892         // (note: qw_download variables are also used)
893         cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
894
895         // input sequence numbers are not reset on level change, only connect
896         unsigned int servermovesequence;
897
898         // quakeworld stuff below
899
900         // value of "qport" cvar at time of connection
901         int qw_qport;
902         // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
903         unsigned int qw_incoming_sequence;
904         unsigned int qw_outgoing_sequence;
905
906         // current file download buffer (only saved when file is completed)
907         char qw_downloadname[MAX_QPATH];
908         unsigned char *qw_downloadmemory;
909         int qw_downloadmemorycursize;
910         int qw_downloadmemorymaxsize;
911         int qw_downloadnumber;
912         int qw_downloadpercent;
913         qw_downloadtype_t qw_downloadtype;
914         // transfer rate display
915         double qw_downloadspeedtime;
916         int qw_downloadspeedcount;
917         int qw_downloadspeedrate;
918         qboolean qw_download_deflate;
919
920         // current file upload buffer (for uploading screenshots to server)
921         unsigned char *qw_uploaddata;
922         int qw_uploadsize;
923         int qw_uploadpos;
924
925         // user infostring
926         // this normally contains the following keys in quakeworld:
927         // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
928         char userinfo[MAX_USERINFO_STRING];
929
930         // extra user info for the "connect" command
931         char connect_userinfo[MAX_USERINFO_STRING];
932
933         // video capture stuff
934         capturevideostate_t capturevideo;
935
936         // crypto channel
937         crypto_t crypto;
938
939         // ProQuake compatibility stuff
940         int proquake_servermod; // 0 = not proquake, 1 = proquake
941         int proquake_serverversion; // actual proquake server version * 10 (3.40 = 34, etc)
942         int proquake_serverflags; // 0 (PQF_CHEATFREE not supported)
943
944         // don't write-then-read csprogs.dat (useful for demo playback)
945         unsigned char *caughtcsprogsdata;
946         fs_offset_t caughtcsprogsdatasize;
947
948         int r_speeds_graph_length;
949         int r_speeds_graph_current;
950         int *r_speeds_graph_data;
951
952         // graph scales
953         int r_speeds_graph_datamin[r_stat_count];
954         int r_speeds_graph_datamax[r_stat_count];
955 }
956 client_static_t;
957
958 extern client_static_t  cls;
959
960 //[515]: csqc
961 typedef struct
962 {
963         qboolean drawworld;
964         qboolean drawenginesbar;
965         qboolean drawcrosshair;
966 }csqc_vidvars_t;
967
968 typedef enum
969 {
970         PARTICLE_BILLBOARD = 0,
971         PARTICLE_SPARK = 1,
972         PARTICLE_ORIENTED_DOUBLESIDED = 2,
973         PARTICLE_VBEAM = 3,
974         PARTICLE_HBEAM = 4,
975         PARTICLE_INVALID = -1
976 }
977 porientation_t;
978
979 typedef enum
980 {
981         PBLEND_ALPHA = 0,
982         PBLEND_ADD = 1,
983         PBLEND_INVMOD = 2,
984         PBLEND_INVALID = -1
985 }
986 pblend_t;
987
988 typedef struct particletype_s
989 {
990         pblend_t blendmode;
991         porientation_t orientation;
992         qboolean lighting;
993 }
994 particletype_t;
995
996 typedef enum ptype_e
997 {
998         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
999 }
1000 ptype_t;
1001
1002 typedef struct decal_s
1003 {
1004         // fields used by rendering:  (44 bytes)
1005         unsigned short  typeindex;
1006         unsigned short  texnum;
1007         unsigned int    decalsequence;
1008         vec3_t                  org;
1009         vec3_t                  normal;
1010         float                   size;
1011         float                   alpha; // 0-255
1012         unsigned char   color[3];
1013         unsigned char   unused1;
1014         int                             clusterindex; // cheap culling by pvs
1015
1016         // fields not used by rendering: (36 bytes in 32bit, 40 bytes in 64bit)
1017         float                   time2; // used for decal fade
1018         unsigned int    owner; // decal stuck to this entity
1019         dp_model_t                      *ownermodel; // model the decal is stuck to (used to make sure the entity is still alive)
1020         vec3_t                  relativeorigin; // decal at this location in entity's coordinate space
1021         vec3_t                  relativenormal; // decal oriented this way relative to entity's coordinate space
1022 }
1023 decal_t;
1024
1025 typedef struct particle_s
1026 {
1027         // for faster batch rendering, particles are rendered in groups by effect (resulting in less perfect sorting but far less state changes)
1028
1029         // fields used by rendering: (48 bytes)
1030         vec3_t          sortorigin; // sort by this group origin, not particle org
1031         vec3_t          org;
1032         vec3_t          vel; // velocity of particle, or orientation of decal, or end point of beam
1033         float           size;
1034         float           alpha; // 0-255
1035         float           stretch; // only for sparks
1036
1037         // fields not used by rendering:  (44 bytes)
1038         float           stainsize;
1039         float           stainalpha;
1040         float           sizeincrease; // rate of size change per second
1041         float           alphafade; // how much alpha reduces per second
1042         float           time2; // used for snow fluttering and decal fade
1043         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)
1044         float           gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
1045         float           airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
1046         float           liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
1047 //      float           delayedcollisions; // time that p->bounce becomes active
1048         float           delayedspawn; // time that particle appears and begins moving
1049         float           die; // time when this particle should be removed, regardless of alpha
1050
1051         // short variables grouped to save memory (4 bytes)
1052         short                   angle; // base rotation of particle
1053         short                   spin; // geometry rotation speed around the particle center normal
1054
1055         // byte variables grouped to save memory (12 bytes)
1056         unsigned char   color[3];
1057         unsigned char   qualityreduction; // enables skipping of this particle according to r_refdef.view.qualityreduction
1058         unsigned char   typeindex;
1059         unsigned char   blendmode;
1060         unsigned char   orientation;
1061         unsigned char   texnum;
1062         unsigned char   staincolor[3];
1063         signed char     staintexnum;
1064 }
1065 particle_t;
1066
1067 typedef enum cl_parsingtextmode_e
1068 {
1069         CL_PARSETEXTMODE_NONE,
1070         CL_PARSETEXTMODE_PING,
1071         CL_PARSETEXTMODE_STATUS,
1072         CL_PARSETEXTMODE_STATUS_PLAYERID,
1073         CL_PARSETEXTMODE_STATUS_PLAYERIP
1074 }
1075 cl_parsingtextmode_t;
1076
1077 typedef struct cl_locnode_s
1078 {
1079         struct cl_locnode_s *next;
1080         char *name;
1081         vec3_t mins, maxs;
1082 }
1083 cl_locnode_t;
1084
1085 typedef struct showlmp_s
1086 {
1087         qboolean        isactive;
1088         float           x;
1089         float           y;
1090         char            label[32];
1091         char            pic[128];
1092 }
1093 showlmp_t;
1094
1095 //
1096 // the client_state_t structure is wiped completely at every
1097 // server signon
1098 //
1099 typedef struct client_state_s
1100 {
1101         // true if playing in a local game and no one else is connected
1102         int islocalgame;
1103
1104         // send a clc_nop periodically until connected
1105         float sendnoptime;
1106
1107         // current input being accumulated by mouse/joystick/etc input
1108         usercmd_t cmd;
1109         // latest moves sent to the server that have not been confirmed yet
1110         usercmd_t movecmd[CL_MAX_USERCMDS];
1111
1112 // information for local display
1113         // health, etc
1114         int stats[MAX_CL_STATS];
1115         float *statsf; // points to stats[] array
1116         // last known inventory bit flags, for blinking
1117         int olditems;
1118         // cl.time of acquiring item, for blinking
1119         float item_gettime[32];
1120         // last known STAT_ACTIVEWEAPON
1121         int activeweapon;
1122         // cl.time of changing STAT_ACTIVEWEAPON
1123         float weapontime;
1124         // use pain anim frame if cl.time < this
1125         float faceanimtime;
1126         // for stair smoothing
1127         float stairsmoothz;
1128         double stairsmoothtime;
1129
1130         // color shifts for damage, powerups
1131         cshift_t cshifts[NUM_CSHIFTS];
1132         // and content types
1133         cshift_t prev_cshifts[NUM_CSHIFTS];
1134
1135 // the client maintains its own idea of view angles, which are
1136 // sent to the server each frame.  The server sets punchangle when
1137 // the view is temporarily offset, and an angle reset commands at the start
1138 // of each level and after teleporting.
1139
1140         // mviewangles is read from demo
1141         // viewangles is either client controlled or lerped from mviewangles
1142         vec3_t mviewangles[2], viewangles;
1143         // update by server, used by qc to do weapon recoil
1144         vec3_t mpunchangle[2], punchangle;
1145         // update by server, can be used by mods to kick view around
1146         vec3_t mpunchvector[2], punchvector;
1147         // update by server, used for lean+bob (0 is newest)
1148         vec3_t mvelocity[2], velocity;
1149         // update by server, can be used by mods for zooming
1150         vec_t mviewzoom[2], viewzoom;
1151         // if true interpolation the mviewangles and other interpolation of the
1152         // player is disabled until the next network packet
1153         // this is used primarily by teleporters, and when spectating players
1154         // special checking of the old fixangle[1] is used to differentiate
1155         // between teleporting and spectating
1156         qboolean fixangle[2];
1157
1158         // client movement simulation
1159         // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
1160         // set by CL_ClientMovement_Replay functions
1161         qboolean movement_predicted;
1162         // if true the CL_ClientMovement_Replay function will update origin, etc
1163         qboolean movement_replay;
1164         // simulated data (this is valid even if cl.movement is false)
1165         vec3_t movement_origin;
1166         vec3_t movement_velocity;
1167         // whether the replay should allow a jump at the first sequence
1168         qboolean movement_replay_canjump;
1169
1170         // previous gun angles (for leaning effects)
1171         vec3_t gunangles_prev;
1172         vec3_t gunangles_highpass;
1173         vec3_t gunangles_adjustment_lowpass;
1174         vec3_t gunangles_adjustment_highpass;
1175         // previous gun angles (for leaning effects)
1176         vec3_t gunorg_prev;
1177         vec3_t gunorg_highpass;
1178         vec3_t gunorg_adjustment_lowpass;
1179         vec3_t gunorg_adjustment_highpass;
1180
1181 // pitch drifting vars
1182         float idealpitch;
1183         float pitchvel;
1184         qboolean nodrift;
1185         float driftmove;
1186         double laststop;
1187
1188 //[515]: added for csqc purposes
1189         float sensitivityscale;
1190         csqc_vidvars_t csqc_vidvars;    //[515]: these parms must be set to true by default
1191         qboolean csqc_wantsmousemove;
1192         qboolean csqc_paused; // vortex: int because could be flags
1193         struct model_s *csqc_model_precache[MAX_MODELS];
1194
1195         // local amount for smoothing stepups
1196         //float crouch;
1197
1198         // sent by server
1199         qboolean paused;
1200         qboolean onground;
1201         qboolean inwater;
1202
1203         // used by bob
1204         qboolean oldonground;
1205         double lastongroundtime;
1206         double hitgroundtime;
1207         float bob2_smooth;
1208         float bobfall_speed;
1209         float bobfall_swing;
1210         double calcrefdef_prevtime;
1211
1212         // don't change view angle, full screen, etc
1213         int intermission;
1214         // latched at intermission start
1215         double completed_time;
1216
1217         // the timestamp of the last two messages
1218         double mtime[2];
1219
1220         // clients view of time, time should be between mtime[0] and mtime[1] to
1221         // generate a lerp point for other data, oldtime is the previous frame's
1222         // value of time, frametime is the difference between time and oldtime
1223         // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
1224         // is only forcefully limited when a packet is received
1225         double time, oldtime;
1226         // how long it has been since the previous client frame in real time
1227         // (not game time, for that use cl.time - cl.oldtime)
1228         double realframetime;
1229         
1230         // fade var for fading while dead
1231         float deathfade;
1232
1233         // motionblur alpha level variable
1234         float motionbluralpha;
1235
1236         // copy of realtime from last recieved message, for net trouble icon
1237         float last_received_message;
1238
1239 // information that is static for the entire time connected to a server
1240         struct model_s *model_precache[MAX_MODELS];
1241         struct sfx_s *sound_precache[MAX_SOUNDS];
1242
1243         // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
1244         char model_name[MAX_MODELS][MAX_QPATH];
1245         char sound_name[MAX_SOUNDS][MAX_QPATH];
1246
1247         // for display on solo scoreboard
1248         char worldmessage[40]; // map title (not related to filename)
1249         // variants of map name
1250         char worldbasename[MAX_QPATH]; // %s
1251         char worldname[MAX_QPATH]; // maps/%s.bsp
1252         char worldnamenoextension[MAX_QPATH]; // maps/%s
1253         // cl_entitites[cl.viewentity] = player
1254         int viewentity;
1255         // the real player entity (normally same as viewentity,
1256         // different than viewentity if mod uses chasecam or other tricks)
1257         int realplayerentity;
1258         // this is updated to match cl.viewentity whenever it is in the clients
1259         // range, basically this is used in preference to cl.realplayerentity for
1260         // most purposes because when spectating another player it should show
1261         // their information rather than yours
1262         int playerentity;
1263         // max players that can be in this game
1264         int maxclients;
1265         // type of game (deathmatch, coop, singleplayer)
1266         int gametype;
1267
1268         // models and sounds used by engine code (particularly cl_parse.c)
1269         dp_model_t *model_bolt;
1270         dp_model_t *model_bolt2;
1271         dp_model_t *model_bolt3;
1272         dp_model_t *model_beam;
1273         sfx_t *sfx_wizhit;
1274         sfx_t *sfx_knighthit;
1275         sfx_t *sfx_tink1;
1276         sfx_t *sfx_ric1;
1277         sfx_t *sfx_ric2;
1278         sfx_t *sfx_ric3;
1279         sfx_t *sfx_r_exp3;
1280         // indicates that the file "sound/misc/talk2.wav" was found (for use by team chat messages)
1281         qboolean foundtalk2wav;
1282
1283 // refresh related state
1284
1285         // cl_entitites[0].model
1286         struct model_s *worldmodel;
1287
1288         // the gun model
1289         entity_t viewent;
1290
1291         // cd audio
1292         int cdtrack, looptrack;
1293
1294 // frag scoreboard
1295
1296         // [cl.maxclients]
1297         scoreboard_t *scores;
1298
1299         // keep track of svc_print parsing state (analyzes ping reports and status reports)
1300         cl_parsingtextmode_t parsingtextmode;
1301         int parsingtextplayerindex;
1302         // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
1303         // (which could eat the wrong ping report if the player issues one
1304         //  manually, but they would still see a ping report, just a later one
1305         //  caused by the scoreboard code rather than the one they intentionally
1306         //  issued)
1307         int parsingtextexpectingpingforscores;
1308
1309         // entity database stuff
1310         // latest received entity frame numbers
1311 #define LATESTFRAMENUMS 32
1312         int latestframenumsposition;
1313         int latestframenums[LATESTFRAMENUMS];
1314         unsigned int latestsendnums[LATESTFRAMENUMS];
1315         entityframe_database_t *entitydatabase;
1316         entityframe4_database_t *entitydatabase4;
1317         entityframeqw_database_t *entitydatabaseqw;
1318
1319         // keep track of quake entities because they need to be killed if they get stale
1320         int lastquakeentity;
1321         unsigned char isquakeentity[MAX_EDICTS];
1322
1323         // bounding boxes for clientside movement
1324         vec3_t playerstandmins;
1325         vec3_t playerstandmaxs;
1326         vec3_t playercrouchmins;
1327         vec3_t playercrouchmaxs;
1328
1329         // old decals are killed based on this
1330         unsigned int decalsequence;
1331
1332         int max_entities;
1333         int max_csqcrenderentities;
1334         int max_static_entities;
1335         int max_effects;
1336         int max_beams;
1337         int max_dlights;
1338         int max_lightstyle;
1339         int max_brushmodel_entities;
1340         int max_particles;
1341         int max_decals;
1342         int max_showlmps;
1343
1344         entity_t *entities;
1345         entity_render_t *csqcrenderentities;
1346         unsigned char *entities_active;
1347         entity_t *static_entities;
1348         cl_effect_t *effects;
1349         beam_t *beams;
1350         dlight_t *dlights;
1351         lightstyle_t *lightstyle;
1352         int *brushmodel_entities;
1353         particle_t *particles;
1354         decal_t *decals;
1355         showlmp_t *showlmps;
1356
1357         int num_entities;
1358         int num_static_entities;
1359         int num_brushmodel_entities;
1360         int num_effects;
1361         int num_beams;
1362         int num_dlights;
1363         int num_particles;
1364         int num_decals;
1365         int num_showlmps;
1366
1367         double particles_updatetime;
1368         double decals_updatetime;
1369         int free_particle;
1370         int free_decal;
1371
1372         // cl_serverextension_download feature
1373         int loadmodel_current;
1374         int downloadmodel_current;
1375         int loadmodel_total;
1376         int loadsound_current;
1377         int downloadsound_current;
1378         int loadsound_total;
1379         qboolean downloadcsqc;
1380         qboolean loadcsqc;
1381         qboolean loadbegun;
1382         qboolean loadfinished;
1383
1384         // quakeworld stuff
1385
1386         // local copy of the server infostring
1387         char qw_serverinfo[MAX_SERVERINFO_STRING];
1388
1389         // time of last qw "pings" command sent to server while showing scores
1390         double last_ping_request;
1391
1392         // used during connect
1393         int qw_servercount;
1394
1395         // updated from serverinfo
1396         int qw_teamplay;
1397
1398         // unused: indicates whether the player is spectating
1399         // use cl.scores[cl.playerentity-1].qw_spectator instead
1400         //qboolean qw_spectator;
1401
1402         // last time an input packet was sent
1403         double lastpackettime;
1404
1405         // movement parameters for client prediction
1406         unsigned int moveflags;
1407         float movevars_wallfriction;
1408         float movevars_waterfriction;
1409         float movevars_friction;
1410         float movevars_timescale;
1411         float movevars_gravity;
1412         float movevars_stopspeed;
1413         float movevars_maxspeed;
1414         float movevars_spectatormaxspeed;
1415         float movevars_accelerate;
1416         float movevars_airaccelerate;
1417         float movevars_wateraccelerate;
1418         float movevars_entgravity;
1419         float movevars_jumpvelocity;
1420         float movevars_edgefriction;
1421         float movevars_maxairspeed;
1422         float movevars_stepheight;
1423         float movevars_airaccel_qw;
1424         float movevars_airaccel_qw_stretchfactor;
1425         float movevars_airaccel_sideways_friction;
1426         float movevars_airstopaccelerate;
1427         float movevars_airstrafeaccelerate;
1428         float movevars_maxairstrafespeed;
1429         float movevars_airstrafeaccel_qw;
1430         float movevars_aircontrol;
1431         float movevars_aircontrol_power;
1432         float movevars_aircontrol_penalty;
1433         float movevars_warsowbunny_airforwardaccel;
1434         float movevars_warsowbunny_accel;
1435         float movevars_warsowbunny_topspeed;
1436         float movevars_warsowbunny_turnaccel;
1437         float movevars_warsowbunny_backtosideratio;
1438         float movevars_ticrate;
1439         float movevars_airspeedlimit_nonqw;
1440
1441         // models used by qw protocol
1442         int qw_modelindex_spike;
1443         int qw_modelindex_player;
1444         int qw_modelindex_flag;
1445         int qw_modelindex_s_explod;
1446
1447         vec3_t qw_intermission_origin;
1448         vec3_t qw_intermission_angles;
1449
1450         // 255 is the most nails the QW protocol could send
1451         int qw_num_nails;
1452         vec_t qw_nails[255][6];
1453
1454         float qw_weaponkick;
1455
1456         unsigned int qw_validsequence;
1457
1458         unsigned int qw_deltasequence[QW_UPDATE_BACKUP];
1459
1460         // csqc stuff:
1461         // server entity number corresponding to a clientside entity
1462         unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
1463         qboolean csqc_loaded;
1464         vec3_t csqc_vieworigin;
1465         vec3_t csqc_viewangles;
1466         vec3_t csqc_vieworiginfromengine;
1467         vec3_t csqc_viewanglesfromengine;
1468         matrix4x4_t csqc_viewmodelmatrixfromengine;
1469         qboolean csqc_usecsqclistener;
1470         matrix4x4_t csqc_listenermatrix;
1471         char csqc_printtextbuf[MAX_INPUTLINE];
1472
1473         // collision culling data
1474         world_t world;
1475
1476         // loc file stuff (points and boxes describing locations in the level)
1477         cl_locnode_t *locnodes;
1478         // this is updated to cl.movement_origin whenever health is < 1
1479         // used by %d print in say/say_team messages if cl_locs_enable is on
1480         vec3_t lastdeathorigin;
1481
1482         // processing buffer used by R_BuildLightMap, reallocated as needed,
1483         // freed on each level change
1484         size_t buildlightmapmemorysize;
1485         unsigned char *buildlightmapmemory;
1486
1487         // used by EntityState5_ReadUpdate
1488         skeleton_t *engineskeletonobjects;
1489 }
1490 client_state_t;
1491
1492 //
1493 // cvars
1494 //
1495 extern cvar_t cl_name;
1496 extern cvar_t cl_color;
1497 extern cvar_t cl_rate;
1498 extern cvar_t cl_rate_burstsize;
1499 extern cvar_t cl_pmodel;
1500 extern cvar_t cl_playermodel;
1501 extern cvar_t cl_playerskin;
1502
1503 extern cvar_t rcon_password;
1504 extern cvar_t rcon_address;
1505
1506 extern cvar_t cl_upspeed;
1507 extern cvar_t cl_forwardspeed;
1508 extern cvar_t cl_backspeed;
1509 extern cvar_t cl_sidespeed;
1510
1511 extern cvar_t cl_movespeedkey;
1512
1513 extern cvar_t cl_yawspeed;
1514 extern cvar_t cl_pitchspeed;
1515
1516 extern cvar_t cl_anglespeedkey;
1517
1518 extern cvar_t cl_autofire;
1519
1520 extern cvar_t cl_shownet;
1521 extern cvar_t cl_nolerp;
1522 extern cvar_t cl_nettimesyncfactor;
1523 extern cvar_t cl_nettimesyncboundmode;
1524 extern cvar_t cl_nettimesyncboundtolerance;
1525
1526 extern cvar_t cl_pitchdriftspeed;
1527 extern cvar_t lookspring;
1528 extern cvar_t lookstrafe;
1529 extern cvar_t sensitivity;
1530
1531 extern cvar_t freelook;
1532
1533 extern cvar_t m_pitch;
1534 extern cvar_t m_yaw;
1535 extern cvar_t m_forward;
1536 extern cvar_t m_side;
1537
1538 extern cvar_t cl_autodemo;
1539 extern cvar_t cl_autodemo_nameformat;
1540 extern cvar_t cl_autodemo_delete;
1541
1542 extern cvar_t r_draweffects;
1543
1544 extern cvar_t cl_explosions_alpha_start;
1545 extern cvar_t cl_explosions_alpha_end;
1546 extern cvar_t cl_explosions_size_start;
1547 extern cvar_t cl_explosions_size_end;
1548 extern cvar_t cl_explosions_lifetime;
1549 extern cvar_t cl_stainmaps;
1550 extern cvar_t cl_stainmaps_clearonload;
1551
1552 extern cvar_t cl_prydoncursor;
1553 extern cvar_t cl_prydoncursor_notrace;
1554
1555 extern cvar_t cl_locs_enable;
1556
1557 extern client_state_t cl;
1558
1559 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);
1560
1561 cl_locnode_t *CL_Locs_FindNearest(const vec3_t point);
1562 void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point);
1563
1564 //=============================================================================
1565
1566 //
1567 // cl_main
1568 //
1569
1570 void CL_Shutdown (void);
1571 void CL_Init (void);
1572
1573 void CL_EstablishConnection(const char *host, int firstarg);
1574
1575 void CL_Disconnect (void);
1576 void CL_Disconnect_f (void);
1577
1578 void CL_UpdateRenderEntity(entity_render_t *ent);
1579 void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
1580 void CL_UpdateViewEntities(void);
1581
1582 //
1583 // cl_input
1584 //
1585 typedef struct kbutton_s
1586 {
1587         int             down[2];                // key nums holding it down
1588         int             state;                  // low bit is down state
1589 }
1590 kbutton_t;
1591
1592 extern  kbutton_t       in_mlook, in_klook;
1593 extern  kbutton_t       in_strafe;
1594 extern  kbutton_t       in_speed;
1595
1596 void CL_InitInput (void);
1597 void CL_SendMove (void);
1598
1599 void CL_ValidateState(entity_state_t *s);
1600 void CL_MoveLerpEntityStates(entity_t *ent);
1601 void CL_LerpUpdate(entity_t *e);
1602 void CL_ParseTEnt (void);
1603 void CL_NewBeam (int ent, vec3_t start, vec3_t end, dp_model_t *m, int lightning);
1604 void CL_RelinkBeams (void);
1605 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1606 void CL_ClientMovement_Replay(void);
1607
1608 void CL_ClearTempEntities (void);
1609 entity_render_t *CL_NewTempEntity (double shadertime);
1610
1611 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
1612
1613 void CL_ClearState (void);
1614 void CL_ExpandEntities(int num);
1615 void CL_ExpandCSQCRenderEntities(int num);
1616 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet);
1617
1618
1619 void CL_UpdateWorld (void);
1620 void CL_WriteToServer (void);
1621 void CL_Input (void);
1622 extern int cl_ignoremousemoves;
1623
1624
1625 float CL_KeyState (kbutton_t *key);
1626 const char *Key_KeynumToString (int keynum, char *buf, size_t buflength);
1627 int Key_StringToKeynum (const char *str);
1628
1629 //
1630 // cl_demo.c
1631 //
1632 void CL_StopPlayback(void);
1633 void CL_ReadDemoMessage(void);
1634 void CL_WriteDemoMessage(sizebuf_t *mesage);
1635
1636 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
1637 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
1638
1639 void CL_NextDemo(void);
1640 void CL_Stop_f(void);
1641 void CL_Record_f(void);
1642 void CL_PlayDemo_f(void);
1643 void CL_TimeDemo_f(void);
1644
1645 //
1646 // cl_parse.c
1647 //
1648 void CL_Parse_Init(void);
1649 void CL_Parse_Shutdown(void);
1650 void CL_ParseServerMessage(void);
1651 void CL_Parse_DumpPacket(void);
1652 void CL_Parse_ErrorCleanUp(void);
1653 void QW_CL_StartUpload(unsigned char *data, int size);
1654 extern cvar_t qport;
1655 void CL_KeepaliveMessage(qboolean readmessages); // call this during loading of large content
1656
1657 //
1658 // view
1659 //
1660 void V_StartPitchDrift (void);
1661 void V_StopPitchDrift (void);
1662
1663 void V_Init (void);
1664 float V_CalcRoll (const vec3_t angles, const vec3_t velocity);
1665 void V_UpdateBlends (void);
1666 void V_ParseDamage (void);
1667
1668 //
1669 // cl_part
1670 //
1671
1672 extern cvar_t cl_particles;
1673 extern cvar_t cl_particles_quality;
1674 extern cvar_t cl_particles_size;
1675 extern cvar_t cl_particles_quake;
1676 extern cvar_t cl_particles_blood;
1677 extern cvar_t cl_particles_blood_alpha;
1678 extern cvar_t cl_particles_blood_decal_alpha;
1679 extern cvar_t cl_particles_blood_decal_scalemin;
1680 extern cvar_t cl_particles_blood_decal_scalemax;
1681 extern cvar_t cl_particles_blood_bloodhack;
1682 extern cvar_t cl_particles_bulletimpacts;
1683 extern cvar_t cl_particles_explosions_sparks;
1684 extern cvar_t cl_particles_explosions_shell;
1685 extern cvar_t cl_particles_rain;
1686 extern cvar_t cl_particles_snow;
1687 extern cvar_t cl_particles_smoke;
1688 extern cvar_t cl_particles_smoke_alpha;
1689 extern cvar_t cl_particles_smoke_alphafade;
1690 extern cvar_t cl_particles_sparks;
1691 extern cvar_t cl_particles_bubbles;
1692 extern cvar_t cl_decals;
1693 extern cvar_t cl_decals_time;
1694 extern cvar_t cl_decals_fadetime;
1695
1696 void CL_Particles_Clear(void);
1697 void CL_Particles_Init(void);
1698 void CL_Particles_Shutdown(void);
1699 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]);
1700
1701 typedef enum effectnameindex_s
1702 {
1703         EFFECT_NONE,
1704         EFFECT_TE_GUNSHOT,
1705         EFFECT_TE_GUNSHOTQUAD,
1706         EFFECT_TE_SPIKE,
1707         EFFECT_TE_SPIKEQUAD,
1708         EFFECT_TE_SUPERSPIKE,
1709         EFFECT_TE_SUPERSPIKEQUAD,
1710         EFFECT_TE_WIZSPIKE,
1711         EFFECT_TE_KNIGHTSPIKE,
1712         EFFECT_TE_EXPLOSION,
1713         EFFECT_TE_EXPLOSIONQUAD,
1714         EFFECT_TE_TAREXPLOSION,
1715         EFFECT_TE_TELEPORT,
1716         EFFECT_TE_LAVASPLASH,
1717         EFFECT_TE_SMALLFLASH,
1718         EFFECT_TE_FLAMEJET,
1719         EFFECT_EF_FLAME,
1720         EFFECT_TE_BLOOD,
1721         EFFECT_TE_SPARK,
1722         EFFECT_TE_PLASMABURN,
1723         EFFECT_TE_TEI_G3,
1724         EFFECT_TE_TEI_SMOKE,
1725         EFFECT_TE_TEI_BIGEXPLOSION,
1726         EFFECT_TE_TEI_PLASMAHIT,
1727         EFFECT_EF_STARDUST,
1728         EFFECT_TR_ROCKET,
1729         EFFECT_TR_GRENADE,
1730         EFFECT_TR_BLOOD,
1731         EFFECT_TR_WIZSPIKE,
1732         EFFECT_TR_SLIGHTBLOOD,
1733         EFFECT_TR_KNIGHTSPIKE,
1734         EFFECT_TR_VORESPIKE,
1735         EFFECT_TR_NEHAHRASMOKE,
1736         EFFECT_TR_NEXUIZPLASMA,
1737         EFFECT_TR_GLOWTRAIL,
1738         EFFECT_SVC_PARTICLE,
1739         EFFECT_TOTAL
1740 }
1741 effectnameindex_t;
1742
1743 int CL_ParticleEffectIndexForName(const char *name);
1744 const char *CL_ParticleEffectNameForIndex(int i);
1745 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);
1746 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);
1747 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);
1748 void CL_ParseParticleEffect (void);
1749 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);
1750 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
1751 void CL_EntityParticles (const entity_t *ent);
1752 void CL_ParticleExplosion (const vec3_t org);
1753 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
1754 void R_NewExplosion(const vec3_t org);
1755
1756 #include "cl_screen.h"
1757
1758 extern qboolean sb_showscores;
1759
1760 float RSurf_FogVertex(const vec3_t p);
1761 float RSurf_FogPoint(const vec3_t p);
1762
1763 typedef enum r_viewport_type_e
1764 {
1765         R_VIEWPORTTYPE_ORTHO,
1766         R_VIEWPORTTYPE_PERSPECTIVE,
1767         R_VIEWPORTTYPE_PERSPECTIVE_INFINITEFARCLIP,
1768         R_VIEWPORTTYPE_PERSPECTIVECUBESIDE,
1769         R_VIEWPORTTYPE_TOTAL
1770 }
1771 r_viewport_type_t;
1772
1773 typedef struct r_viewport_s
1774 {
1775         matrix4x4_t cameramatrix; // from entity (transforms from camera entity to world)
1776         matrix4x4_t viewmatrix; // actual matrix for rendering (transforms to viewspace)
1777         matrix4x4_t projectmatrix; // actual projection matrix (transforms from viewspace to screen)
1778         int x;
1779         int y;
1780         int z;
1781         int width;
1782         int height;
1783         int depth;
1784         r_viewport_type_t type;
1785         float screentodepth[2]; // used by deferred renderer to calculate linear depth from device depth coordinates
1786 }
1787 r_viewport_t;
1788
1789 typedef struct r_refdef_view_s
1790 {
1791         // view information (changes multiple times per frame)
1792         // if any of these variables change then r_refdef.viewcache must be regenerated
1793         // by calling R_View_Update
1794         // (which also updates viewport, scissor, colormask)
1795
1796         // it is safe and expected to copy this into a structure on the stack and
1797         // call the renderer recursively, then restore from the stack afterward
1798         // (as long as R_View_Update is called)
1799
1800         // eye position information
1801         matrix4x4_t matrix, inverse_matrix;
1802         vec3_t origin;
1803         vec3_t forward;
1804         vec3_t left;
1805         vec3_t right;
1806         vec3_t up;
1807         int numfrustumplanes;
1808         mplane_t frustum[6];
1809         qboolean useclipplane;
1810         qboolean usecustompvs; // uses r_refdef.viewcache.pvsbits as-is rather than computing it
1811         mplane_t clipplane;
1812         float frustum_x, frustum_y;
1813         vec3_t frustumcorner[4];
1814         // if turned off it renders an ortho view
1815         int useperspective;
1816         float ortho_x, ortho_y;
1817
1818         // screen area to render in
1819         int x;
1820         int y;
1821         int z;
1822         int width;
1823         int height;
1824         int depth;
1825         r_viewport_t viewport; // note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and height
1826
1827         // which color components to allow (for anaglyph glasses)
1828         int colormask[4];
1829
1830         // global RGB color multiplier for rendering
1831         float colorscale;
1832
1833         // whether to call R_ClearScreen before rendering stuff
1834         qboolean clear;
1835         // if true, don't clear or do any post process effects (bloom, etc)
1836         qboolean isoverlay;
1837         // 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)
1838         qboolean ismain;
1839
1840         // whether to draw r_showtris and such, this is only true for the main
1841         // view render, all secondary renders (mirrors, portals, cameras,
1842         // distortion effects, etc) omit such debugging information
1843         qboolean showdebug;
1844
1845         // these define which values to use in GL_CullFace calls to request frontface or backface culling
1846         int cullface_front;
1847         int cullface_back;
1848
1849         // render quality (0 to 1) - affects r_drawparticles_drawdistance and others
1850         float quality;
1851 }
1852 r_refdef_view_t;
1853
1854 typedef struct r_refdef_viewcache_s
1855 {
1856         // updated by gl_main_newmap()
1857         int maxentities;
1858         int world_numclusters;
1859         int world_numclusterbytes;
1860         int world_numleafs;
1861         int world_numsurfaces;
1862
1863         // these properties are generated by R_View_Update()
1864
1865         // which entities are currently visible for this viewpoint
1866         // (the used range is 0...r_refdef.scene.numentities)
1867         unsigned char *entityvisible;
1868
1869         // flag arrays used for visibility checking on world model
1870         // (all other entities have no per-surface/per-leaf visibility checks)
1871         unsigned char *world_pvsbits;
1872         unsigned char *world_leafvisible;
1873         unsigned char *world_surfacevisible;
1874         // if true, the view is currently in a leaf without pvs data
1875         qboolean world_novis;
1876 }
1877 r_refdef_viewcache_t;
1878
1879 // TODO: really think about which fields should go into scene and which one should stay in refdef [1/7/2008 Black]
1880 // maybe also refactor some of the functions to support different setting sources (ie. fogenabled, etc.) for different scenes
1881 typedef struct r_refdef_scene_s {
1882         // whether to call S_ExtraUpdate during render to reduce sound chop
1883         qboolean extraupdate;
1884
1885         // (client gameworld) time for rendering time based effects
1886         double time;
1887
1888         // the world
1889         entity_render_t *worldentity;
1890
1891         // same as worldentity->model
1892         dp_model_t *worldmodel;
1893
1894         // renderable entities (excluding world)
1895         entity_render_t **entities;
1896         int numentities;
1897         int maxentities;
1898
1899         // field of temporary entities that is reset each (client) frame
1900         entity_render_t *tempentities;
1901         int numtempentities;
1902         int maxtempentities;
1903         qboolean expandtempentities;
1904
1905         // renderable dynamic lights
1906         rtlight_t *lights[MAX_DLIGHTS];
1907         rtlight_t templights[MAX_DLIGHTS];
1908         int numlights;
1909
1910         // intensities for light styles right now, controls rtlights
1911         float rtlightstylevalue[MAX_LIGHTSTYLES];       // float fraction of base light value
1912         // 8.8bit fixed point intensities for light styles
1913         // controls intensity lightmap layers
1914         unsigned short lightstylevalue[MAX_LIGHTSTYLES];        // 8.8 fraction of base light value
1915
1916         // adds brightness to the whole scene, separate from lightmapintensity
1917         // see CL_UpdateEntityShading
1918         float ambientintensity;
1919         // brightness of lightmap and modellight lighting on materials
1920         // see CL_UpdateEntityShading
1921         float lightmapintensity;
1922
1923         qboolean rtworld;
1924         qboolean rtworldshadows;
1925         qboolean rtdlight;
1926         qboolean rtdlightshadows;
1927 } r_refdef_scene_t;
1928
1929 typedef struct r_refdef_s
1930 {
1931         // these fields define the basic rendering information for the world
1932         // but not the view, which could change multiple times in one rendered
1933         // frame (for example when rendering textures for certain effects)
1934
1935         // these are set for water warping before
1936         // frustum_x/frustum_y are calculated
1937         float frustumscale_x, frustumscale_y;
1938
1939         // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
1940         r_refdef_view_t view;
1941         r_refdef_viewcache_t viewcache;
1942
1943         // minimum visible distance (pixels closer than this disappear)
1944         double nearclip;
1945         // maximum visible distance (pixels further than this disappear in 16bpp modes,
1946         // in 32bpp an infinite-farclip matrix is used instead)
1947         double farclip;
1948
1949         // fullscreen color blend
1950         float viewblend[4];
1951
1952         r_refdef_scene_t scene;
1953
1954         float fogplane[4];
1955         float fogplaneviewdist;
1956         qboolean fogplaneviewabove;
1957         float fogheightfade;
1958         float fogcolor[3];
1959         float fogrange;
1960         float fograngerecip;
1961         float fogmasktabledistmultiplier;
1962 #define FOGMASKTABLEWIDTH 1024
1963         float fogmasktable[FOGMASKTABLEWIDTH];
1964         float fogmasktable_start, fogmasktable_alpha, fogmasktable_range, fogmasktable_density;
1965         float fog_density;
1966         float fog_red;
1967         float fog_green;
1968         float fog_blue;
1969         float fog_alpha;
1970         float fog_start;
1971         float fog_end;
1972         float fog_height;
1973         float fog_fadedepth;
1974         qboolean fogenabled;
1975         qboolean oldgl_fogenable;
1976
1977         // new flexible texture height fog (overrides normal fog)
1978         char fog_height_texturename[64]; // note: must be 64 for the sscanf code
1979         unsigned char *fog_height_table1d;
1980         unsigned char *fog_height_table2d;
1981         int fog_height_tablesize; // enable
1982         float fog_height_tablescale;
1983         float fog_height_texcoordscale;
1984         char fogheighttexturename[64]; // detects changes to active fog height texture
1985
1986         int draw2dstage; // 0 = no, 1 = yes, other value = needs setting up again
1987
1988         // true during envmap command capture
1989         qboolean envmap;
1990
1991         // whether to draw world lights realtime, dlights realtime, and their shadows
1992         float polygonfactor;
1993         float polygonoffset;
1994         float shadowpolygonfactor;
1995         float shadowpolygonoffset;
1996
1997         // how long R_RenderView took on the previous frame
1998         double lastdrawscreentime;
1999
2000         // rendering stats for r_speeds display
2001         // (these are incremented in many places)
2002         int stats[r_stat_count];
2003 }
2004 r_refdef_t;
2005
2006 extern r_refdef_t r_refdef;
2007
2008 typedef enum waterlevel_e
2009 {
2010         WATERLEVEL_NONE,
2011         WATERLEVEL_WETFEET,
2012         WATERLEVEL_SWIMMING,
2013         WATERLEVEL_SUBMERGED
2014 }
2015 waterlevel_t;
2016
2017 typedef struct cl_clientmovement_state_s
2018 {
2019         // entity to be ignored for movement
2020         struct prvm_edict_s *self;
2021         // position
2022         vec3_t origin;
2023         vec3_t velocity;
2024         // current bounding box (different if crouched vs standing)
2025         vec3_t mins;
2026         vec3_t maxs;
2027         // currently on the ground
2028         qboolean onground;
2029         // currently crouching
2030         qboolean crouched;
2031         // what kind of water (SUPERCONTENTS_LAVA for instance)
2032         int watertype;
2033         // how deep
2034         waterlevel_t waterlevel;
2035         // weird hacks when jumping out of water
2036         // (this is in seconds and counts down to 0)
2037         float waterjumptime;
2038
2039         // user command
2040         usercmd_t cmd;
2041 }
2042 cl_clientmovement_state_t;
2043 void CL_ClientMovement_PlayerMove_Frame(cl_clientmovement_state_t *s);
2044
2045 // warpzone prediction hack (CSQC builtin)
2046 void CL_RotateMoves(const matrix4x4_t *m);
2047
2048 typedef enum meshname_e {
2049         MESH_DEBUG,
2050         MESH_CSQCPOLYGONS,
2051         MESH_PARTICLES,
2052         MESH_UI,
2053         NUM_MESHENTITIES,
2054 } meshname_t;
2055 extern entity_t cl_meshentities[NUM_MESHENTITIES];
2056 extern dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
2057 extern const char *cl_meshentitynames[NUM_MESHENTITIES];
2058 #define CL_Mesh_Debug() (&cl_meshentitymodels[MESH_DEBUG])
2059 #define CL_Mesh_CSQC() (&cl_meshentitymodels[MESH_CSQCPOLYGONS])
2060 #define CL_Mesh_Particles() (&cl_meshentitymodels[MESH_PARTICLES])
2061 #define CL_Mesh_UI() (&cl_meshentitymodels[MESH_UI])
2062 void CL_MeshEntities_AddToScene(void);
2063 void CL_MeshEntities_Reset(void);
2064 void CL_UpdateEntityShading(void);
2065
2066 void CL_NewFrameReceived(int num);
2067 void CL_ParseEntityLump(char *entitystring);
2068 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
2069 void CL_RelinkLightFlashes(void);
2070 void CL_Beam_AddPolygons(const beam_t *b);
2071 void Sbar_ShowFPS(void);
2072 void Sbar_ShowFPS_Update(void);
2073 void Host_SaveConfig(void);
2074 void Host_LoadConfig_f(void);
2075 void CL_UpdateMoveVars(void);
2076 void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length);
2077 void V_DriftPitch(void);
2078 void V_FadeViewFlashs(void);
2079 void V_CalcViewBlend(void);
2080 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);
2081 void V_CalcRefdef(void);
2082 void CL_Locs_Reload_f(void);
2083
2084 #endif
2085