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