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