]> git.xonotic.org Git - xonotic/darkplaces.git/blob - client.h
client: Add cl_particles.h and move cl_particles definitions to it.
[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 #include "view.h"
28 #include "cap.h"
29 #include "cl_parse.h"
30 #include "cl_particles.h"
31
32 // NOTE: r_stat_name[] must match this indexing
33 typedef enum r_stat_e
34 {
35         r_stat_timedelta,
36         r_stat_quality,
37         r_stat_renders,
38         r_stat_entities,
39         r_stat_entities_surfaces,
40         r_stat_entities_triangles,
41         r_stat_world_leafs,
42         r_stat_world_portals,
43         r_stat_world_surfaces,
44         r_stat_world_triangles,
45         r_stat_lightmapupdates,
46         r_stat_lightmapupdatepixels,
47         r_stat_particles,
48         r_stat_drawndecals,
49         r_stat_totaldecals,
50         r_stat_draws,
51         r_stat_draws_vertices,
52         r_stat_draws_elements,
53         r_stat_lights,
54         r_stat_lights_clears,
55         r_stat_lights_scissored,
56         r_stat_lights_lighttriangles,
57         r_stat_lights_shadowtriangles,
58         r_stat_lights_dynamicshadowtriangles,
59         r_stat_bouncegrid_lights,
60         r_stat_bouncegrid_particles,
61         r_stat_bouncegrid_traces,
62         r_stat_bouncegrid_hits,
63         r_stat_bouncegrid_splats,
64         r_stat_bouncegrid_bounces,
65         r_stat_photoncache_animated,
66         r_stat_photoncache_cached,
67         r_stat_photoncache_traced,
68         r_stat_bloom,
69         r_stat_bloom_copypixels,
70         r_stat_bloom_drawpixels,
71         r_stat_rendertargets_used,
72         r_stat_rendertargets_pixels,
73         r_stat_indexbufferuploadcount,
74         r_stat_indexbufferuploadsize,
75         r_stat_vertexbufferuploadcount,
76         r_stat_vertexbufferuploadsize,
77         r_stat_framedatacurrent,
78         r_stat_framedatasize,
79         r_stat_bufferdatacurrent_vertex, // R_BUFFERDATA_ types are added to this index
80         r_stat_bufferdatacurrent_index16,
81         r_stat_bufferdatacurrent_index32,
82         r_stat_bufferdatacurrent_uniform,
83         r_stat_bufferdatasize_vertex, // R_BUFFERDATA_ types are added to this index
84         r_stat_bufferdatasize_index16,
85         r_stat_bufferdatasize_index32,
86         r_stat_bufferdatasize_uniform,
87         r_stat_animcache_skeletal_count,
88         r_stat_animcache_skeletal_bones,
89         r_stat_animcache_skeletal_maxbones,
90         r_stat_animcache_shade_count,
91         r_stat_animcache_shade_vertices,
92         r_stat_animcache_shade_maxvertices,
93         r_stat_animcache_shape_count,
94         r_stat_animcache_shape_vertices,
95         r_stat_animcache_shape_maxvertices,
96         r_stat_batch_batches,
97         r_stat_batch_withgaps,
98         r_stat_batch_surfaces,
99         r_stat_batch_vertices,
100         r_stat_batch_triangles,
101         r_stat_batch_fast_batches,
102         r_stat_batch_fast_surfaces,
103         r_stat_batch_fast_vertices,
104         r_stat_batch_fast_triangles,
105         r_stat_batch_copytriangles_batches,
106         r_stat_batch_copytriangles_surfaces,
107         r_stat_batch_copytriangles_vertices,
108         r_stat_batch_copytriangles_triangles,
109         r_stat_batch_dynamic_batches,
110         r_stat_batch_dynamic_surfaces,
111         r_stat_batch_dynamic_vertices,
112         r_stat_batch_dynamic_triangles,
113         r_stat_batch_dynamicskeletal_batches,
114         r_stat_batch_dynamicskeletal_surfaces,
115         r_stat_batch_dynamicskeletal_vertices,
116         r_stat_batch_dynamicskeletal_triangles,
117         r_stat_batch_dynamic_batches_because_cvar,
118         r_stat_batch_dynamic_surfaces_because_cvar,
119         r_stat_batch_dynamic_vertices_because_cvar,
120         r_stat_batch_dynamic_triangles_because_cvar,
121         r_stat_batch_dynamic_batches_because_lightmapvertex,
122         r_stat_batch_dynamic_surfaces_because_lightmapvertex,
123         r_stat_batch_dynamic_vertices_because_lightmapvertex,
124         r_stat_batch_dynamic_triangles_because_lightmapvertex,
125         r_stat_batch_dynamic_batches_because_deformvertexes_autosprite,
126         r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite,
127         r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite,
128         r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite,
129         r_stat_batch_dynamic_batches_because_deformvertexes_autosprite2,
130         r_stat_batch_dynamic_surfaces_because_deformvertexes_autosprite2,
131         r_stat_batch_dynamic_vertices_because_deformvertexes_autosprite2,
132         r_stat_batch_dynamic_triangles_because_deformvertexes_autosprite2,
133         r_stat_batch_dynamic_batches_because_deformvertexes_normal,
134         r_stat_batch_dynamic_surfaces_because_deformvertexes_normal,
135         r_stat_batch_dynamic_vertices_because_deformvertexes_normal,
136         r_stat_batch_dynamic_triangles_because_deformvertexes_normal,
137         r_stat_batch_dynamic_batches_because_deformvertexes_wave,
138         r_stat_batch_dynamic_surfaces_because_deformvertexes_wave,
139         r_stat_batch_dynamic_vertices_because_deformvertexes_wave,
140         r_stat_batch_dynamic_triangles_because_deformvertexes_wave,
141         r_stat_batch_dynamic_batches_because_deformvertexes_bulge,
142         r_stat_batch_dynamic_surfaces_because_deformvertexes_bulge,
143         r_stat_batch_dynamic_vertices_because_deformvertexes_bulge,
144         r_stat_batch_dynamic_triangles_because_deformvertexes_bulge,
145         r_stat_batch_dynamic_batches_because_deformvertexes_move,
146         r_stat_batch_dynamic_surfaces_because_deformvertexes_move,
147         r_stat_batch_dynamic_vertices_because_deformvertexes_move,
148         r_stat_batch_dynamic_triangles_because_deformvertexes_move,
149         r_stat_batch_dynamic_batches_because_tcgen_lightmap,
150         r_stat_batch_dynamic_surfaces_because_tcgen_lightmap,
151         r_stat_batch_dynamic_vertices_because_tcgen_lightmap,
152         r_stat_batch_dynamic_triangles_because_tcgen_lightmap,
153         r_stat_batch_dynamic_batches_because_tcgen_vector,
154         r_stat_batch_dynamic_surfaces_because_tcgen_vector,
155         r_stat_batch_dynamic_vertices_because_tcgen_vector,
156         r_stat_batch_dynamic_triangles_because_tcgen_vector,
157         r_stat_batch_dynamic_batches_because_tcgen_environment,
158         r_stat_batch_dynamic_surfaces_because_tcgen_environment,
159         r_stat_batch_dynamic_vertices_because_tcgen_environment,
160         r_stat_batch_dynamic_triangles_because_tcgen_environment,
161         r_stat_batch_dynamic_batches_because_tcmod_turbulent,
162         r_stat_batch_dynamic_surfaces_because_tcmod_turbulent,
163         r_stat_batch_dynamic_vertices_because_tcmod_turbulent,
164         r_stat_batch_dynamic_triangles_because_tcmod_turbulent,
165         r_stat_batch_dynamic_batches_because_nogaps,
166         r_stat_batch_dynamic_surfaces_because_nogaps,
167         r_stat_batch_dynamic_vertices_because_nogaps,
168         r_stat_batch_dynamic_triangles_because_nogaps,
169         r_stat_batch_dynamic_batches_because_derived,
170         r_stat_batch_dynamic_surfaces_because_derived,
171         r_stat_batch_dynamic_vertices_because_derived,
172         r_stat_batch_dynamic_triangles_because_derived,
173         r_stat_batch_entitycache_count,
174         r_stat_batch_entitycache_surfaces,
175         r_stat_batch_entitycache_vertices,
176         r_stat_batch_entitycache_triangles,
177         r_stat_batch_entityanimate_count,
178         r_stat_batch_entityanimate_surfaces,
179         r_stat_batch_entityanimate_vertices,
180         r_stat_batch_entityanimate_triangles,
181         r_stat_batch_entityskeletal_count,
182         r_stat_batch_entityskeletal_surfaces,
183         r_stat_batch_entityskeletal_vertices,
184         r_stat_batch_entityskeletal_triangles,
185         r_stat_batch_entitystatic_count,
186         r_stat_batch_entitystatic_surfaces,
187         r_stat_batch_entitystatic_vertices,
188         r_stat_batch_entitystatic_triangles,
189         r_stat_batch_entitycustom_count,
190         r_stat_batch_entitycustom_surfaces,
191         r_stat_batch_entitycustom_vertices,
192         r_stat_batch_entitycustom_triangles,
193         r_stat_count // size of array
194 }
195 r_stat_t;
196
197 // flags for rtlight rendering
198 #define LIGHTFLAG_NORMALMODE 1
199 #define LIGHTFLAG_REALTIMEMODE 2
200
201 typedef struct tridecal_s
202 {
203         // color and initial alpha value
204         float                   texcoord2f[3][2];
205         float                   vertex3f[3][3];
206         float                   color4f[3][4];
207         float                   plane[4]; // backface culling
208         // how long this decal has lived so far (the actual fade begins at cl_decals_time)
209         float                   lived;
210         // if >= 0 this indicates the decal should follow an animated triangle
211         int                             triangleindex;
212         // for visibility culling
213         int                             surfaceindex;
214         // old decals are killed to obey cl_decals_max
215         unsigned int    decalsequence;
216 }
217 tridecal_t;
218
219 typedef struct decalsystem_s
220 {
221         dp_model_t *model;
222         double lastupdatetime;
223         int maxdecals;
224         int freedecal;
225         int numdecals;
226         tridecal_t *decals;
227         float *vertex3f;
228         float *texcoord2f;
229         float *color4f;
230         int *element3i;
231         unsigned short *element3s;
232 }
233 decalsystem_t;
234
235 typedef struct effect_s
236 {
237         int active;
238         vec3_t origin;
239         double starttime;
240         float framerate;
241         dp_model_t *model;
242         int startframe;
243         int endframe;
244         // these are for interpolation
245         int frame;
246         double frame1time;
247         double frame2time;
248 }
249 cl_effect_t;
250
251 typedef struct beam_s
252 {
253         int             entity;
254         // draw this as lightning polygons, or a model?
255         int             lightning;
256         struct model_s  *model;
257         float   endtime;
258         vec3_t  start, end;
259 }
260 beam_t;
261
262 typedef struct rtlight_particle_s
263 {
264         float origin[3];
265         float color[3];
266 }
267 rtlight_particle_t;
268
269 typedef struct rtlight_s
270 {
271         // note that the world to light matrices are inversely scaled (divided) by lightradius
272
273         // core properties
274         /// matrix for transforming light filter coordinates to world coordinates
275         matrix4x4_t matrix_lighttoworld;
276         /// matrix for transforming world coordinates to light filter coordinates
277         matrix4x4_t matrix_worldtolight;
278         /// typically 1 1 1, can be lower (dim) or higher (overbright)
279         vec3_t color;
280         /// size of the light (remove?)
281         vec_t radius;
282         /// light filter
283         char cubemapname[64];
284         /// light style to monitor for brightness
285         int style;
286         /// whether light should render shadows (see castshadows for whether it actually does this frame)
287         int shadow;
288         /// intensity of corona to render
289         vec_t corona;
290         /// radius scale of corona to render (1.0 means same as light radius)
291         vec_t coronasizescale;
292         /// ambient intensity to render
293         vec_t ambientscale;
294         /// diffuse intensity to render
295         vec_t diffusescale;
296         /// specular intensity to render
297         vec_t specularscale;
298         /// LIGHTFLAG_* flags
299         int flags;
300
301         // generated properties
302         /// used only for casting shadows
303         vec3_t shadoworigin;
304         /// culling
305         vec3_t cullmins;
306         vec3_t cullmaxs;
307         /// when r_shadow_culllights_trace is set, this is refreshed by each successful trace.
308         double trace_timer;
309
310         // rendering properties, updated each time a light is rendered
311         // this is rtlight->color * d_lightstylevalue
312         vec3_t currentcolor;
313         /// used by corona updates, due to occlusion query
314         float corona_visibility;
315         unsigned int corona_queryindex_visiblepixels;
316         unsigned int corona_queryindex_allpixels;
317         /// this is R_GetCubemap(rtlight->cubemapname)
318         rtexture_t *currentcubemap;
319         /// set by R_Shadow_PrepareLight to decide whether R_Shadow_DrawLight should draw it
320         qbool draw;
321         /// set by R_Shadow_PrepareLight to indicate whether R_Shadow_DrawShadowMaps should do anything
322         qbool castshadows;
323         /// these fields are set by R_Shadow_PrepareLight for later drawing
324         int cached_numlightentities;
325         int cached_numlightentities_noselfshadow;
326         int cached_numshadowentities;
327         int cached_numshadowentities_noselfshadow;
328         int cached_numsurfaces;
329         struct entity_render_s **cached_lightentities;
330         struct entity_render_s **cached_lightentities_noselfshadow;
331         struct entity_render_s **cached_shadowentities;
332         struct entity_render_s **cached_shadowentities_noselfshadow;
333         unsigned char *cached_shadowtrispvs;
334         unsigned char *cached_lighttrispvs;
335         int *cached_surfacelist;
336         // reduced light cullbox from GetLightInfo
337         vec3_t cached_cullmins;
338         vec3_t cached_cullmaxs;
339         // current shadow-caster culling planes based on view
340         // (any geometry outside these planes can not contribute to the visible
341         //  shadows in any way, and thus can be culled safely)
342         int cached_numfrustumplanes;
343         mplane_t cached_frustumplanes[5]; // see R_Shadow_ComputeShadowCasterCullingPlanes
344
345         /// static light info
346         /// true if this light should be compiled as a static light
347         int isstatic;
348         /// true if this is a compiled world light, cleared if the light changes
349         int compiled;
350         /// the size that this light should have (assuming no scene LOD kicking in to reduce it)
351         int shadowmapsidesize;
352         /// position of this light in the shadowmap atlas
353         int shadowmapatlasposition[2];
354         /// 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)
355         int shadowmapatlassidesize;
356         /// optimized and culled mesh to render for world entity shadows
357         shadowmesh_t *static_meshchain_shadow_shadowmap;
358         /// used for visibility testing (more exact than bbox)
359         int static_numleafs;
360         int static_numleafpvsbytes;
361         int *static_leaflist;
362         unsigned char *static_leafpvs;
363         /// surfaces seen by light
364         int static_numsurfaces;
365         int *static_surfacelist;
366         /// flag bits indicating which triangles of the world model should cast
367         /// shadows, and which ones should be lit
368         ///
369         /// this avoids redundantly scanning the triangles in each surface twice
370         /// for whether they should cast shadows, once in culling and once in the
371         /// actual shadowmarklist production.
372         int static_numshadowtrispvsbytes;
373         unsigned char *static_shadowtrispvs;
374         /// this allows the lighting batch code to skip backfaces andother culled
375         /// triangles not relevant for lighting
376         /// (important on big surfaces such as terrain)
377         int static_numlighttrispvsbytes;
378         unsigned char *static_lighttrispvs;
379         /// masks of all shadowmap sides that have any potential static receivers or casters
380         int static_shadowmap_receivers;
381         int static_shadowmap_casters;
382         /// particle-tracing cache for global illumination
383         int particlecache_numparticles;
384         int particlecache_maxparticles;
385         int particlecache_updateparticle;
386         rtlight_particle_t *particlecache_particles;
387
388         /// bouncegrid light info
389         float bouncegrid_photoncolor[3];
390         float bouncegrid_photons;
391         int bouncegrid_hits;
392         int bouncegrid_traces;
393         float bouncegrid_effectiveradius;
394 }
395 rtlight_t;
396
397 typedef struct dlight_s
398 {
399         // destroy light after this time
400         // (dlight only)
401         vec_t die;
402         // the entity that owns this light (can be NULL)
403         // (dlight only)
404         struct entity_render_s *ent;
405         // location
406         // (worldlight: saved to .rtlights file)
407         vec3_t origin;
408         // worldlight orientation
409         // (worldlight only)
410         // (worldlight: saved to .rtlights file)
411         vec3_t angles;
412         // dlight orientation/scaling/location
413         // (dlight only)
414         matrix4x4_t matrix;
415         // color of light
416         // (worldlight: saved to .rtlights file)
417         vec3_t color;
418         // cubemap name to use on this light
419         // (worldlight: saved to .rtlights file)
420         char cubemapname[64];
421         // make light flash while selected
422         // (worldlight only)
423         int selected;
424         // brightness (not really radius anymore)
425         // (worldlight: saved to .rtlights file)
426         vec_t radius;
427         // drop intensity this much each second
428         // (dlight only)
429         vec_t decay;
430         // intensity value which is dropped over time
431         // (dlight only)
432         vec_t intensity;
433         // initial values for intensity to modify
434         // (dlight only)
435         vec_t initialradius;
436         vec3_t initialcolor;
437         // light style which controls intensity of this light
438         // (worldlight: saved to .rtlights file)
439         int style;
440         // cast shadows
441         // (worldlight: saved to .rtlights file)
442         int shadow;
443         // corona intensity
444         // (worldlight: saved to .rtlights file)
445         vec_t corona;
446         // radius scale of corona to render (1.0 means same as light radius)
447         // (worldlight: saved to .rtlights file)
448         vec_t coronasizescale;
449         // ambient intensity to render
450         // (worldlight: saved to .rtlights file)
451         vec_t ambientscale;
452         // diffuse intensity to render
453         // (worldlight: saved to .rtlights file)
454         vec_t diffusescale;
455         // specular intensity to render
456         // (worldlight: saved to .rtlights file)
457         vec_t specularscale;
458         // LIGHTFLAG_* flags
459         // (worldlight: saved to .rtlights file)
460         int flags;
461         // linked list of world lights
462         // (worldlight only)
463         struct dlight_s *next;
464         // embedded rtlight struct for renderer
465         // (worldlight only)
466         rtlight_t rtlight;
467 }
468 dlight_t;
469
470 // this is derived from processing of the framegroupblend array
471 // note: technically each framegroupblend can produce two of these, but that
472 // never happens in practice because no one blends between more than 2
473 // framegroups at once
474 #define MAX_FRAMEBLENDS (MAX_FRAMEGROUPBLENDS * 2)
475 typedef struct frameblend_s
476 {
477         int subframe;
478         float lerp;
479 }
480 frameblend_t;
481
482 // LadyHavoc: this struct is intended for the renderer but some fields are
483 // used by the client.
484 //
485 // The renderer should not rely on any changes to this struct to be persistent
486 // across multiple frames because temp entities are wiped every frame, but it
487 // is acceptable to cache things in this struct that are not critical.
488 //
489 // For example the r_cullentities_trace code does such caching.
490 typedef struct entity_render_s
491 {
492         // location
493         //vec3_t origin;
494         // orientation
495         //vec3_t angles;
496         // transform matrix for model to world
497         matrix4x4_t matrix;
498         // transform matrix for world to model
499         matrix4x4_t inversematrix;
500         // opacity (alpha) of the model
501         float alpha;
502         // size the model is shown
503         float scale;
504         // transparent sorting offset
505         float transparent_offset;
506
507         // NULL = no model
508         dp_model_t *model;
509         // number of the entity represents, or 0 for non-network entities
510         int entitynumber;
511         // literal colormap colors for renderer, if both are 0 0 0 it is not colormapped
512         vec3_t colormap_pantscolor;
513         vec3_t colormap_shirtcolor;
514         // light, particles, etc
515         int effects;
516         // qw CTF flags and other internal-use-only effect bits
517         int internaleffects;
518         // for Alias models
519         int skinnum;
520         // render flags
521         int flags;
522
523         // colormod tinting of models
524         float colormod[3];
525         float glowmod[3];
526
527         // interpolated animation - active framegroups and blend factors
528         framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
529
530         // time of last model change (for shader animations)
531         double shadertime;
532
533         // calculated by the renderer (but not persistent)
534
535         // calculated during R_AddModelEntities
536         vec3_t mins, maxs;
537         // subframe numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use subframeblend[0].subframe
538         frameblend_t frameblend[MAX_FRAMEBLENDS];
539         // skeletal animation data (if skeleton.relativetransforms is not NULL, it overrides frameblend)
540         skeleton_t *skeleton;
541
542         // animation cache (pointers allocated using R_FrameData_Alloc)
543         // ONLY valid during R_RenderView!  may be NULL (not cached)
544         float          *animcache_vertex3f;
545         r_meshbuffer_t *animcache_vertex3f_vertexbuffer;
546         int             animcache_vertex3f_bufferoffset;
547         float          *animcache_normal3f;
548         r_meshbuffer_t *animcache_normal3f_vertexbuffer;
549         int             animcache_normal3f_bufferoffset;
550         float          *animcache_svector3f;
551         r_meshbuffer_t *animcache_svector3f_vertexbuffer;
552         int             animcache_svector3f_bufferoffset;
553         float          *animcache_tvector3f;
554         r_meshbuffer_t *animcache_tvector3f_vertexbuffer;
555         int             animcache_tvector3f_bufferoffset;
556         // gpu-skinning shader needs transforms in a certain format, we have to
557         // upload this to a uniform buffer for the shader to use, and also keep a
558         // backup copy in system memory for the dynamic batch fallback code
559         // if this is not NULL, the other animcache variables are NULL
560         float *animcache_skeletaltransform3x4;
561         r_meshbuffer_t *animcache_skeletaltransform3x4buffer;
562         int animcache_skeletaltransform3x4offset;
563         int animcache_skeletaltransform3x4size;
564
565         // CL_UpdateEntityShading reads these fields
566         // used only if RENDER_CUSTOMIZEDMODELLIGHT is set
567         vec3_t custommodellight_ambient;
568         vec3_t custommodellight_diffuse;
569         vec3_t custommodellight_lightdir;
570         // CSQC entities get their shading from the root of their attachment chain
571         float custommodellight_origin[3];
572
573         // derived lighting parameters (CL_UpdateEntityShading)
574
575         // used by MATERIALFLAG_FULLBRIGHT which is MATERIALFLAG_MODELLIGHT with
576         // this as ambient color, along with MATERIALFLAG_NORTLIGHT
577         float render_fullbright[3];
578         // color tint for the base pass glow textures if any
579         float render_glowmod[3];
580         // MATERIALFLAG_MODELLIGHT uses these parameters
581         float render_modellight_ambient[3];
582         float render_modellight_diffuse[3];
583         float render_modellight_lightdir_world[3];
584         float render_modellight_lightdir_local[3];
585         float render_modellight_specular[3];
586         // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
587         float render_lightmap_ambient[3];
588         float render_lightmap_diffuse[3];
589         float render_lightmap_specular[3];
590         // rtlights use these colors for the materials on this entity
591         float render_rtlight_diffuse[3];
592         float render_rtlight_specular[3];
593         // ignore lightmap and use fixed lighting settings on this entity (e.g. FULLBRIGHT)
594         qbool render_modellight_forced;
595         // do not process per pixel lights on this entity at all (like MATERIALFLAG_NORTLIGHT)
596         qbool render_rtlight_disabled;
597         // use the 3D lightmap from q3bsp on this entity
598         qbool render_lightgrid;
599
600         // storage of decals on this entity
601         // (note: if allowdecals is set, be sure to call R_DecalSystem_Reset on removal!)
602         int allowdecals;
603         decalsystem_t decalsystem;
604
605         // FIELDS UPDATED BY RENDERER:
606         // last time visible during trace culling
607         double last_trace_visibility;
608
609         // user wavefunc parameters (from csqc)
610         vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
611 }
612 entity_render_t;
613
614 typedef struct entity_persistent_s
615 {
616         vec3_t trail_origin; // previous position for particle trail spawning
617         vec3_t oldorigin; // lerp
618         vec3_t oldangles; // lerp
619         vec3_t neworigin; // lerp
620         vec3_t newangles; // lerp
621         vec_t lerpstarttime; // lerp
622         vec_t lerpdeltatime; // lerp
623         float muzzleflash; // muzzleflash intensity, fades over time
624         float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
625         qbool trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
626 }
627 entity_persistent_t;
628
629 typedef struct entity_s
630 {
631         // baseline state (default values)
632         entity_state_t state_baseline;
633         // previous state (interpolating from this)
634         entity_state_t state_previous;
635         // current state (interpolating to this)
636         entity_state_t state_current;
637
638         // used for regenerating parts of render
639         entity_persistent_t persistent;
640
641         // the only data the renderer should know about
642         entity_render_t render;
643 }
644 entity_t;
645
646 typedef struct usercmd_s
647 {
648         vec3_t  viewangles;
649
650 // intended velocities
651         float   forwardmove;
652         float   sidemove;
653         float   upmove;
654
655         vec3_t  cursor_screen;
656         vec3_t  cursor_start;
657         vec3_t  cursor_end;
658         vec3_t  cursor_impact;
659         vec3_t  cursor_normal;
660         vec_t   cursor_fraction;
661         int             cursor_entitynumber;
662
663         double time; // time the move is executed for (cl_movement: clienttime, non-cl_movement: receivetime)
664         double receivetime; // time the move was received at
665         double clienttime; // time to which server state the move corresponds to
666         int msec; // for predicted moves
667         int buttons;
668         int impulse;
669         unsigned int sequence;
670         qbool applied; // if false we're still accumulating a move
671         qbool predicted; // if true the sequence should be sent as 0
672
673         // derived properties
674         double frametime;
675         qbool canjump;
676         qbool jump;
677         qbool crouch;
678 } usercmd_t;
679
680 typedef struct lightstyle_s
681 {
682         int             length;
683         char    map[MAX_STYLESTRING];
684 } lightstyle_t;
685
686 typedef struct scoreboard_s
687 {
688         char    name[MAX_SCOREBOARDNAME];
689         int             frags;
690         int             colors; // two 4 bit fields
691         // QW fields:
692         int             qw_userid;
693         char    qw_userinfo[MAX_USERINFO_STRING];
694         float   qw_entertime;
695         int             qw_ping;
696         int             qw_packetloss;
697         int             qw_movementloss;
698         int             qw_spectator;
699         char    qw_team[8];
700         char    qw_skin[MAX_QPATH];
701 } scoreboard_t;
702
703 typedef struct cshift_s
704 {
705         float   destcolor[3];
706         float   percent;                // 0-255
707         float   alphafade;      // (any speed)
708 } cshift_t;
709
710 #define CSHIFT_CONTENTS 0
711 #define CSHIFT_DAMAGE   1
712 #define CSHIFT_BONUS    2
713 #define CSHIFT_POWERUP  3
714 #define CSHIFT_VCSHIFT  4
715 #define NUM_CSHIFTS             5
716
717 #define NAME_LENGTH     64
718
719
720 //
721 // client_state_t should hold all pieces of the client state
722 //
723
724 #define SIGNONS         4                       // signon messages to receive before connected
725
726 typedef enum cactive_e
727 {
728         ca_uninitialized,       // during early startup
729         ca_dedicated,           // a dedicated server with no ability to start a client
730         ca_disconnected,        // full screen console with no connection
731         ca_connected            // valid netcon, talking to a server
732 }
733 cactive_t;
734
735 typedef enum qw_downloadtype_e
736 {
737         dl_none,
738         dl_single,
739         dl_skin,
740         dl_model,
741         dl_sound
742 }
743 qw_downloadtype_t;
744
745 #define CL_MAX_DOWNLOADACKS 4
746
747 typedef struct cl_downloadack_s
748 {
749         int start, size;
750 }
751 cl_downloadack_t;
752
753 typedef struct cl_soundstats_s
754 {
755         int mixedsounds;
756         int totalsounds;
757         int latency_milliseconds;
758 }
759 cl_soundstats_t;
760
761 //
762 // the client_static_t structure is persistent through an arbitrary number
763 // of server connections
764 //
765 typedef struct client_static_s
766 {
767         cactive_t state;
768
769         // all client memory allocations go in these pools
770         mempool_t *levelmempool;
771         mempool_t *permanentmempool;
772
773 // demo loop control
774         // -1 = don't play demos
775         int demonum;
776         // list of demos in loop
777         char demos[MAX_DEMOS][MAX_DEMONAME];
778         // the actively playing demo (set by CL_PlayDemo_f)
779         char demoname[MAX_QPATH];
780
781 // demo recording info must be here, because record is started before
782 // entering a map (and clearing client_state_t)
783         qbool demorecording;
784         fs_offset_t demo_lastcsprogssize;
785         int demo_lastcsprogscrc;
786         qbool demoplayback;
787         qbool demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo
788         qbool timedemo;
789         // -1 = use normal cd track
790         int forcetrack;
791         qfile_t *demofile;
792         // realtime at second frame of timedemo (LadyHavoc: changed to double)
793         double td_starttime;
794         int td_frames; // total frames parsed
795         double td_onesecondnexttime;
796         double td_onesecondframes;
797         double td_onesecondrealtime;
798         double td_onesecondminfps;
799         double td_onesecondmaxfps;
800         double td_onesecondavgfps;
801         int td_onesecondavgcount;
802         // LadyHavoc: pausedemo
803         qbool demopaused;
804
805         // sound mixer statistics for showsound display
806         cl_soundstats_t soundstats;
807
808         qbool connect_trying;
809         int connect_remainingtries;
810         double connect_nextsendtime;
811         lhnetsocket_t *connect_mysocket;
812         lhnetaddress_t connect_address;
813         lhnetaddress_t rcon_address;
814         // protocol version of the server we're connected to
815         // (kept outside client_state_t because it's used between levels)
816         protocolversion_t protocol;
817
818 #define MAX_RCONS 16
819         int rcon_trying;
820         lhnetaddress_t rcon_addresses[MAX_RCONS];
821         char rcon_commands[MAX_RCONS][MAX_INPUTLINE];
822         double rcon_timeout[MAX_RCONS];
823         int rcon_ringpos;
824
825 // connection information
826         // 0 to SIGNONS
827         int signon;
828         // network connection
829         netconn_t *netcon;
830
831         // download information
832         // (note: qw_download variables are also used)
833         cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
834
835         // input sequence numbers are not reset on level change, only connect
836         unsigned int servermovesequence;
837
838         // quakeworld stuff below
839
840         // value of "qport" cvar at time of connection
841         int qw_qport;
842         // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
843         unsigned int qw_incoming_sequence;
844         unsigned int qw_outgoing_sequence;
845
846         // current file download buffer (only saved when file is completed)
847         char qw_downloadname[MAX_QPATH];
848         unsigned char *qw_downloadmemory;
849         int qw_downloadmemorycursize;
850         int qw_downloadmemorymaxsize;
851         int qw_downloadnumber;
852         int qw_downloadpercent;
853         qw_downloadtype_t qw_downloadtype;
854         // transfer rate display
855         double qw_downloadspeedtime;
856         int qw_downloadspeedcount;
857         int qw_downloadspeedrate;
858         qbool qw_download_deflate;
859
860         // current file upload buffer (for uploading screenshots to server)
861         unsigned char *qw_uploaddata;
862         int qw_uploadsize;
863         int qw_uploadpos;
864
865         // user infostring
866         // this normally contains the following keys in quakeworld:
867         // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
868         char userinfo[MAX_USERINFO_STRING];
869
870         // extra user info for the "connect" command
871         char connect_userinfo[MAX_USERINFO_STRING];
872
873 #ifdef CONFIG_VIDEO_CAPTURE
874         // video capture stuff
875         capturevideostate_t capturevideo;
876 #endif
877
878         // crypto channel
879         crypto_t crypto;
880
881         // ProQuake compatibility stuff
882         int proquake_servermod; // 0 = not proquake, 1 = proquake
883         int proquake_serverversion; // actual proquake server version * 10 (3.40 = 34, etc)
884         int proquake_serverflags; // 0 (PQF_CHEATFREE not supported)
885
886         // don't write-then-read csprogs.dat (useful for demo playback)
887         unsigned char *caughtcsprogsdata;
888         fs_offset_t caughtcsprogsdatasize;
889
890         int r_speeds_graph_length;
891         int r_speeds_graph_current;
892         int *r_speeds_graph_data;
893
894         // graph scales
895         int r_speeds_graph_datamin[r_stat_count];
896         int r_speeds_graph_datamax[r_stat_count];
897 }
898 client_static_t;
899
900 extern client_static_t  cls;
901
902 //[515]: csqc
903 typedef struct
904 {
905         qbool drawworld;
906         qbool drawenginesbar;
907         qbool drawcrosshair;
908 }csqc_vidvars_t;
909
910 typedef enum cl_parsingtextmode_e
911 {
912         CL_PARSETEXTMODE_NONE,
913         CL_PARSETEXTMODE_PING,
914         CL_PARSETEXTMODE_STATUS,
915         CL_PARSETEXTMODE_STATUS_PLAYERID,
916         CL_PARSETEXTMODE_STATUS_PLAYERIP
917 }
918 cl_parsingtextmode_t;
919
920 typedef struct cl_locnode_s
921 {
922         struct cl_locnode_s *next;
923         char *name;
924         vec3_t mins, maxs;
925 }
926 cl_locnode_t;
927
928 typedef struct showlmp_s
929 {
930         qbool   isactive;
931         float           x;
932         float           y;
933         char            label[32];
934         char            pic[128];
935 }
936 showlmp_t;
937
938 //
939 // the client_state_t structure is wiped completely at every
940 // server signon
941 //
942 typedef struct client_state_s
943 {
944         // true if playing in a local game and no one else is connected
945         int islocalgame;
946
947         // send a clc_nop periodically until connected
948         float sendnoptime;
949
950         // current input being accumulated by mouse/joystick/etc input
951         usercmd_t cmd;
952         // latest moves sent to the server that have not been confirmed yet
953         usercmd_t movecmd[CL_MAX_USERCMDS];
954
955 // information for local display
956         // health, etc
957         int stats[MAX_CL_STATS];
958         float *statsf; // points to stats[] array
959         // last known inventory bit flags, for blinking
960         int olditems;
961         // cl.time of acquiring item, for blinking
962         float item_gettime[32];
963         // last known STAT_ACTIVEWEAPON
964         int activeweapon;
965         // cl.time of changing STAT_ACTIVEWEAPON
966         float weapontime;
967         // use pain anim frame if cl.time < this
968         float faceanimtime;
969         // for stair smoothing
970         float stairsmoothz;
971         double stairsmoothtime;
972
973         // color shifts for damage, powerups
974         cshift_t cshifts[NUM_CSHIFTS];
975         // and content types
976         cshift_t prev_cshifts[NUM_CSHIFTS];
977
978 // the client maintains its own idea of view angles, which are
979 // sent to the server each frame.  The server sets punchangle when
980 // the view is temporarily offset, and an angle reset commands at the start
981 // of each level and after teleporting.
982
983         // mviewangles is read from demo
984         // viewangles is either client controlled or lerped from mviewangles
985         vec3_t mviewangles[2], viewangles;
986         // update by server, used by qc to do weapon recoil
987         vec3_t mpunchangle[2], punchangle;
988         // update by server, can be used by mods to kick view around
989         vec3_t mpunchvector[2], punchvector;
990         // update by server, used for lean+bob (0 is newest)
991         vec3_t mvelocity[2], velocity;
992         // update by server, can be used by mods for zooming
993         vec_t mviewzoom[2], viewzoom;
994         // if true interpolation the mviewangles and other interpolation of the
995         // player is disabled until the next network packet
996         // this is used primarily by teleporters, and when spectating players
997         // special checking of the old fixangle[1] is used to differentiate
998         // between teleporting and spectating
999         qbool fixangle[2];
1000
1001         // client movement simulation
1002         // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
1003         // set by CL_ClientMovement_Replay functions
1004         qbool movement_predicted;
1005         // if true the CL_ClientMovement_Replay function will update origin, etc
1006         qbool movement_replay;
1007         // simulated data (this is valid even if cl.movement is false)
1008         vec3_t movement_origin;
1009         vec3_t movement_velocity;
1010         // whether the replay should allow a jump at the first sequence
1011         qbool movement_replay_canjump;
1012
1013         // previous gun angles (for leaning effects)
1014         vec3_t gunangles_prev;
1015         vec3_t gunangles_highpass;
1016         vec3_t gunangles_adjustment_lowpass;
1017         vec3_t gunangles_adjustment_highpass;
1018         // previous gun angles (for leaning effects)
1019         vec3_t gunorg_prev;
1020         vec3_t gunorg_highpass;
1021         vec3_t gunorg_adjustment_lowpass;
1022         vec3_t gunorg_adjustment_highpass;
1023
1024 // pitch drifting vars
1025         float idealpitch;
1026         float pitchvel;
1027         qbool nodrift;
1028         float driftmove;
1029         double laststop;
1030
1031 //[515]: added for csqc purposes
1032         float sensitivityscale;
1033         csqc_vidvars_t csqc_vidvars;    //[515]: these parms must be set to true by default
1034         qbool csqc_wantsmousemove;
1035         struct model_s *csqc_model_precache[MAX_MODELS];
1036
1037         // local amount for smoothing stepups
1038         //float crouch;
1039
1040         // sent by server
1041         qbool paused;
1042         qbool onground;
1043         qbool inwater;
1044
1045         // used by bob
1046         qbool oldonground;
1047         double lastongroundtime;
1048         double hitgroundtime;
1049         float bob2_smooth;
1050         float bobfall_speed;
1051         float bobfall_swing;
1052         double calcrefdef_prevtime;
1053
1054         // don't change view angle, full screen, etc
1055         int intermission;
1056         // latched at intermission start
1057         double completed_time;
1058
1059         // the timestamp of the last two messages
1060         double mtime[2];
1061
1062         // clients view of time, time should be between mtime[0] and mtime[1] to
1063         // generate a lerp point for other data, oldtime is the previous frame's
1064         // value of time, frametime is the difference between time and oldtime
1065         // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
1066         // is only forcefully limited when a packet is received
1067         double time, oldtime;
1068         // how long it has been since the previous client frame in real time
1069         // (not game time, for that use cl.time - cl.oldtime)
1070         double realframetime;
1071         
1072         // fade var for fading while dead
1073         float deathfade;
1074
1075         // motionblur alpha level variable
1076         float motionbluralpha;
1077
1078         // copy of realtime from last recieved message, for net trouble icon
1079         float last_received_message;
1080
1081 // information that is static for the entire time connected to a server
1082         struct model_s *model_precache[MAX_MODELS];
1083         struct sfx_s *sound_precache[MAX_SOUNDS];
1084
1085         // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
1086         char model_name[MAX_MODELS][MAX_QPATH];
1087         char sound_name[MAX_SOUNDS][MAX_QPATH];
1088
1089         // for display on solo scoreboard
1090         char worldmessage[40]; // map title (not related to filename)
1091         // variants of map name
1092         char worldbasename[MAX_QPATH]; // %s
1093         char worldname[MAX_QPATH]; // maps/%s.bsp
1094         char worldnamenoextension[MAX_QPATH]; // maps/%s
1095         // cl_entitites[cl.viewentity] = player
1096         int viewentity;
1097         // the real player entity (normally same as viewentity,
1098         // different than viewentity if mod uses chasecam or other tricks)
1099         int realplayerentity;
1100         // this is updated to match cl.viewentity whenever it is in the clients
1101         // range, basically this is used in preference to cl.realplayerentity for
1102         // most purposes because when spectating another player it should show
1103         // their information rather than yours
1104         int playerentity;
1105         // max players that can be in this game
1106         int maxclients;
1107         // type of game (deathmatch, coop, singleplayer)
1108         int gametype;
1109
1110         // models and sounds used by engine code (particularly cl_parse.c)
1111         dp_model_t *model_bolt;
1112         dp_model_t *model_bolt2;
1113         dp_model_t *model_bolt3;
1114         dp_model_t *model_beam;
1115         sfx_t *sfx_wizhit;
1116         sfx_t *sfx_knighthit;
1117         sfx_t *sfx_tink1;
1118         sfx_t *sfx_ric1;
1119         sfx_t *sfx_ric2;
1120         sfx_t *sfx_ric3;
1121         sfx_t *sfx_r_exp3;
1122         // indicates that the file "sound/misc/talk2.wav" was found (for use by team chat messages)
1123         qbool foundteamchatsound;
1124
1125 // refresh related state
1126
1127         // cl_entitites[0].model
1128         struct model_s *worldmodel;
1129
1130         // the gun model
1131         entity_t viewent;
1132
1133         // cd audio
1134         int cdtrack, looptrack;
1135
1136 // frag scoreboard
1137
1138         // [cl.maxclients]
1139         scoreboard_t *scores;
1140
1141         // keep track of svc_print parsing state (analyzes ping reports and status reports)
1142         cl_parsingtextmode_t parsingtextmode;
1143         int parsingtextplayerindex;
1144         // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
1145         // (which could eat the wrong ping report if the player issues one
1146         //  manually, but they would still see a ping report, just a later one
1147         //  caused by the scoreboard code rather than the one they intentionally
1148         //  issued)
1149         int parsingtextexpectingpingforscores;
1150
1151         // entity database stuff
1152         // latest received entity frame numbers
1153 #define LATESTFRAMENUMS 32
1154         int latestframenumsposition;
1155         int latestframenums[LATESTFRAMENUMS];
1156         unsigned int latestsendnums[LATESTFRAMENUMS];
1157         entityframe_database_t *entitydatabase;
1158         entityframe4_database_t *entitydatabase4;
1159         entityframeqw_database_t *entitydatabaseqw;
1160
1161         // keep track of quake entities because they need to be killed if they get stale
1162         int lastquakeentity;
1163         unsigned char isquakeentity[MAX_EDICTS];
1164
1165         // bounding boxes for clientside movement
1166         vec3_t playerstandmins;
1167         vec3_t playerstandmaxs;
1168         vec3_t playercrouchmins;
1169         vec3_t playercrouchmaxs;
1170
1171         // old decals are killed based on this
1172         unsigned int decalsequence;
1173
1174         int max_entities;
1175         int max_csqcrenderentities;
1176         int max_static_entities;
1177         int max_effects;
1178         int max_beams;
1179         int max_dlights;
1180         int max_lightstyle;
1181         int max_brushmodel_entities;
1182         int max_particles;
1183         int max_showlmps;
1184
1185         entity_t *entities;
1186         entity_render_t *csqcrenderentities;
1187         unsigned char *entities_active;
1188         entity_t *static_entities;
1189         cl_effect_t *effects;
1190         beam_t *beams;
1191         dlight_t *dlights;
1192         lightstyle_t *lightstyle;
1193         int *brushmodel_entities;
1194         particle_t *particles;
1195         showlmp_t *showlmps;
1196
1197         int num_entities;
1198         int num_static_entities;
1199         int num_brushmodel_entities;
1200         int num_effects;
1201         int num_beams;
1202         int num_dlights;
1203         int num_particles;
1204         int num_decals;
1205         int num_showlmps;
1206
1207         double particles_updatetime;
1208         double decals_updatetime;
1209         int free_particle;
1210         int free_decal;
1211
1212         // cl_serverextension_download feature
1213         int loadmodel_current;
1214         int downloadmodel_current;
1215         int loadmodel_total;
1216         int loadsound_current;
1217         int downloadsound_current;
1218         int loadsound_total;
1219         qbool downloadcsqc;
1220         qbool loadcsqc;
1221         qbool loadbegun;
1222         qbool loadfinished;
1223
1224         // quakeworld stuff
1225
1226         // local copy of the server infostring
1227         char qw_serverinfo[MAX_SERVERINFO_STRING];
1228
1229         // time of last qw "pings" command sent to server while showing scores
1230         double last_ping_request;
1231
1232         // used during connect
1233         int qw_servercount;
1234
1235         // updated from serverinfo
1236         int qw_teamplay;
1237
1238         // unused: indicates whether the player is spectating
1239         // use cl.scores[cl.playerentity-1].qw_spectator instead
1240         //qbool qw_spectator;
1241
1242         // last time an input packet was sent
1243         double lastpackettime;
1244
1245         // movement parameters for client prediction
1246         unsigned int moveflags;
1247         float movevars_wallfriction;
1248         float movevars_waterfriction;
1249         float movevars_friction;
1250         float movevars_timescale;
1251         float movevars_gravity;
1252         float movevars_stopspeed;
1253         float movevars_maxspeed;
1254         float movevars_spectatormaxspeed;
1255         float movevars_accelerate;
1256         float movevars_airaccelerate;
1257         float movevars_wateraccelerate;
1258         float movevars_entgravity;
1259         float movevars_jumpvelocity;
1260         float movevars_edgefriction;
1261         float movevars_maxairspeed;
1262         float movevars_stepheight;
1263         float movevars_airaccel_qw;
1264         float movevars_airaccel_qw_stretchfactor;
1265         float movevars_airaccel_sideways_friction;
1266         float movevars_airstopaccelerate;
1267         float movevars_airstrafeaccelerate;
1268         float movevars_maxairstrafespeed;
1269         float movevars_airstrafeaccel_qw;
1270         float movevars_aircontrol;
1271         float movevars_aircontrol_power;
1272         float movevars_aircontrol_penalty;
1273         float movevars_warsowbunny_airforwardaccel;
1274         float movevars_warsowbunny_accel;
1275         float movevars_warsowbunny_topspeed;
1276         float movevars_warsowbunny_turnaccel;
1277         float movevars_warsowbunny_backtosideratio;
1278         float movevars_ticrate;
1279         float movevars_airspeedlimit_nonqw;
1280
1281         // models used by qw protocol
1282         int qw_modelindex_spike;
1283         int qw_modelindex_player;
1284         int qw_modelindex_flag;
1285         int qw_modelindex_s_explod;
1286
1287         vec3_t qw_intermission_origin;
1288         vec3_t qw_intermission_angles;
1289
1290         // 255 is the most nails the QW protocol could send
1291         int qw_num_nails;
1292         vec_t qw_nails[255][6];
1293
1294         float qw_weaponkick;
1295
1296         unsigned int qw_validsequence;
1297
1298         unsigned int qw_deltasequence[QW_UPDATE_BACKUP];
1299
1300         // csqc stuff:
1301         // server entity number corresponding to a clientside entity
1302         unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
1303         qbool csqc_loaded;
1304         vec3_t csqc_vieworigin;
1305         vec3_t csqc_viewangles;
1306         vec3_t csqc_vieworiginfromengine;
1307         vec3_t csqc_viewanglesfromengine;
1308         matrix4x4_t csqc_viewmodelmatrixfromengine;
1309         qbool csqc_usecsqclistener;
1310         matrix4x4_t csqc_listenermatrix;
1311         char csqc_printtextbuf[MAX_INPUTLINE];
1312
1313         // collision culling data
1314         world_t world;
1315
1316         // loc file stuff (points and boxes describing locations in the level)
1317         cl_locnode_t *locnodes;
1318         // this is updated to cl.movement_origin whenever health is < 1
1319         // used by %d print in say/say_team messages if cl_locs_enable is on
1320         vec3_t lastdeathorigin;
1321
1322         // processing buffer used by R_BuildLightMap, reallocated as needed,
1323         // freed on each level change
1324         size_t buildlightmapmemorysize;
1325         unsigned char *buildlightmapmemory;
1326
1327         // used by EntityState5_ReadUpdate
1328         skeleton_t *engineskeletonobjects;
1329 }
1330 client_state_t;
1331
1332 //
1333 // cvars
1334 //
1335 extern cvar_t cl_name;
1336 extern cvar_t cl_color;
1337 extern cvar_t cl_rate;
1338 extern cvar_t cl_rate_burstsize;
1339 extern cvar_t cl_pmodel;
1340 extern cvar_t cl_playermodel;
1341 extern cvar_t cl_playerskin;
1342
1343 extern cvar_t rcon_password;
1344 extern cvar_t rcon_address;
1345
1346 extern cvar_t cl_upspeed;
1347 extern cvar_t cl_forwardspeed;
1348 extern cvar_t cl_backspeed;
1349 extern cvar_t cl_sidespeed;
1350
1351 extern cvar_t cl_movespeedkey;
1352
1353 extern cvar_t cl_yawspeed;
1354 extern cvar_t cl_pitchspeed;
1355
1356 extern cvar_t cl_anglespeedkey;
1357
1358 extern cvar_t cl_autofire;
1359
1360 extern cvar_t cl_shownet;
1361 extern cvar_t cl_nolerp;
1362 extern cvar_t cl_nettimesyncfactor;
1363 extern cvar_t cl_nettimesyncboundmode;
1364 extern cvar_t cl_nettimesyncboundtolerance;
1365
1366 extern cvar_t cl_pitchdriftspeed;
1367 extern cvar_t lookspring;
1368 extern cvar_t lookstrafe;
1369 extern cvar_t sensitivity;
1370
1371 extern cvar_t freelook;
1372
1373 extern cvar_t m_pitch;
1374 extern cvar_t m_yaw;
1375 extern cvar_t m_forward;
1376 extern cvar_t m_side;
1377
1378 extern cvar_t cl_autodemo;
1379 extern cvar_t cl_autodemo_nameformat;
1380 extern cvar_t cl_autodemo_delete;
1381
1382 extern cvar_t r_draweffects;
1383
1384 extern cvar_t cl_explosions_alpha_start;
1385 extern cvar_t cl_explosions_alpha_end;
1386 extern cvar_t cl_explosions_size_start;
1387 extern cvar_t cl_explosions_size_end;
1388 extern cvar_t cl_explosions_lifetime;
1389 extern cvar_t cl_stainmaps;
1390 extern cvar_t cl_stainmaps_clearonload;
1391
1392 extern cvar_t cl_prydoncursor;
1393 extern cvar_t cl_prydoncursor_notrace;
1394
1395 extern cvar_t cl_locs_enable;
1396
1397 extern client_state_t cl;
1398
1399 extern void CL_AllocLightFlash (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, char *cubemapname, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
1400
1401 cl_locnode_t *CL_Locs_FindNearest(const vec3_t point);
1402 void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point);
1403
1404 //=============================================================================
1405
1406 //
1407 // cl_main
1408 //
1409
1410 double CL_Frame(double time);
1411
1412 void CL_Shutdown (void);
1413 void CL_Init (void);
1414
1415 void CL_EstablishConnection(const char *host, int firstarg);
1416
1417 void CL_Disconnect (void);
1418 void CL_Disconnect_f(cmd_state_t *cmd);
1419
1420 void CL_UpdateRenderEntity(entity_render_t *ent);
1421 void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
1422 void CL_UpdateViewEntities(void);
1423
1424 //
1425 // cl_input
1426 //
1427 typedef struct kbutton_s
1428 {
1429         int             down[2];                // key nums holding it down
1430         int             state;                  // low bit is down state
1431 }
1432 kbutton_t;
1433
1434 extern  kbutton_t       in_mlook, in_klook;
1435 extern  kbutton_t       in_strafe;
1436 extern  kbutton_t       in_speed;
1437
1438 void CL_InitInput (void);
1439 void CL_SendMove (void);
1440
1441 void CL_ValidateState(entity_state_t *s);
1442 void CL_MoveLerpEntityStates(entity_t *ent);
1443 void CL_LerpUpdate(entity_t *e);
1444 void CL_ParseTEnt (void);
1445 void CL_NewBeam (int ent, vec3_t start, vec3_t end, dp_model_t *m, int lightning);
1446 void CL_RelinkBeams (void);
1447 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1448 void CL_ClientMovement_Replay(void);
1449
1450 void CL_ClearTempEntities (void);
1451 entity_render_t *CL_NewTempEntity (double shadertime);
1452
1453 void CL_Effect(vec3_t org, dp_model_t *model, int startframe, int framecount, float framerate);
1454
1455 void CL_ClearState (void);
1456 void CL_ExpandEntities(int num);
1457 void CL_ExpandCSQCRenderEntities(int num);
1458 void CL_SetInfo(const char *key, const char *value, qbool send, qbool allowstarkey, qbool allowmodel, qbool quiet);
1459
1460
1461 void CL_UpdateWorld (void);
1462 void CL_WriteToServer (void);
1463 void CL_Input (void);
1464 extern int cl_ignoremousemoves;
1465
1466
1467 float CL_KeyState (kbutton_t *key);
1468
1469 //
1470 // cl_cmd.c
1471 //
1472 /// adds the string as a clc_stringcmd to the client message.
1473 /// (used when there is no reason to generate a local command to do it)
1474 void CL_ForwardToServer (const char *s);
1475
1476 /// adds the current command line as a clc_stringcmd to the client message.
1477 /// things like godmode, noclip, etc, are commands directed to the server,
1478 /// so when they are typed in at the console, they will need to be forwarded.
1479 void CL_ForwardToServer_f (cmd_state_t *cmd);
1480 void CL_InitCommands(void);
1481
1482
1483 //
1484 // cl_demo.c
1485 //
1486 void CL_StopPlayback(void);
1487 void CL_ReadDemoMessage(void);
1488 void CL_WriteDemoMessage(sizebuf_t *mesage);
1489
1490 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
1491 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
1492
1493 void CL_NextDemo(void);
1494 void CL_Stop_f(cmd_state_t *cmd);
1495 void CL_Record_f(cmd_state_t *cmd);
1496 void CL_PlayDemo_f(cmd_state_t *cmd);
1497 void CL_TimeDemo_f(cmd_state_t *cmd);
1498
1499 void CL_Demo_Init(void);
1500
1501
1502 #include "cl_screen.h"
1503
1504 extern qbool sb_showscores;
1505
1506 typedef enum waterlevel_e
1507 {
1508         WATERLEVEL_NONE,
1509         WATERLEVEL_WETFEET,
1510         WATERLEVEL_SWIMMING,
1511         WATERLEVEL_SUBMERGED
1512 }
1513 waterlevel_t;
1514
1515 typedef struct cl_clientmovement_state_s
1516 {
1517         // entity to be ignored for movement
1518         struct prvm_edict_s *self;
1519         // position
1520         vec3_t origin;
1521         vec3_t velocity;
1522         // current bounding box (different if crouched vs standing)
1523         vec3_t mins;
1524         vec3_t maxs;
1525         // currently on the ground
1526         qbool onground;
1527         // currently crouching
1528         qbool crouched;
1529         // what kind of water (SUPERCONTENTS_LAVA for instance)
1530         int watertype;
1531         // how deep
1532         waterlevel_t waterlevel;
1533         // weird hacks when jumping out of water
1534         // (this is in seconds and counts down to 0)
1535         float waterjumptime;
1536
1537         // user command
1538         usercmd_t cmd;
1539 }
1540 cl_clientmovement_state_t;
1541 void CL_ClientMovement_PlayerMove_Frame(cl_clientmovement_state_t *s);
1542
1543 // warpzone prediction hack (CSQC builtin)
1544 void CL_RotateMoves(const matrix4x4_t *m);
1545
1546 typedef enum meshname_e {
1547         MESH_SCENE, // CSQC R_PolygonBegin, potentially also engine particles and debug stuff
1548         MESH_UI,
1549         NUM_MESHENTITIES,
1550 } meshname_t;
1551 extern entity_t cl_meshentities[NUM_MESHENTITIES];
1552 extern dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
1553 extern const char *cl_meshentitynames[NUM_MESHENTITIES];
1554 #define CL_Mesh_Scene() (&cl_meshentitymodels[MESH_SCENE])
1555 #define CL_Mesh_UI() (&cl_meshentitymodels[MESH_UI])
1556 void CL_MeshEntities_Scene_Clear(void);
1557 void CL_MeshEntities_Scene_AddRenderEntity(void);
1558 void CL_MeshEntities_Scene_FinalizeRenderEntity(void);
1559 void CL_UpdateEntityShading(void);
1560
1561 void CL_NewFrameReceived(int num);
1562 void CL_ParseEntityLump(char *entitystring);
1563 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
1564 void CL_RelinkLightFlashes(void);
1565 void CL_Beam_AddPolygons(const beam_t *b);
1566 void CL_UpdateMoveVars(void);
1567 void CL_Locs_Reload_f(cmd_state_t *cmd);
1568
1569 #endif
1570