2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
25 #include "matrixlib.h"
30 #include "cl_particles.h"
33 // flags for rtlight rendering
34 #define LIGHTFLAG_NORMALMODE 1
35 #define LIGHTFLAG_REALTIMEMODE 2
37 typedef struct tridecal_s
39 // color and initial alpha value
40 float texcoord2f[3][2];
43 float plane[4]; // backface culling
44 // how long this decal has lived so far (the actual fade begins at cl_decals_time)
46 // if >= 0 this indicates the decal should follow an animated triangle
48 // for visibility culling
50 // old decals are killed to obey cl_decals_max
51 unsigned int decalsequence;
55 typedef struct decalsystem_s
58 double lastupdatetime;
67 unsigned short *element3s;
71 typedef struct effect_s
80 // these are for interpolation
90 // draw this as lightning polygons, or a model?
92 struct model_s *model;
98 typedef struct rtlight_particle_s
105 typedef struct rtlight_s
107 // note that the world to light matrices are inversely scaled (divided) by lightradius
110 /// matrix for transforming light filter coordinates to world coordinates
111 matrix4x4_t matrix_lighttoworld;
112 /// matrix for transforming world coordinates to light filter coordinates
113 matrix4x4_t matrix_worldtolight;
114 /// typically 1 1 1, can be lower (dim) or higher (overbright)
116 /// size of the light (remove?)
119 char cubemapname[64];
120 /// light style to monitor for brightness
122 /// whether light should render shadows (see castshadows for whether it actually does this frame)
124 /// intensity of corona to render
126 /// radius scale of corona to render (1.0 means same as light radius)
127 vec_t coronasizescale;
128 /// ambient intensity to render
130 /// diffuse intensity to render
132 /// specular intensity to render
134 /// LIGHTFLAG_* flags
137 // generated properties
138 /// used only for casting shadows
143 /// when r_shadow_culllights_trace is set, this is refreshed by each successful trace.
146 // rendering properties, updated each time a light is rendered
147 // this is rtlight->color * d_lightstylevalue
149 /// used by corona updates, due to occlusion query
150 float corona_visibility;
151 unsigned int corona_queryindex_visiblepixels;
152 unsigned int corona_queryindex_allpixels;
153 /// this is R_GetCubemap(rtlight->cubemapname)
154 rtexture_t *currentcubemap;
155 /// set by R_Shadow_PrepareLight to decide whether R_Shadow_DrawLight should draw it
157 /// set by R_Shadow_PrepareLight to indicate whether R_Shadow_DrawShadowMaps should do anything
159 /// these fields are set by R_Shadow_PrepareLight for later drawing
160 int cached_numlightentities;
161 int cached_numlightentities_noselfshadow;
162 int cached_numshadowentities;
163 int cached_numshadowentities_noselfshadow;
164 int cached_numsurfaces;
165 struct entity_render_s **cached_lightentities;
166 struct entity_render_s **cached_lightentities_noselfshadow;
167 struct entity_render_s **cached_shadowentities;
168 struct entity_render_s **cached_shadowentities_noselfshadow;
169 unsigned char *cached_shadowtrispvs;
170 unsigned char *cached_lighttrispvs;
171 int *cached_surfacelist;
172 // reduced light cullbox from GetLightInfo
173 vec3_t cached_cullmins;
174 vec3_t cached_cullmaxs;
175 // current shadow-caster culling planes based on view
176 // (any geometry outside these planes can not contribute to the visible
177 // shadows in any way, and thus can be culled safely)
178 int cached_numfrustumplanes;
179 mplane_t cached_frustumplanes[5]; // see R_Shadow_ComputeShadowCasterCullingPlanes
181 /// static light info
182 /// true if this light should be compiled as a static light
184 /// true if this is a compiled world light, cleared if the light changes
186 /// the size that this light should have (assuming no scene LOD kicking in to reduce it)
187 int shadowmapsidesize;
188 /// position of this light in the shadowmap atlas
189 int shadowmapatlasposition[2];
190 /// 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)
191 int shadowmapatlassidesize;
192 /// optimized and culled mesh to render for world entity shadows
193 shadowmesh_t *static_meshchain_shadow_shadowmap;
194 /// used for visibility testing (more exact than bbox)
196 int static_numleafpvsbytes;
197 int *static_leaflist;
198 unsigned char *static_leafpvs;
199 /// surfaces seen by light
200 int static_numsurfaces;
201 int *static_surfacelist;
202 /// flag bits indicating which triangles of the world model should cast
203 /// shadows, and which ones should be lit
205 /// this avoids redundantly scanning the triangles in each surface twice
206 /// for whether they should cast shadows, once in culling and once in the
207 /// actual shadowmarklist production.
208 int static_numshadowtrispvsbytes;
209 unsigned char *static_shadowtrispvs;
210 /// this allows the lighting batch code to skip backfaces andother culled
211 /// triangles not relevant for lighting
212 /// (important on big surfaces such as terrain)
213 int static_numlighttrispvsbytes;
214 unsigned char *static_lighttrispvs;
215 /// masks of all shadowmap sides that have any potential static receivers or casters
216 int static_shadowmap_receivers;
217 int static_shadowmap_casters;
218 /// particle-tracing cache for global illumination
219 int particlecache_numparticles;
220 int particlecache_maxparticles;
221 int particlecache_updateparticle;
222 rtlight_particle_t *particlecache_particles;
224 /// bouncegrid light info
225 float bouncegrid_photoncolor[3];
226 float bouncegrid_photons;
228 int bouncegrid_traces;
229 float bouncegrid_effectiveradius;
233 typedef struct dlight_s
235 // destroy light after this time
238 // the entity that owns this light (can be NULL)
240 struct entity_render_s *ent;
242 // (worldlight: saved to .rtlights file)
244 // worldlight orientation
246 // (worldlight: saved to .rtlights file)
248 // dlight orientation/scaling/location
252 // (worldlight: saved to .rtlights file)
254 // cubemap name to use on this light
255 // (worldlight: saved to .rtlights file)
256 char cubemapname[64];
257 // make light flash while selected
260 // brightness (not really radius anymore)
261 // (worldlight: saved to .rtlights file)
263 // drop intensity this much each second
266 // intensity value which is dropped over time
269 // initial values for intensity to modify
273 // light style which controls intensity of this light
274 // (worldlight: saved to .rtlights file)
277 // (worldlight: saved to .rtlights file)
280 // (worldlight: saved to .rtlights file)
282 // radius scale of corona to render (1.0 means same as light radius)
283 // (worldlight: saved to .rtlights file)
284 vec_t coronasizescale;
285 // ambient intensity to render
286 // (worldlight: saved to .rtlights file)
288 // diffuse intensity to render
289 // (worldlight: saved to .rtlights file)
291 // specular intensity to render
292 // (worldlight: saved to .rtlights file)
295 // (worldlight: saved to .rtlights file)
297 // linked list of world lights
299 struct dlight_s *next;
300 // embedded rtlight struct for renderer
306 // this is derived from processing of the framegroupblend array
307 // note: technically each framegroupblend can produce two of these, but that
308 // never happens in practice because no one blends between more than 2
309 // framegroups at once
310 #define MAX_FRAMEBLENDS (MAX_FRAMEGROUPBLENDS * 2)
311 typedef struct frameblend_s
318 // LadyHavoc: this struct is intended for the renderer but some fields are
319 // used by the client.
321 // The renderer should not rely on any changes to this struct to be persistent
322 // across multiple frames because temp entities are wiped every frame, but it
323 // is acceptable to cache things in this struct that are not critical.
325 // For example the r_cullentities_trace code does such caching.
326 typedef struct entity_render_s
332 // transform matrix for model to world
334 // transform matrix for world to model
335 matrix4x4_t inversematrix;
336 // opacity (alpha) of the model
338 // size the model is shown
340 // transparent sorting offset
341 float transparent_offset;
345 // number of the entity represents, or 0 for non-network entities
347 // literal colormap colors for renderer, if both are 0 0 0 it is not colormapped
348 vec3_t colormap_pantscolor;
349 vec3_t colormap_shirtcolor;
350 // light, particles, etc
352 // qw CTF flags and other internal-use-only effect bits
359 // colormod tinting of models
363 // interpolated animation - active framegroups and blend factors
364 framegroupblend_t framegroupblend[MAX_FRAMEGROUPBLENDS];
366 // time of last model change (for shader animations)
369 // calculated by the renderer (but not persistent)
371 // calculated during R_AddModelEntities
373 // subframe numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use subframeblend[0].subframe
374 frameblend_t frameblend[MAX_FRAMEBLENDS];
375 // skeletal animation data (if skeleton.relativetransforms is not NULL, it overrides frameblend)
376 skeleton_t *skeleton;
378 // animation cache (pointers allocated using R_FrameData_Alloc)
379 // ONLY valid during R_RenderView! may be NULL (not cached)
380 float *animcache_vertex3f;
381 r_meshbuffer_t *animcache_vertex3f_vertexbuffer;
382 int animcache_vertex3f_bufferoffset;
383 float *animcache_normal3f;
384 r_meshbuffer_t *animcache_normal3f_vertexbuffer;
385 int animcache_normal3f_bufferoffset;
386 float *animcache_svector3f;
387 r_meshbuffer_t *animcache_svector3f_vertexbuffer;
388 int animcache_svector3f_bufferoffset;
389 float *animcache_tvector3f;
390 r_meshbuffer_t *animcache_tvector3f_vertexbuffer;
391 int animcache_tvector3f_bufferoffset;
392 // gpu-skinning shader needs transforms in a certain format, we have to
393 // upload this to a uniform buffer for the shader to use, and also keep a
394 // backup copy in system memory for the dynamic batch fallback code
395 // if this is not NULL, the other animcache variables are NULL
396 float *animcache_skeletaltransform3x4;
397 r_meshbuffer_t *animcache_skeletaltransform3x4buffer;
398 int animcache_skeletaltransform3x4offset;
399 int animcache_skeletaltransform3x4size;
401 // CL_UpdateEntityShading reads these fields
402 // used only if RENDER_CUSTOMIZEDMODELLIGHT is set
403 vec3_t custommodellight_ambient;
404 vec3_t custommodellight_diffuse;
405 vec3_t custommodellight_lightdir;
406 // CSQC entities get their shading from the root of their attachment chain
407 float custommodellight_origin[3];
409 // derived lighting parameters (CL_UpdateEntityShading)
411 // used by MATERIALFLAG_FULLBRIGHT which is MATERIALFLAG_MODELLIGHT with
412 // this as ambient color, along with MATERIALFLAG_NORTLIGHT
413 float render_fullbright[3];
414 // color tint for the base pass glow textures if any
415 float render_glowmod[3];
416 // MATERIALFLAG_MODELLIGHT uses these parameters
417 float render_modellight_ambient[3];
418 float render_modellight_diffuse[3];
419 float render_modellight_lightdir_world[3];
420 float render_modellight_lightdir_local[3];
421 float render_modellight_specular[3];
422 // lightmap rendering (not MATERIALFLAG_MODELLIGHT)
423 float render_lightmap_ambient[3];
424 float render_lightmap_diffuse[3];
425 float render_lightmap_specular[3];
426 // rtlights use these colors for the materials on this entity
427 float render_rtlight_diffuse[3];
428 float render_rtlight_specular[3];
429 // ignore lightmap and use fixed lighting settings on this entity (e.g. FULLBRIGHT)
430 qbool render_modellight_forced;
431 // do not process per pixel lights on this entity at all (like MATERIALFLAG_NORTLIGHT)
432 qbool render_rtlight_disabled;
433 // use the 3D lightmap from q3bsp on this entity
434 qbool render_lightgrid;
436 // storage of decals on this entity
437 // (note: if allowdecals is set, be sure to call R_DecalSystem_Reset on removal!)
439 decalsystem_t decalsystem;
441 // FIELDS UPDATED BY RENDERER:
442 // last time visible during trace culling
443 double last_trace_visibility;
445 // user wavefunc parameters (from csqc)
446 vec_t userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
450 typedef struct entity_persistent_s
452 vec3_t trail_origin; // previous position for particle trail spawning
453 vec3_t oldorigin; // lerp
454 vec3_t oldangles; // lerp
455 vec3_t neworigin; // lerp
456 vec3_t newangles; // lerp
457 vec_t lerpstarttime; // lerp
458 vec_t lerpdeltatime; // lerp
459 float muzzleflash; // muzzleflash intensity, fades over time
460 float trail_time; // residual error accumulation for particle trail spawning (to keep spacing across frames)
461 qbool trail_allowed; // set to false by teleports, true by update code, prevents bad lerps
465 typedef struct entity_s
467 // baseline state (default values)
468 entity_state_t state_baseline;
469 // previous state (interpolating from this)
470 entity_state_t state_previous;
471 // current state (interpolating to this)
472 entity_state_t state_current;
474 // used for regenerating parts of render
475 entity_persistent_t persistent;
477 // the only data the renderer should know about
478 entity_render_t render;
482 typedef struct lightstyle_s
485 char map[MAX_STYLESTRING];
488 typedef struct scoreboard_s
490 char name[MAX_SCOREBOARDNAME];
492 int colors; // two 4 bit fields
495 char qw_userinfo[MAX_USERINFO_STRING];
502 char qw_skin[MAX_QPATH];
505 typedef struct cshift_s
508 float percent; // 0-255
509 float alphafade; // (any speed)
512 #define CSHIFT_CONTENTS 0
513 #define CSHIFT_DAMAGE 1
514 #define CSHIFT_BONUS 2
515 #define CSHIFT_POWERUP 3
516 #define CSHIFT_VCSHIFT 4
517 #define NUM_CSHIFTS 5
519 #define NAME_LENGTH 64
523 // client_state_t should hold all pieces of the client state
526 #define SIGNONS 4 // signon messages to receive before connected
528 typedef enum cactive_e
530 ca_uninitialized, // during early startup
531 ca_dedicated, // a dedicated server with no ability to start a client
532 ca_disconnected, // full screen console with no connection
533 ca_connected // valid netcon, talking to a server
537 typedef enum qw_downloadtype_e
547 #define CL_MAX_DOWNLOADACKS 4
549 typedef struct cl_downloadack_s
555 typedef struct cl_soundstats_s
559 int latency_milliseconds;
564 // the client_static_t structure is persistent through an arbitrary number
565 // of server connections
567 typedef struct client_static_s
571 // all client memory allocations go in these pools
572 mempool_t *levelmempool;
573 mempool_t *permanentmempool;
576 // -1 = don't play demos
578 // list of demos in loop
579 char demos[MAX_DEMOS][MAX_DEMONAME];
580 // the actively playing demo (set by CL_PlayDemo)
581 char demoname[MAX_QPATH];
583 // demo recording info must be here, because record is started before
584 // entering a map (and clearing client_state_t)
586 fs_offset_t demo_lastcsprogssize;
587 int demo_lastcsprogscrc;
589 qbool demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo
591 // -1 = use normal cd track
594 // realtime at second frame of timedemo (LadyHavoc: changed to double)
596 int td_frames; // total frames parsed
597 double td_onesecondnexttime;
598 double td_onesecondframes;
599 double td_onesecondrealtime;
600 double td_onesecondminfps;
601 double td_onesecondmaxfps;
602 double td_onesecondavgfps;
603 int td_onesecondavgcount;
604 // LadyHavoc: pausedemo
607 // sound mixer statistics for showsound display
608 cl_soundstats_t soundstats;
610 qbool connect_trying;
611 int connect_remainingtries;
612 double connect_nextsendtime;
613 lhnetsocket_t *connect_mysocket;
614 lhnetaddress_t connect_address;
615 lhnetaddress_t rcon_address;
616 // protocol version of the server we're connected to
617 // (kept outside client_state_t because it's used between levels)
618 protocolversion_t protocol;
622 lhnetaddress_t rcon_addresses[MAX_RCONS];
623 char rcon_commands[MAX_RCONS][MAX_INPUTLINE];
624 double rcon_timeout[MAX_RCONS];
627 // connection information
630 // network connection
633 // download information
634 // (note: qw_download variables are also used)
635 cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
637 // input sequence numbers are not reset on level change, only connect
638 unsigned int servermovesequence;
640 // quakeworld stuff below
642 // value of "qport" cvar at time of connection
644 // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
645 unsigned int qw_incoming_sequence;
646 unsigned int qw_outgoing_sequence;
648 // current file download buffer (only saved when file is completed)
649 char qw_downloadname[MAX_QPATH];
650 unsigned char *qw_downloadmemory;
651 int qw_downloadmemorycursize;
652 int qw_downloadmemorymaxsize;
653 int qw_downloadnumber;
654 int qw_downloadpercent;
655 qw_downloadtype_t qw_downloadtype;
656 // transfer rate display
657 double qw_downloadspeedtime;
658 int qw_downloadspeedcount;
659 int qw_downloadspeedrate;
660 qbool qw_download_deflate;
662 // current file upload buffer (for uploading screenshots to server)
663 unsigned char *qw_uploaddata;
668 // this normally contains the following keys in quakeworld:
669 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
670 char userinfo[MAX_USERINFO_STRING];
672 // extra user info for the "connect" command
673 char connect_userinfo[MAX_USERINFO_STRING];
675 #ifdef CONFIG_VIDEO_CAPTURE
676 // video capture stuff
677 capturevideostate_t capturevideo;
683 // ProQuake compatibility stuff
684 int proquake_servermod; // 0 = not proquake, 1 = proquake
685 int proquake_serverversion; // actual proquake server version * 10 (3.40 = 34, etc)
686 int proquake_serverflags; // 0 (PQF_CHEATFREE not supported)
688 // don't write-then-read csprogs.dat (useful for demo playback)
689 unsigned char *caughtcsprogsdata;
690 fs_offset_t caughtcsprogsdatasize;
692 int r_speeds_graph_length;
693 int r_speeds_graph_current;
694 int *r_speeds_graph_data;
697 int r_speeds_graph_datamin[r_stat_count];
698 int r_speeds_graph_datamax[r_stat_count];
702 extern client_static_t cls;
708 qbool drawenginesbar;
712 typedef enum cl_parsingtextmode_e
714 CL_PARSETEXTMODE_NONE,
715 CL_PARSETEXTMODE_PING,
716 CL_PARSETEXTMODE_STATUS,
717 CL_PARSETEXTMODE_STATUS_PLAYERID,
718 CL_PARSETEXTMODE_STATUS_PLAYERIP
720 cl_parsingtextmode_t;
722 typedef struct cl_locnode_s
724 struct cl_locnode_s *next;
730 typedef struct showlmp_s
741 // the client_state_t structure is wiped completely at every
744 typedef struct client_state_s
746 // true if playing in a local game and no one else is connected
749 // send a clc_nop periodically until connected
752 // current input being accumulated by mouse/joystick/etc input
754 // latest moves sent to the server that have not been confirmed yet
755 usercmd_t movecmd[CL_MAX_USERCMDS];
757 // information for local display
759 int stats[MAX_CL_STATS];
760 float *statsf; // points to stats[] array
761 // last known inventory bit flags, for blinking
763 // cl.time of acquiring item, for blinking
764 float item_gettime[32];
765 // last known STAT_ACTIVEWEAPON
767 // cl.time of changing STAT_ACTIVEWEAPON
769 // use pain anim frame if cl.time < this
771 // for stair smoothing
773 double stairsmoothtime;
775 // color shifts for damage, powerups
776 cshift_t cshifts[NUM_CSHIFTS];
778 cshift_t prev_cshifts[NUM_CSHIFTS];
780 // the client maintains its own idea of view angles, which are
781 // sent to the server each frame. The server sets punchangle when
782 // the view is temporarily offset, and an angle reset commands at the start
783 // of each level and after teleporting.
785 // mviewangles is read from demo
786 // viewangles is either client controlled or lerped from mviewangles
787 vec3_t mviewangles[2], viewangles;
788 // update by server, used by qc to do weapon recoil
789 vec3_t mpunchangle[2], punchangle;
790 // update by server, can be used by mods to kick view around
791 vec3_t mpunchvector[2], punchvector;
792 // update by server, used for lean+bob (0 is newest)
793 vec3_t mvelocity[2], velocity;
794 // update by server, can be used by mods for zooming
795 vec_t mviewzoom[2], viewzoom;
796 // if true interpolation the mviewangles and other interpolation of the
797 // player is disabled until the next network packet
798 // this is used primarily by teleporters, and when spectating players
799 // special checking of the old fixangle[1] is used to differentiate
800 // between teleporting and spectating
803 // client movement simulation
804 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
805 // set by CL_ClientMovement_Replay functions
806 qbool movement_predicted;
807 // if true the CL_ClientMovement_Replay function will update origin, etc
808 qbool movement_replay;
809 // simulated data (this is valid even if cl.movement is false)
810 vec3_t movement_origin;
811 vec3_t movement_velocity;
812 // whether the replay should allow a jump at the first sequence
813 qbool movement_replay_canjump;
815 // previous gun angles (for leaning effects)
816 vec3_t gunangles_prev;
817 vec3_t gunangles_highpass;
818 vec3_t gunangles_adjustment_lowpass;
819 vec3_t gunangles_adjustment_highpass;
820 // previous gun angles (for leaning effects)
822 vec3_t gunorg_highpass;
823 vec3_t gunorg_adjustment_lowpass;
824 vec3_t gunorg_adjustment_highpass;
826 // pitch drifting vars
833 //[515]: added for csqc purposes
834 float sensitivityscale;
835 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
836 qbool csqc_wantsmousemove;
837 struct model_s *csqc_model_precache[MAX_MODELS];
839 // local amount for smoothing stepups
849 double lastongroundtime;
850 double hitgroundtime;
854 double calcrefdef_prevtime;
856 // don't change view angle, full screen, etc
858 // latched at intermission start
859 double completed_time;
861 // the timestamp of the last two messages
864 // clients view of time, time should be between mtime[0] and mtime[1] to
865 // generate a lerp point for other data, oldtime is the previous frame's
866 // value of time, frametime is the difference between time and oldtime
867 // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
868 // is only forcefully limited when a packet is received
869 double time, oldtime;
870 // how long it has been since the previous client frame in real time
871 // (not game time, for that use cl.time - cl.oldtime)
872 double realframetime;
874 // used by cl_nettimesyncboundmode 7
875 #define NUM_TS_ERRORS 32 // max 256
876 unsigned char ts_error_num;
877 float ts_error_stor[NUM_TS_ERRORS];
879 // fade var for fading while dead
882 // motionblur alpha level variable
883 float motionbluralpha;
885 // copy of realtime from last recieved message, for net trouble icon
886 float last_received_message;
888 // information that is static for the entire time connected to a server
889 struct model_s *model_precache[MAX_MODELS];
890 struct sfx_s *sound_precache[MAX_SOUNDS];
892 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
893 char model_name[MAX_MODELS][MAX_QPATH];
894 char sound_name[MAX_SOUNDS][MAX_QPATH];
896 // for display on solo scoreboard
897 char worldmessage[MAX_QPATH]; // map title (not related to filename)
898 // variants of map name
899 char worldbasename[MAX_QPATH]; // %s
900 char worldname[MAX_QPATH]; // maps/%s.bsp
901 char worldnamenoextension[MAX_QPATH]; // maps/%s
902 // cl_entitites[cl.viewentity] = player
904 // the real player entity (normally same as viewentity,
905 // different than viewentity if mod uses chasecam or other tricks)
906 int realplayerentity;
907 // this is updated to match cl.viewentity whenever it is in the clients
908 // range, basically this is used in preference to cl.realplayerentity for
909 // most purposes because when spectating another player it should show
910 // their information rather than yours
912 // max players that can be in this game
914 // type of game (deathmatch, coop, singleplayer)
917 // models and sounds used by engine code (particularly cl_parse.c)
919 model_t *model_bolt2;
920 model_t *model_bolt3;
923 sfx_t *sfx_knighthit;
929 // indicates that the file "sound/misc/talk2.wav" was found (for use by team chat messages)
930 qbool foundteamchatsound;
932 // refresh related state
934 // cl_entitites[0].model
935 struct model_s *worldmodel;
941 int cdtrack, looptrack;
946 scoreboard_t *scores;
948 // keep track of svc_print parsing state (analyzes ping reports and status reports)
949 cl_parsingtextmode_t parsingtextmode;
950 int parsingtextplayerindex;
951 // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
952 // (which could eat the wrong ping report if the player issues one
953 // manually, but they would still see a ping report, just a later one
954 // caused by the scoreboard code rather than the one they intentionally
956 int parsingtextexpectingpingforscores;
958 // entity database stuff
959 // latest received entity frame numbers
960 #define LATESTFRAMENUMS 32
961 int latestframenumsposition;
962 int latestframenums[LATESTFRAMENUMS];
963 unsigned int latestsendnums[LATESTFRAMENUMS];
964 entityframe_database_t *entitydatabase;
965 entityframe4_database_t *entitydatabase4;
966 entityframeqw_database_t *entitydatabaseqw;
968 // keep track of quake entities because they need to be killed if they get stale
970 unsigned char isquakeentity[MAX_EDICTS];
972 // bounding boxes for clientside movement
973 vec3_t playerstandmins;
974 vec3_t playerstandmaxs;
975 vec3_t playercrouchmins;
976 vec3_t playercrouchmaxs;
978 // old decals are killed based on this
979 unsigned int decalsequence;
982 int max_csqcrenderentities;
983 int max_static_entities;
988 int max_brushmodel_entities;
993 entity_render_t *csqcrenderentities;
994 unsigned char *entities_active;
995 entity_t *static_entities;
996 cl_effect_t *effects;
999 lightstyle_t *lightstyle;
1000 int *brushmodel_entities;
1001 particle_t *particles;
1002 showlmp_t *showlmps;
1005 int num_static_entities;
1006 int num_brushmodel_entities;
1014 double particles_updatetime;
1015 double decals_updatetime;
1019 // cl_serverextension_download feature
1020 int loadmodel_current;
1021 int downloadmodel_current;
1022 int loadmodel_total;
1023 int loadsound_current;
1024 int downloadsound_current;
1025 int loadsound_total;
1033 // local copy of the server infostring
1034 char qw_serverinfo[MAX_SERVERINFO_STRING];
1036 // time of last qw "pings" command sent to server while showing scores
1037 double last_ping_request;
1039 // used during connect
1042 // updated from serverinfo
1045 // unused: indicates whether the player is spectating
1046 // use cl.scores[cl.playerentity-1].qw_spectator instead
1047 //qbool qw_spectator;
1049 // time accumulated since an input packet was sent
1050 float timesincepacket;
1051 // how many optimally timed inputs we sent since we received an update from the server
1052 uint8_t opt_inputs_since_update;
1054 // movement parameters for client prediction
1055 unsigned int moveflags;
1056 float movevars_wallfriction;
1057 float movevars_waterfriction;
1058 float movevars_friction;
1059 float movevars_timescale;
1060 float movevars_gravity;
1061 float movevars_stopspeed;
1062 float movevars_maxspeed;
1063 float movevars_spectatormaxspeed;
1064 float movevars_accelerate;
1065 float movevars_airaccelerate;
1066 float movevars_wateraccelerate;
1067 float movevars_entgravity;
1068 float movevars_jumpvelocity;
1069 float movevars_edgefriction;
1070 float movevars_maxairspeed;
1071 float movevars_stepheight;
1072 float movevars_airaccel_qw;
1073 float movevars_airaccel_qw_stretchfactor;
1074 float movevars_airaccel_sideways_friction;
1075 float movevars_airstopaccelerate;
1076 float movevars_airstrafeaccelerate;
1077 float movevars_maxairstrafespeed;
1078 float movevars_airstrafeaccel_qw;
1079 float movevars_aircontrol;
1080 float movevars_aircontrol_power;
1081 float movevars_aircontrol_penalty;
1082 float movevars_warsowbunny_airforwardaccel;
1083 float movevars_warsowbunny_accel;
1084 float movevars_warsowbunny_topspeed;
1085 float movevars_warsowbunny_turnaccel;
1086 float movevars_warsowbunny_backtosideratio;
1087 float movevars_ticrate;
1088 float movevars_airspeedlimit_nonqw;
1090 // models used by qw protocol
1091 int qw_modelindex_spike;
1092 int qw_modelindex_player;
1093 int qw_modelindex_flag;
1094 int qw_modelindex_s_explod;
1096 vec3_t qw_intermission_origin;
1097 vec3_t qw_intermission_angles;
1099 // 255 is the most nails the QW protocol could send
1101 vec_t qw_nails[255][6];
1103 float qw_weaponkick;
1105 unsigned int qw_validsequence;
1107 unsigned int qw_deltasequence[QW_UPDATE_BACKUP];
1110 // server entity number corresponding to a clientside entity
1111 unsigned short csqc_server2csqcentitynumber[MAX_EDICTS];
1113 vec3_t csqc_vieworigin;
1114 vec3_t csqc_viewangles;
1115 vec3_t csqc_vieworiginfromengine;
1116 vec3_t csqc_viewanglesfromengine;
1117 matrix4x4_t csqc_viewmodelmatrixfromengine;
1118 qbool csqc_usecsqclistener;
1119 matrix4x4_t csqc_listenermatrix;
1120 char csqc_printtextbuf[MAX_INPUTLINE];
1122 // collision culling data
1125 // loc file stuff (points and boxes describing locations in the level)
1126 cl_locnode_t *locnodes;
1127 // this is updated to cl.movement_origin whenever health is < 1
1128 // used by %d print in say/say_team messages if cl_locs_enable is on
1129 vec3_t lastdeathorigin;
1131 // processing buffer used by R_BuildLightMap, reallocated as needed,
1132 // freed on each level change
1133 size_t buildlightmapmemorysize;
1134 unsigned char *buildlightmapmemory;
1136 // used by EntityState5_ReadUpdate
1137 skeleton_t *engineskeletonobjects;
1144 extern cvar_t cl_name;
1145 extern cvar_t cl_color;
1146 extern cvar_t cl_rate;
1147 extern cvar_t cl_rate_burstsize;
1148 extern cvar_t cl_pmodel;
1149 extern cvar_t cl_playermodel;
1150 extern cvar_t cl_playerskin;
1152 extern cvar_t rcon_password;
1153 extern cvar_t rcon_address;
1155 extern cvar_t cl_upspeed;
1156 extern cvar_t cl_forwardspeed;
1157 extern cvar_t cl_backspeed;
1158 extern cvar_t cl_sidespeed;
1160 extern cvar_t cl_movespeedkey;
1162 extern cvar_t cl_yawspeed;
1163 extern cvar_t cl_pitchspeed;
1165 extern cvar_t cl_anglespeedkey;
1167 extern cvar_t cl_autofire;
1169 extern cvar_t cl_shownet;
1170 extern cvar_t cl_nettimesyncfactor;
1171 extern cvar_t cl_nettimesyncboundmode;
1172 extern cvar_t cl_nettimesyncboundtolerance;
1174 extern cvar_t cl_pitchdriftspeed;
1175 extern cvar_t lookspring;
1176 extern cvar_t lookstrafe;
1177 extern cvar_t sensitivity;
1179 extern cvar_t freelook;
1181 extern cvar_t m_pitch;
1182 extern cvar_t m_yaw;
1183 extern cvar_t m_forward;
1184 extern cvar_t m_side;
1186 extern cvar_t cl_autodemo;
1187 extern cvar_t cl_autodemo_nameformat;
1188 extern cvar_t cl_autodemo_delete;
1190 extern cvar_t r_draweffects;
1192 extern cvar_t cl_explosions_alpha_start;
1193 extern cvar_t cl_explosions_alpha_end;
1194 extern cvar_t cl_explosions_size_start;
1195 extern cvar_t cl_explosions_size_end;
1196 extern cvar_t cl_explosions_lifetime;
1197 extern cvar_t cl_stainmaps;
1198 extern cvar_t cl_stainmaps_clearonload;
1200 extern cvar_t cl_prydoncursor;
1201 extern cvar_t cl_prydoncursor_notrace;
1203 extern cvar_t cl_locs_enable;
1205 extern cvar_t cl_areagrid_link_SOLID_NOT;
1207 extern client_state_t cl;
1209 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);
1211 cl_locnode_t *CL_Locs_FindNearest(const vec3_t point);
1212 void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point);
1214 //=============================================================================
1220 double CL_Frame(double time);
1222 void CL_Shutdown (void);
1223 void CL_Init (void);
1225 void CL_StartVideo(void);
1227 void CL_EstablishConnection(const char *host, int firstarg);
1229 void CL_Disconnect(void);
1230 void CL_DisconnectEx(qbool kicked, const char *reason, ... );
1231 void CL_Disconnect_f(cmd_state_t *cmd);
1233 void CL_UpdateRenderEntity(entity_render_t *ent);
1234 void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
1235 void CL_UpdateViewEntities(void);
1240 typedef struct kbutton_s
1242 int down[2]; // key nums holding it down
1243 int state; // low bit is down state
1247 extern kbutton_t in_mlook, in_klook;
1248 extern kbutton_t in_strafe;
1249 extern kbutton_t in_speed;
1251 void CL_InitInput (void);
1252 void CL_SendMove (void);
1254 void CL_ValidateState(entity_state_t *s);
1255 void CL_MoveLerpEntityStates(entity_t *ent);
1256 void CL_LerpUpdate(entity_t *e);
1257 void CL_ParseTEnt (void);
1258 void CL_NewBeam (int ent, vec3_t start, vec3_t end, model_t *m, int lightning);
1259 void CL_RelinkBeams (void);
1260 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1261 void CL_ClientMovement_Replay(void);
1263 void CL_ClearTempEntities (void);
1264 entity_render_t *CL_NewTempEntity (double shadertime);
1266 void CL_Effect(vec3_t org, model_t *model, int startframe, int framecount, float framerate);
1268 void CL_ClearState (void);
1269 void CL_ExpandEntities(int num);
1270 void CL_ExpandCSQCRenderEntities(int num);
1271 void CL_SetInfo(const char *key, const char *value, qbool send, qbool allowstarkey, qbool allowmodel, qbool quiet);
1274 void CL_UpdateWorld (void);
1275 void CL_WriteToServer (void);
1276 void CL_Input (void);
1277 extern int cl_ignoremousemoves;
1280 float CL_KeyState (kbutton_t *key);
1285 /// adds the string as a clc_stringcmd to the client message.
1286 /// (used when there is no reason to generate a local command to do it)
1287 void CL_ForwardToServer (const char *s);
1289 /// adds the current command line as a clc_stringcmd to the client message.
1290 /// things like godmode, noclip, etc, are commands directed to the server,
1291 /// so when they are typed in at the console, they will need to be forwarded.
1292 void CL_ForwardToServer_f (cmd_state_t *cmd);
1293 void CL_InitCommands(void);
1299 void CL_StopPlayback(void);
1300 void CL_ReadDemoMessage(void);
1301 void CL_WriteDemoMessage(sizebuf_t *mesage);
1303 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
1304 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
1306 void CL_PlayDemo(const char *demo);
1307 void CL_NextDemo(void);
1308 void CL_Stop_f(cmd_state_t *cmd);
1309 void CL_Record_f(cmd_state_t *cmd);
1310 void CL_PlayDemo_f(cmd_state_t *cmd);
1311 void CL_TimeDemo_f(cmd_state_t *cmd);
1313 void CL_Demo_Init(void);
1316 #include "cl_screen.h"
1318 extern qbool sb_showscores;
1320 typedef enum waterlevel_e
1324 WATERLEVEL_SWIMMING,
1325 WATERLEVEL_SUBMERGED
1329 typedef struct cl_clientmovement_state_s
1331 // entity to be ignored for movement
1332 struct prvm_edict_s *self;
1336 // current bounding box (different if crouched vs standing)
1339 // currently on the ground
1341 // currently crouching
1343 // what kind of water (SUPERCONTENTS_LAVA for instance)
1346 waterlevel_t waterlevel;
1347 // weird hacks when jumping out of water
1348 // (this is in seconds and counts down to 0)
1349 float waterjumptime;
1354 cl_clientmovement_state_t;
1355 void CL_ClientMovement_PlayerMove_Frame(cl_clientmovement_state_t *s);
1357 // warpzone prediction hack (CSQC builtin)
1358 void CL_RotateMoves(const matrix4x4_t *m);
1360 typedef enum meshname_e {
1361 MESH_SCENE, // CSQC R_PolygonBegin, potentially also engine particles and debug stuff
1365 extern entity_t cl_meshentities[NUM_MESHENTITIES];
1366 extern model_t cl_meshentitymodels[NUM_MESHENTITIES];
1367 extern const char *cl_meshentitynames[NUM_MESHENTITIES];
1368 #define CL_Mesh_Scene() (&cl_meshentitymodels[MESH_SCENE])
1369 #define CL_Mesh_UI() (&cl_meshentitymodels[MESH_UI])
1370 void CL_MeshEntities_Init(void);
1371 void CL_MeshEntities_Scene_Clear(void);
1372 void CL_MeshEntities_Scene_AddRenderEntity(void);
1373 void CL_MeshEntities_Scene_FinalizeRenderEntity(void);
1374 void CL_UpdateEntityShading(void);
1376 void CL_NewFrameReceived(int num);
1377 void CL_ParseEntityLump(char *entitystring);
1378 void CL_FindNonSolidLocation(const vec3_t in, vec3_t out, vec_t radius);
1379 void CL_RelinkLightFlashes(void);
1380 void CL_Beam_AddPolygons(const beam_t *b);
1381 void CL_UpdateMoveVars(void);
1382 void CL_Locs_Reload_f(cmd_state_t *cmd);