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