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