]> icculus.org git repositories - divverent/darkplaces.git/blob - client.h
ignore various MSVC files (.opt, .plg, .ncb) and .exe
[divverent/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 typedef struct frameblend_s
23 {
24         int frame;
25         float lerp;
26 }
27 frameblend_t;
28
29 // LordHavoc: nothing in this structure is persistant, it may be overwritten by the client every frame, for persistant data use entity_lerp_t.
30 typedef struct entity_render_s
31 {
32         // location
33         vec3_t origin;
34         // orientation
35         vec3_t angles;
36         // opacity (alpha) of the model
37         float alpha;
38         // size the model is shown
39         float scale;
40
41         // NULL = no model
42         model_t *model;
43         // current uninterpolated animation frame (for things which do not use interpolation)
44         int frame;
45         // entity shirt and pants colors
46         int colormap;
47         // light, particles, etc
48         int effects;
49         // for Alias models
50         int skinnum;
51         // render flags
52         int flags;
53
54         // these are copied from the persistent data
55
56         // frame that the model is interpolating from
57         int frame1;
58         // frame that the model is interpolating to
59         int frame2;
60         // interpolation factor, usually computed from frame2time
61         double framelerp;
62         // time frame1 began playing (for framegroup animations)
63         double frame1time;
64         // time frame2 began playing (for framegroup animations)
65         double frame2time;
66
67         // calculated by the renderer (but not persistent)
68
69         // if visframe == r_framecount, it is visible
70         int visframe;
71         // calculated during R_AddModelEntities
72         vec3_t mins, maxs;
73         // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
74         frameblend_t frameblend[4];
75 }
76 entity_render_t;
77
78 typedef struct entity_persistent_s
79 {
80         // particles
81
82         // trail rendering
83         vec3_t trail_origin;
84         float trail_time;
85
86         // effects
87
88         // muzzleflash fading
89         float muzzleflash;
90
91         // interpolated animation
92
93         // lerp resets when model changes
94         int modelindex;
95         // frame that the model is interpolating from
96         int frame1;
97         // frame that the model is interpolating to
98         int frame2;
99         // interpolation factor, usually computed from frame2time
100         double framelerp;
101         // time frame1 began playing (for framegroup animations)
102         double frame1time;
103         // time frame2 began playing (for framegroup animations)
104         double frame2time;
105 }
106 entity_persistent_t;
107
108 typedef struct entity_s
109 {
110         // baseline state (default values)
111         entity_state_t state_baseline;
112         // previous state (interpolating from this)
113         entity_state_t state_previous;
114         // current state (interpolating to this)
115         entity_state_t state_current;
116
117         // used for regenerating parts of render
118         entity_persistent_t persistent;
119
120         // the only data the renderer should know about
121         entity_render_t render;
122 }
123 entity_t;
124
125 typedef struct
126 {
127         vec3_t  viewangles;
128
129 // intended velocities
130         float   forwardmove;
131         float   sidemove;
132         float   upmove;
133 } usercmd_t;
134
135 typedef struct
136 {
137         int             length;
138         char    map[MAX_STYLESTRING];
139 } lightstyle_t;
140
141 typedef struct
142 {
143         char    name[MAX_SCOREBOARDNAME];
144         float   entertime;
145         int             frags;
146         int             colors; // two 4 bit fields
147 } scoreboard_t;
148
149 typedef struct
150 {
151         int             destcolor[3];
152         int             percent;                // 0-256
153 } cshift_t;
154
155 #define CSHIFT_CONTENTS 0
156 #define CSHIFT_DAMAGE   1
157 #define CSHIFT_BONUS    2
158 #define CSHIFT_POWERUP  3
159 #define NUM_CSHIFTS             4
160
161 #define NAME_LENGTH     64
162
163
164 //
165 // client_state_t should hold all pieces of the client state
166 //
167
168 #define SIGNONS         4                       // signon messages to receive before connected
169
170 #define MAX_BEAMS       24
171 typedef struct
172 {
173         int             entity;
174         struct model_s  *model;
175         float   endtime;
176         vec3_t  start, end;
177 }
178 beam_t;
179
180 #define MAX_MAPSTRING   2048
181 #define MAX_DEMOS               8
182 #define MAX_DEMONAME    16
183
184 typedef enum
185 {
186         ca_dedicated,           // a dedicated server with no ability to start a client
187         ca_disconnected,        // full screen console with no connection
188         ca_connected            // valid netcon, talking to a server
189 }
190 cactive_t;
191
192 //
193 // the client_static_t structure is persistant through an arbitrary number
194 // of server connections
195 //
196 typedef struct
197 {
198         cactive_t       state;
199
200 // personalization data sent to server
201         char            mapstring[MAX_QPATH];
202         char            spawnparms[MAX_MAPSTRING];      // to restart a level
203
204 // demo loop control
205         int                     demonum;                // -1 = don't play demos
206         char            demos[MAX_DEMOS][MAX_DEMONAME];         // when not playing
207
208 // demo recording info must be here, because record is started before
209 // entering a map (and clearing client_state_t)
210         qboolean        demorecording;
211         qboolean        demoplayback;
212         qboolean        timedemo;
213         int                     forcetrack;                     // -1 = use normal cd track
214         QFile           *demofile;
215         int                     td_lastframe;           // to meter out one message a frame
216         int                     td_startframe;          // host_framecount at start
217         double          td_starttime;           // realtime at second frame of timedemo (LordHavoc: changed to double)
218         qboolean        demopaused;                     // LordHavoc: pausedemo
219
220
221 // connection information
222         int                     signon;                 // 0 to SIGNONS
223         struct qsocket_s        *netcon;
224         sizebuf_t       message;                // writing buffer to send to server
225 }
226 client_static_t;
227
228 extern client_static_t  cls;
229
230 //
231 // the client_state_t structure is wiped completely at every
232 // server signon
233 //
234 typedef struct
235 {
236         int                     movemessages;   // since connecting to this server
237                                                                 // throw out the first couple, so the player
238                                                                 // doesn't accidentally do something the
239                                                                 // first frame
240         float           sendnoptime;    // send a clc_nop periodically until connected
241         usercmd_t       cmd;                    // last command sent to the server
242
243 // information for local display
244         int                     stats[MAX_CL_STATS];    // health, etc
245         int                     items;                  // inventory bit flags
246         float           item_gettime[32];       // cl.time of acquiring item, for blinking
247         float           faceanimtime;   // use anim frame if cl.time < this
248
249         cshift_t        cshifts[NUM_CSHIFTS];   // color shifts for damage, powerups
250         cshift_t        prev_cshifts[NUM_CSHIFTS];      // and content types
251
252 // the client maintains its own idea of view angles, which are
253 // sent to the server each frame.  The server sets punchangle when
254 // the view is temporarliy offset, and an angle reset commands at the start
255 // of each level and after teleporting.
256         vec3_t          mviewangles[2]; // during demo playback viewangles is lerped
257                                                                 // between these
258         vec3_t          viewangles;
259
260         vec3_t          mvelocity[2];   // update by server, used for lean+bob
261                                                                 // (0 is newest)
262         vec3_t          velocity;               // lerped between mvelocity[0] and [1]
263
264         vec3_t          punchangle;             // temporary offset
265         vec3_t          punchvector;    // LordHavoc: origin view kick
266
267 // pitch drifting vars
268         float           idealpitch;
269         float           pitchvel;
270         qboolean        nodrift;
271         float           driftmove;
272         double          laststop;
273
274         float           viewheight;
275         float           crouch;                 // local amount for smoothing stepups
276
277         qboolean        paused;                 // send over by server
278         qboolean        onground;
279         qboolean        inwater;
280
281         int                     intermission;   // don't change view angle, full screen, etc
282         int                     completed_time; // latched at intermission start
283
284         double          mtime[2];               // the timestamp of last two messages
285         double          time;                   // clients view of time, should be between
286                                                                 // servertime and oldservertime to generate
287                                                                 // a lerp point for other data
288         double          oldtime;                // previous cl.time, time-oldtime is used
289                                                                 // to decay light values and smooth step ups
290
291         double          frametime;
292
293
294         float           last_received_message;  // (realtime) for net trouble icon
295
296 //
297 // information that is static for the entire time connected to a server
298 //
299         struct model_s          *model_precache[MAX_MODELS];
300         struct sfx_s            *sound_precache[MAX_SOUNDS];
301
302         char            levelname[40];  // for display on solo scoreboard
303         int                     viewentity;             // cl_entitites[cl.viewentity] = player
304         int                     maxclients;
305         int                     gametype;
306
307 // refresh related state
308         struct model_s  *worldmodel;    // cl_entitites[0].model
309 //      int                     num_entities;   // held in cl_entities array
310         int                     num_statics;    // held in cl_staticentities array
311         entity_t        viewent;                        // the gun model
312
313         int                     cdtrack, looptrack;     // cd audio
314
315 // frag scoreboard
316         scoreboard_t    *scores;                // [cl.maxclients]
317
318         vec3_t          viewentorigin;
319         float           viewzoom;                       // LordHavoc: sniping zoom, QC controlled
320         float           viewzoomold, viewzoomnew; // for interpolation
321
322         // entity database stuff
323         vec3_t          viewentoriginold, viewentoriginnew;
324         entity_database_t entitydatabase;
325 }
326 client_state_t;
327
328 extern mempool_t *cl_scores_mempool;
329
330 //
331 // cvars
332 //
333 extern cvar_t cl_name;
334 extern cvar_t cl_color;
335 extern cvar_t cl_pmodel;
336
337 extern cvar_t cl_upspeed;
338 extern cvar_t cl_forwardspeed;
339 extern cvar_t cl_backspeed;
340 extern cvar_t cl_sidespeed;
341
342 extern cvar_t cl_movespeedkey;
343
344 extern cvar_t cl_yawspeed;
345 extern cvar_t cl_pitchspeed;
346
347 extern cvar_t cl_anglespeedkey;
348
349 extern cvar_t cl_autofire;
350
351 extern cvar_t cl_shownet;
352 extern cvar_t cl_nolerp;
353
354 extern cvar_t cl_pitchdriftspeed;
355 extern cvar_t lookspring;
356 extern cvar_t lookstrafe;
357 extern cvar_t sensitivity;
358
359 extern cvar_t freelook;
360
361 extern cvar_t m_pitch;
362 extern cvar_t m_yaw;
363 extern cvar_t m_forward;
364 extern cvar_t m_side;
365
366
367 // LordHavoc: raised these from 64 and 128 to 512 and 256
368 #define MAX_TEMP_ENTITIES       512                     // lightning bolts, effects, etc
369 #define MAX_STATIC_ENTITIES     256                     // torches, etc
370
371 extern client_state_t cl;
372
373 // FIXME, allocate dynamically
374 extern  entity_t                cl_entities[MAX_EDICTS];
375 extern  entity_t                cl_static_entities[MAX_STATIC_ENTITIES];
376 extern  lightstyle_t    cl_lightstyle[MAX_LIGHTSTYLES];
377 extern  entity_t                cl_temp_entities[MAX_TEMP_ENTITIES];
378 extern  beam_t                  cl_beams[MAX_BEAMS];
379
380 #include "cl_light.h"
381
382 //=============================================================================
383
384 //
385 // cl_main
386 //
387
388 void CL_Init (void);
389
390 void CL_EstablishConnection (char *host);
391
392 void CL_Disconnect (void);
393 void CL_Disconnect_f (void);
394
395 //
396 // cl_input
397 //
398 typedef struct
399 {
400         int             down[2];                // key nums holding it down
401         int             state;                  // low bit is down state
402 }
403 kbutton_t;
404
405 extern  kbutton_t       in_mlook, in_klook;
406 extern  kbutton_t       in_strafe;
407 extern  kbutton_t       in_speed;
408
409 void CL_InitInput (void);
410 void CL_SendCmd (void);
411 void CL_SendMove (usercmd_t *cmd);
412
413 void CL_LerpUpdate(entity_t *e);
414 void CL_ParseTEnt (void);
415 void CL_UpdateTEnts (void);
416
417 entity_t *CL_NewTempEntity (void);
418
419 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
420
421 void CL_ClearState (void);
422
423
424 int  CL_ReadFromServer (void);
425 void CL_WriteToServer (usercmd_t *cmd);
426 void CL_BaseMove (usercmd_t *cmd);
427
428
429 float CL_KeyState (kbutton_t *key);
430 char *Key_KeynumToString (int keynum);
431
432 //
433 // cl_demo.c
434 //
435 void CL_StopPlayback (void);
436 int CL_GetMessage (void);
437
438 void CL_NextDemo (void);
439 void CL_Stop_f (void);
440 void CL_Record_f (void);
441 void CL_PlayDemo_f (void);
442 void CL_TimeDemo_f (void);
443
444 //
445 // cl_parse.c
446 //
447 void CL_Parse_Init(void);
448 void CL_ParseServerMessage(void);
449 void CL_BitProfile_f(void);
450
451 //
452 // view
453 //
454 void V_StartPitchDrift (void);
455 void V_StopPitchDrift (void);
456
457 void V_Init (void);
458 float V_CalcRoll (vec3_t angles, vec3_t velocity);
459 void V_UpdateBlends (void);
460 void V_ParseDamage (void);
461
462
463 //
464 // cl_tent
465 //
466 void CL_InitTEnts (void);
467
468 //
469 // cl_part
470 //
471
472 #define PARTICLE_INVALID 0
473 #define PARTICLE_BILLBOARD 1
474 #define PARTICLE_UPRIGHT_FACING 2
475 #define PARTICLE_ORIENTED_DOUBLESIDED 3
476
477 /*
478 typedef struct renderparticle_s
479 {
480         int tex;
481         int orientation;
482         int additive;
483         int dynlight;
484         float scalex;
485         float scaley;
486         float org[3];
487         float dir[3];
488         float color[4];
489 }
490 renderparticle_t;
491 */
492
493 void CL_Particles_Clear(void);
494 void CL_Particles_Init(void);
495
496 void CL_ParseParticleEffect (void);
497 void CL_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
498 void CL_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
499 void CL_RocketTrail2 (vec3_t start, vec3_t end, int color, entity_t *ent);
500 void CL_SparkShower (vec3_t org, vec3_t dir, int count);
501 void CL_PlasmaBurn (vec3_t org);
502 void CL_BloodPuff (vec3_t org, vec3_t vel, int count);
503 void CL_Stardust (vec3_t mins, vec3_t maxs, int count);
504 void CL_FlameCube (vec3_t mins, vec3_t maxs, int count);
505 void CL_Flames (vec3_t org, vec3_t vel, int count);
506 void CL_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
507 void CL_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
508 void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
509 void CL_EntityParticles (entity_t *ent);
510 void CL_BlobExplosion (vec3_t org);
511 void CL_ParticleExplosion (vec3_t org, int smoke);
512 void CL_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
513 void CL_LavaSplash (vec3_t org);
514 void CL_TeleportSplash (vec3_t org);
515 void CL_MoveParticles(void);
516 void R_MoveExplosions(void);
517 void R_NewExplosion(vec3_t org);
518
519 #include "cl_screen.h"
520
521 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
522
523 typedef struct
524 {
525         // area to render in
526         int x, y, width, height;
527         float fov_x, fov_y;
528
529         // view point
530         vec3_t vieworg;
531         vec3_t viewangles;
532
533         // fullscreen color blend
534         float viewblend[4];
535
536         // weapon model
537         entity_render_t viewent;
538
539         int numentities;
540         entity_render_t **entities;
541
542         //int numparticles;
543         //struct renderparticle_s *particles;
544
545         qbyte drawqueue[MAX_DRAWQUEUE];
546         int drawqueuesize;
547 }
548 refdef_t;
549
550 refdef_t r_refdef;
551
552 extern mempool_t *cl_refdef_mempool;
553
554 #include "cgamevm.h"