]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - client.h
42845cda32982de39b055d1fc0d8c7c7bb33cba3
[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 typedef struct
23 {
24         vec3_t  viewangles;
25
26 // intended velocities
27         float   forwardmove;
28         float   sidemove;
29         float   upmove;
30 } usercmd_t;
31
32 typedef struct
33 {
34         int             length;
35         char    map[MAX_STYLESTRING];
36 } lightstyle_t;
37
38 typedef struct
39 {
40         char    name[MAX_SCOREBOARDNAME];
41         float   entertime;
42         int             frags;
43         int             colors; // two 4 bit fields
44 } scoreboard_t;
45
46 typedef struct
47 {
48         int             destcolor[3];
49         int             percent;                // 0-256
50 } cshift_t;
51
52 #define CSHIFT_CONTENTS 0
53 #define CSHIFT_DAMAGE   1
54 #define CSHIFT_BONUS    2
55 #define CSHIFT_POWERUP  3
56 #define NUM_CSHIFTS             4
57
58 #define NAME_LENGTH     64
59
60
61 //
62 // client_state_t should hold all pieces of the client state
63 //
64
65 #define SIGNONS         4                       // signon messages to receive before connected
66
67 #include "r_light.h"
68
69 #define MAX_BEAMS       24
70 typedef struct
71 {
72         int             entity;
73         struct model_s  *model;
74         float   endtime;
75         vec3_t  start, end;
76 }
77 beam_t;
78
79 // LordHavoc: increased MAX_EFRAGS from 640 to 2048
80 #define MAX_EFRAGS              2048
81
82 #define MAX_MAPSTRING   2048
83 #define MAX_DEMOS               8
84 #define MAX_DEMONAME    16
85
86 typedef enum
87 {
88         ca_dedicated,           // a dedicated server with no ability to start a client
89         ca_disconnected,        // full screen console with no connection
90         ca_connected            // valid netcon, talking to a server
91 }
92 cactive_t;
93
94 //
95 // the client_static_t structure is persistant through an arbitrary number
96 // of server connections
97 //
98 typedef struct
99 {
100         cactive_t       state;
101
102 // personalization data sent to server  
103         char            mapstring[MAX_QPATH];
104         char            spawnparms[MAX_MAPSTRING];      // to restart a level
105
106 // demo loop control
107         int                     demonum;                // -1 = don't play demos
108         char            demos[MAX_DEMOS][MAX_DEMONAME];         // when not playing
109
110 // demo recording info must be here, because record is started before
111 // entering a map (and clearing client_state_t)
112         qboolean        demorecording;
113         qboolean        demoplayback;
114         qboolean        timedemo;
115         int                     forcetrack;                     // -1 = use normal cd track
116         FILE            *demofile;
117         int                     td_lastframe;           // to meter out one message a frame
118         int                     td_startframe;          // host_framecount at start
119         double          td_starttime;           // realtime at second frame of timedemo (LordHavoc: changed to double)
120         qboolean        demopaused;                     // LordHavoc: pausedemo
121
122
123 // connection information
124         int                     signon;                 // 0 to SIGNONS
125         struct qsocket_s        *netcon;
126         sizebuf_t       message;                // writing buffer to send to server
127 }
128 client_static_t;
129
130 extern client_static_t  cls;
131
132 //
133 // the client_state_t structure is wiped completely at every
134 // server signon
135 //
136 typedef struct
137 {
138         int                     movemessages;   // since connecting to this server
139                                                                 // throw out the first couple, so the player
140                                                                 // doesn't accidentally do something the 
141                                                                 // first frame
142         usercmd_t       cmd;                    // last command sent to the server
143
144 // information for local display
145         int                     stats[MAX_CL_STATS];    // health, etc
146         int                     items;                  // inventory bit flags
147         float           item_gettime[32];       // cl.time of acquiring item, for blinking
148         float           faceanimtime;   // use anim frame if cl.time < this
149
150         cshift_t        cshifts[NUM_CSHIFTS];   // color shifts for damage, powerups
151         cshift_t        prev_cshifts[NUM_CSHIFTS];      // and content types
152
153 // the client maintains its own idea of view angles, which are
154 // sent to the server each frame.  The server sets punchangle when
155 // the view is temporarliy offset, and an angle reset commands at the start
156 // of each level and after teleporting.
157         vec3_t          mviewangles[2]; // during demo playback viewangles is lerped
158                                                                 // between these
159         vec3_t          viewangles;
160         
161         vec3_t          mvelocity[2];   // update by server, used for lean+bob
162                                                                 // (0 is newest)
163         vec3_t          velocity;               // lerped between mvelocity[0] and [1]
164
165         vec3_t          punchangle;             // temporary offset
166         vec3_t          punchvector;    // LordHavoc: origin view kick
167
168 // pitch drifting vars
169         float           idealpitch;
170         float           pitchvel;
171         qboolean        nodrift;
172         float           driftmove;
173         double          laststop;
174
175         float           viewheight;
176         float           crouch;                 // local amount for smoothing stepups
177
178         qboolean        paused;                 // send over by server
179         qboolean        onground;
180         qboolean        inwater;
181
182         int                     intermission;   // don't change view angle, full screen, etc
183         int                     completed_time; // latched at intermission start
184
185         double          mtime[2];               // the timestamp of last two messages   
186         double          time;                   // clients view of time, should be between
187                                                                 // servertime and oldservertime to generate
188                                                                 // a lerp point for other data
189         double          oldtime;                // previous cl.time, time-oldtime is used
190                                                                 // to decay light values and smooth step ups
191
192         double          frametime;
193
194
195         float           last_received_message;  // (realtime) for net trouble icon
196
197 //
198 // information that is static for the entire time connected to a server
199 //
200         struct model_s          *model_precache[MAX_MODELS];
201         struct sfx_s            *sound_precache[MAX_SOUNDS];
202
203         char            levelname[40];  // for display on solo scoreboard
204         int                     viewentity;             // cl_entitites[cl.viewentity] = player
205         int                     maxclients;
206         int                     gametype;
207
208 // refresh related state
209         struct model_s  *worldmodel;    // cl_entitites[0].model
210         struct efrag_s  *free_efrags;
211 //      int                     num_entities;   // held in cl_entities array
212         int                     num_statics;    // held in cl_staticentities array
213         entity_t        viewent;                        // the gun model
214
215         int                     cdtrack, looptrack;     // cd audio
216
217 // frag scoreboard
218         scoreboard_t    *scores;                // [cl.maxclients]
219 }
220 client_state_t;
221
222
223 //
224 // cvars
225 //
226 extern  cvar_t  cl_name;
227 extern  cvar_t  cl_color;
228 extern  cvar_t  cl_pmodel;
229
230 extern  cvar_t  cl_upspeed;
231 extern  cvar_t  cl_forwardspeed;
232 extern  cvar_t  cl_backspeed;
233 extern  cvar_t  cl_sidespeed;
234
235 extern  cvar_t  cl_movespeedkey;
236
237 extern  cvar_t  cl_yawspeed;
238 extern  cvar_t  cl_pitchspeed;
239
240 extern  cvar_t  cl_anglespeedkey;
241
242 extern  cvar_t  cl_autofire;
243
244 extern  cvar_t  cl_shownet;
245 extern  cvar_t  cl_nolerp;
246
247 extern  cvar_t  cl_pitchdriftspeed;
248 extern  cvar_t  lookspring;
249 extern  cvar_t  lookstrafe;
250 extern  cvar_t  sensitivity;
251
252 extern  cvar_t  m_pitch;
253 extern  cvar_t  m_yaw;
254 extern  cvar_t  m_forward;
255 extern  cvar_t  m_side;
256
257
258 // LordHavoc: raised these from 64 and 128 to 512 and 256
259 #define MAX_TEMP_ENTITIES       512                     // lightning bolts, effects, etc
260 #define MAX_STATIC_ENTITIES     256                     // torches, etc
261
262 extern  client_state_t  cl;
263
264 // FIXME, allocate dynamically
265 extern  efrag_t                 cl_efrags[MAX_EFRAGS];
266 extern  entity_t                cl_entities[MAX_EDICTS];
267 extern  entity_t                cl_static_entities[MAX_STATIC_ENTITIES];
268 extern  lightstyle_t    cl_lightstyle[MAX_LIGHTSTYLES];
269 extern  dlight_t                cl_dlights[MAX_DLIGHTS];
270 extern  entity_t                cl_temp_entities[MAX_TEMP_ENTITIES];
271 extern  beam_t                  cl_beams[MAX_BEAMS];
272
273 //=============================================================================
274
275 //
276 // cl_main
277 //
278 void CL_AllocDlight (entity_t *ent, vec3_t org, float radius, float red, float green, float blue, float decay, float lifetime);
279 void CL_DecayLights (void);
280
281 void CL_Init (void);
282
283 void CL_EstablishConnection (char *host);
284 void CL_Signon1 (void);
285 void CL_Signon2 (void);
286 void CL_Signon3 (void);
287 void CL_Signon4 (void);
288
289 void CL_Disconnect (void);
290 void CL_Disconnect_f (void);
291 void CL_NextDemo (void);
292
293 // LordHavoc: raised this from 256 to the maximum possible number of entities visible
294 #define MAX_VISEDICTS (MAX_EDICTS + MAX_STATIC_ENTITIES + MAX_TEMP_ENTITIES)
295 extern  int                     cl_numvisedicts;
296 extern  entity_t        *cl_visedicts[MAX_VISEDICTS];
297
298 //
299 // cl_input
300 //
301 typedef struct
302 {
303         int             down[2];                // key nums holding it down
304         int             state;                  // low bit is down state
305 }
306 kbutton_t;
307
308 extern  kbutton_t       in_mlook, in_klook;
309 extern  kbutton_t       in_strafe;
310 extern  kbutton_t       in_speed;
311
312 void CL_InitInput (void);
313 void CL_SendCmd (void);
314 void CL_SendMove (usercmd_t *cmd);
315
316 void CL_ParseTEnt (void);
317 void CL_UpdateTEnts (void);
318 void CL_DoEffects (void);
319
320 entity_t *CL_NewTempEntity (void);
321
322 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
323
324 void CL_ClearState (void);
325
326
327 int  CL_ReadFromServer (void);
328 void CL_WriteToServer (usercmd_t *cmd);
329 void CL_BaseMove (usercmd_t *cmd);
330
331
332 float CL_KeyState (kbutton_t *key);
333 char *Key_KeynumToString (int keynum);
334
335 //
336 // cl_demo.c
337 //
338 void CL_StopPlayback (void);
339 int CL_GetMessage (void);
340
341 void CL_Stop_f (void);
342 void CL_Record_f (void);
343 void CL_PlayDemo_f (void);
344 void CL_TimeDemo_f (void);
345
346 //
347 // cl_parse.c
348 //
349 void CL_ParseServerMessage (void);
350
351 //
352 // view
353 //
354 void V_StartPitchDrift (void);
355 void V_StopPitchDrift (void);
356
357 void V_RenderView (void);
358 void V_UpdateBlends (void);
359 void V_Register (void);
360 void V_ParseDamage (void);
361 void V_SetContentsColor (int contents);
362
363
364 //
365 // cl_tent
366 //
367 void CL_InitTEnts (void);
368 void CL_SignonReply (void);