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