]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - client.h
Borland C++ makefile for Darkplaces. Does NOT use asm objs yet, but works otherwise.
[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 //      byte    translations[256]; // LordHavoc: major memory reduction (was VID_GRADES*256, and VID_GRADES is 64), and weirdness cleanup
45 } scoreboard_t;
46
47 typedef struct
48 {
49         int             destcolor[3];
50         int             percent;                // 0-256
51 } cshift_t;
52
53 #define CSHIFT_CONTENTS 0
54 #define CSHIFT_DAMAGE   1
55 #define CSHIFT_BONUS    2
56 #define CSHIFT_POWERUP  3
57 #define NUM_CSHIFTS             4
58
59 #define NAME_LENGTH     64
60
61
62 //
63 // client_state_t should hold all pieces of the client state
64 //
65
66 #define SIGNONS         4                       // signon messages to receive before connected
67
68 #include "r_light.h"
69
70 #define MAX_BEAMS       24
71 typedef struct
72 {
73         int             entity;
74         struct model_s  *model;
75         float   endtime;
76         vec3_t  start, end;
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 ca_dedicated,           // a dedicated server with no ability to start a client
88 ca_disconnected,        // full screen console with no connection
89 ca_connected            // valid netcon, talking to a server
90 } cactive_t;
91
92 //
93 // the client_static_t structure is persistant through an arbitrary number
94 // of server connections
95 //
96 typedef struct
97 {
98         cactive_t       state;
99
100 // personalization data sent to server  
101         char            mapstring[MAX_QPATH];
102         char            spawnparms[MAX_MAPSTRING];      // to restart a level
103
104 // demo loop control
105         int                     demonum;                // -1 = don't play demos
106         char            demos[MAX_DEMOS][MAX_DEMONAME];         // when not playing
107
108 // demo recording info must be here, because record is started before
109 // entering a map (and clearing client_state_t)
110         qboolean        demorecording;
111         qboolean        demoplayback;
112         qboolean        timedemo;
113         int                     forcetrack;                     // -1 = use normal cd track
114         FILE            *demofile;
115         int                     td_lastframe;           // to meter out one message a frame
116         int                     td_startframe;          // host_framecount at start
117         double          td_starttime;           // realtime at second frame of timedemo (LordHavoc: changed to double)
118         qboolean        demopaused;                     // LordHavoc: pausedemo
119
120
121 // connection information
122         int                     signon;                 // 0 to SIGNONS
123         struct qsocket_s        *netcon;
124         sizebuf_t       message;                // writing buffer to send to server
125         
126 } client_static_t;
127
128 extern client_static_t  cls;
129
130 //
131 // the client_state_t structure is wiped completely at every
132 // server signon
133 //
134 typedef struct
135 {
136         int                     movemessages;   // since connecting to this server
137                                                                 // throw out the first couple, so the player
138                                                                 // doesn't accidentally do something the 
139                                                                 // first frame
140         usercmd_t       cmd;                    // last command sent to the server
141
142 // information for local display
143         int                     stats[MAX_CL_STATS];    // health, etc
144         int                     items;                  // inventory bit flags
145         float   item_gettime[32];       // cl.time of aquiring item, for blinking
146         float           faceanimtime;   // use anim frame if cl.time < this
147
148         cshift_t        cshifts[NUM_CSHIFTS];   // color shifts for damage, powerups
149         cshift_t        prev_cshifts[NUM_CSHIFTS];      // and content types
150
151 // the client maintains its own idea of view angles, which are
152 // sent to the server each frame.  The server sets punchangle when
153 // the view is temporarliy offset, and an angle reset commands at the start
154 // of each level and after teleporting.
155         vec3_t          mviewangles[2]; // during demo playback viewangles is lerped
156                                                                 // between these
157         vec3_t          viewangles;
158         
159         vec3_t          mvelocity[2];   // update by server, used for lean+bob
160                                                                 // (0 is newest)
161         vec3_t          velocity;               // lerped between mvelocity[0] and [1]
162
163         vec3_t          punchangle;             // temporary offset
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
190         float           last_received_message;  // (realtime) for net trouble icon
191
192 //
193 // information that is static for the entire time connected to a server
194 //
195         struct model_s          *model_precache[MAX_MODELS];
196         struct sfx_s            *sound_precache[MAX_SOUNDS];
197
198         char            levelname[40];  // for display on solo scoreboard
199         int                     viewentity;             // cl_entitites[cl.viewentity] = player
200         int                     maxclients;
201         int                     gametype;
202
203 // refresh related state
204         struct model_s  *worldmodel;    // cl_entitites[0].model
205         struct efrag_s  *free_efrags;
206         int                     num_entities;   // held in cl_entities array
207         int                     num_statics;    // held in cl_staticentities array
208         entity_t        viewent;                        // the gun model
209
210         int                     cdtrack, looptrack;     // cd audio
211
212 // frag scoreboard
213         scoreboard_t    *scores;                // [cl.maxclients]
214 } client_state_t;
215
216
217 //
218 // cvars
219 //
220 extern  cvar_t  cl_name;
221 extern  cvar_t  cl_color;
222 extern  cvar_t  cl_pmodel;
223
224 extern  cvar_t  cl_upspeed;
225 extern  cvar_t  cl_forwardspeed;
226 extern  cvar_t  cl_backspeed;
227 extern  cvar_t  cl_sidespeed;
228
229 extern  cvar_t  cl_movespeedkey;
230
231 extern  cvar_t  cl_yawspeed;
232 extern  cvar_t  cl_pitchspeed;
233
234 extern  cvar_t  cl_anglespeedkey;
235
236 extern  cvar_t  cl_autofire;
237
238 extern  cvar_t  cl_shownet;
239 extern  cvar_t  cl_nolerp;
240
241 extern  cvar_t  cl_pitchdriftspeed;
242 extern  cvar_t  lookspring;
243 extern  cvar_t  lookstrafe;
244 extern  cvar_t  sensitivity;
245
246 extern  cvar_t  m_pitch;
247 extern  cvar_t  m_yaw;
248 extern  cvar_t  m_forward;
249 extern  cvar_t  m_side;
250
251
252 #define MAX_TEMP_ENTITIES       64                      // lightning bolts, etc
253 #define MAX_STATIC_ENTITIES     128                     // torches, etc
254
255 extern  client_state_t  cl;
256
257 // FIXME, allocate dynamically
258 extern  efrag_t                 cl_efrags[MAX_EFRAGS];
259 extern  entity_t                cl_entities[MAX_EDICTS];
260 extern  entity_t                cl_static_entities[MAX_STATIC_ENTITIES];
261 extern  lightstyle_t    cl_lightstyle[MAX_LIGHTSTYLES];
262 extern  dlight_t                cl_dlights[MAX_DLIGHTS];
263 extern  entity_t                cl_temp_entities[MAX_TEMP_ENTITIES];
264 extern  beam_t                  cl_beams[MAX_BEAMS];
265
266 //=============================================================================
267
268 //
269 // cl_main
270 //
271 dlight_t *CL_AllocDlight (int key);
272 void    CL_DecayLights (void);
273
274 void CL_Init (void);
275
276 void CL_EstablishConnection (char *host);
277 void CL_Signon1 (void);
278 void CL_Signon2 (void);
279 void CL_Signon3 (void);
280 void CL_Signon4 (void);
281
282 void CL_Disconnect (void);
283 void CL_Disconnect_f (void);
284 void CL_NextDemo (void);
285
286 #define                 MAX_VISEDICTS   256
287 extern  int                             cl_numvisedicts;
288 extern  entity_t                *cl_visedicts[MAX_VISEDICTS];
289
290 //
291 // cl_input
292 //
293 typedef struct
294 {
295         int             down[2];                // key nums holding it down
296         int             state;                  // low bit is down state
297 } kbutton_t;
298
299 extern  kbutton_t       in_mlook, in_klook;
300 extern  kbutton_t       in_strafe;
301 extern  kbutton_t       in_speed;
302
303 void CL_InitInput (void);
304 void CL_SendCmd (void);
305 void CL_SendMove (usercmd_t *cmd);
306
307 void CL_ParseTEnt (void);
308 void CL_UpdateTEnts (void);
309
310 void CL_ClearState (void);
311
312
313 int  CL_ReadFromServer (void);
314 void CL_WriteToServer (usercmd_t *cmd);
315 void CL_BaseMove (usercmd_t *cmd);
316
317
318 float CL_KeyState (kbutton_t *key);
319 char *Key_KeynumToString (int keynum);
320
321 //
322 // cl_demo.c
323 //
324 void CL_StopPlayback (void);
325 int CL_GetMessage (void);
326
327 void CL_Stop_f (void);
328 void CL_Record_f (void);
329 void CL_PlayDemo_f (void);
330 void CL_TimeDemo_f (void);
331
332 //
333 // cl_parse.c
334 //
335 void CL_ParseServerMessage (void);
336
337 //
338 // view
339 //
340 void V_StartPitchDrift (void);
341 void V_StopPitchDrift (void);
342
343 void V_RenderView (void);
344 void V_UpdatePalette (void);
345 void V_Register (void);
346 void V_ParseDamage (void);
347 void V_SetContentsColor (int contents);
348
349
350 //
351 // cl_tent
352 //
353 void CL_InitTEnts (void);
354 void CL_SignonReply (void);