summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/client.h')
-rw-r--r--apps/plugins/sdl/progs/quake/client.h376
1 files changed, 376 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/client.h b/apps/plugins/sdl/progs/quake/client.h
new file mode 100644
index 0000000000..4d52bf907e
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/client.h
@@ -0,0 +1,376 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// client.h
21
22typedef struct
23{
24 vec3_t viewangles;
25
26// intended velocities
27 float forwardmove;
28 float sidemove;
29 float upmove;
30#ifdef QUAKE2
31 byte lightlevel;
32#endif
33} usercmd_t;
34
35typedef struct
36{
37 int length;
38 char map[MAX_STYLESTRING];
39} lightstyle_t;
40
41typedef struct
42{
43 char name[MAX_SCOREBOARDNAME];
44 float entertime;
45 int frags;
46 int colors; // two 4 bit fields
47 byte translations[VID_GRADES*256];
48} scoreboard_t;
49
50typedef struct
51{
52 int destcolor[3];
53 int percent; // 0-256
54} cshift_t;
55
56#define CSHIFT_CONTENTS 0
57#define CSHIFT_DAMAGE 1
58#define CSHIFT_BONUS 2
59#define CSHIFT_POWERUP 3
60#define NUM_CSHIFTS 4
61
62#define NAME_LENGTH 64
63
64
65//
66// client_state_t should hold all pieces of the client state
67//
68
69#define SIGNONS 4 // signon messages to receive before connected
70
71#define MAX_DLIGHTS 32
72typedef struct
73{
74 vec3_t origin;
75 float radius;
76 float die; // stop lighting after this time
77 float decay; // drop this each second
78 float minlight; // don't add when contributing less
79 int key;
80#ifdef QUAKE2
81 qboolean dark; // subtracts light instead of adding
82#endif
83} dlight_t;
84
85
86#define MAX_BEAMS 24
87typedef struct
88{
89 int entity;
90 struct model_s *model;
91 float endtime;
92 vec3_t start, end;
93} beam_t;
94
95#define MAX_EFRAGS 640
96
97#define MAX_MAPSTRING 2048
98#define MAX_DEMOS 8
99#define MAX_DEMONAME 16
100
101typedef int cactive_t;
102enum {
103ca_dedicated, // a dedicated server with no ability to start a client
104ca_disconnected, // full screen console with no connection
105ca_connected // valid netcon, talking to a server
106};
107
108//
109// the client_static_t structure is persistant through an arbitrary number
110// of server connections
111//
112typedef struct
113{
114 cactive_t state;
115
116// personalization data sent to server
117 char mapstring[MAX_QPATH];
118 char spawnparms[MAX_MAPSTRING]; // to restart a level
119
120// demo loop control
121 int demonum; // -1 = don't play demos
122 char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
123
124// demo recording info must be here, because record is started before
125// entering a map (and clearing client_state_t)
126 qboolean demorecording;
127 qboolean demoplayback;
128 qboolean timedemo;
129 int forcetrack; // -1 = use normal cd track
130 FILE *demofile;
131 int td_lastframe; // to meter out one message a frame
132 int td_startframe; // host_framecount at start
133 float td_starttime; // realtime at second frame of timedemo
134
135
136// connection information
137 int signon; // 0 to SIGNONS
138 struct qsocket_s *netcon;
139 sizebuf_t message; // writing buffer to send to server
140
141} client_static_t;
142
143extern client_static_t cls;
144
145//
146// the client_state_t structure is wiped completely at every
147// server signon
148//
149typedef struct
150{
151 int movemessages; // since connecting to this server
152 // throw out the first couple, so the player
153 // doesn't accidentally do something the
154 // first frame
155 usercmd_t cmd; // last command sent to the server
156
157// information for local display
158 int stats[MAX_CL_STATS]; // health, etc
159 int items; // inventory bit flags
160 float item_gettime[32]; // cl.time of aquiring item, for blinking
161 float faceanimtime; // use anim frame if cl.time < this
162
163 cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
164 cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
165
166// the client maintains its own idea of view angles, which are
167// sent to the server each frame. The server sets punchangle when
168// the view is temporarliy offset, and an angle reset commands at the start
169// of each level and after teleporting.
170 vec3_t mviewangles[2]; // during demo playback viewangles is lerped
171 // between these
172 vec3_t viewangles;
173
174 vec3_t mvelocity[2]; // update by server, used for lean+bob
175 // (0 is newest)
176 vec3_t velocity; // lerped between mvelocity[0] and [1]
177
178 vec3_t punchangle; // temporary offset
179
180// pitch drifting vars
181 float idealpitch;
182 float pitchvel;
183 qboolean nodrift;
184 float driftmove;
185 double laststop;
186
187 float viewheight;
188 float crouch; // local amount for smoothing stepups
189
190 qboolean paused; // send over by server
191 qboolean onground;
192 qboolean inwater;
193
194 int intermission; // don't change view angle, full screen, etc
195 int completed_time; // latched at intermission start
196
197 double mtime[2]; // the timestamp of last two messages
198 double time; // clients view of time, should be between
199 // servertime and oldservertime to generate
200 // a lerp point for other data
201 double oldtime; // previous cl.time, time-oldtime is used
202 // to decay light values and smooth step ups
203
204
205 float last_received_message; // (realtime) for net trouble icon
206
207//
208// information that is static for the entire time connected to a server
209//
210 struct model_s *model_precache[MAX_MODELS];
211 struct sfx_s *sound_precache[MAX_SOUNDS];
212
213 char levelname[40]; // for display on solo scoreboard
214 int viewentity; // cl_entitites[cl.viewentity] = player
215 int maxclients;
216 int gametype;
217
218// refresh related state
219 struct model_s *worldmodel; // cl_entitites[0].model
220 struct efrag_s *free_efrags;
221 int num_entities; // held in cl_entities array
222 int num_statics; // held in cl_staticentities array
223 entity_t viewent; // the gun model
224
225 int cdtrack, looptrack; // cd audio
226
227// frag scoreboard
228 scoreboard_t *scores; // [cl.maxclients]
229
230#ifdef QUAKE2
231// light level at player's position including dlights
232// this is sent back to the server each frame
233// architectually ugly but it works
234 int light_level;
235#endif
236} client_state_t;
237
238
239//
240// cvars
241//
242extern cvar_t cl_name;
243extern cvar_t cl_color;
244
245extern cvar_t cl_upspeed;
246extern cvar_t cl_forwardspeed;
247extern cvar_t cl_backspeed;
248extern cvar_t cl_sidespeed;
249
250extern cvar_t cl_movespeedkey;
251
252extern cvar_t cl_yawspeed;
253extern cvar_t cl_pitchspeed;
254
255extern cvar_t cl_anglespeedkey;
256
257extern cvar_t cl_autofire;
258
259extern cvar_t cl_shownet;
260extern cvar_t cl_nolerp;
261
262extern cvar_t cl_pitchdriftspeed;
263extern cvar_t lookspring;
264extern cvar_t lookstrafe;
265extern cvar_t sensitivity;
266
267extern cvar_t m_pitch;
268extern cvar_t m_yaw;
269extern cvar_t m_forward;
270extern cvar_t m_side;
271
272
273#define MAX_TEMP_ENTITIES 64 // lightning bolts, etc
274#define MAX_STATIC_ENTITIES 128 // torches, etc
275
276extern client_state_t cl;
277
278// FIXME, allocate dynamically
279extern efrag_t cl_efrags[MAX_EFRAGS];
280extern entity_t cl_entities[MAX_EDICTS];
281extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
282extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
283extern dlight_t cl_dlights[MAX_DLIGHTS];
284extern entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
285extern beam_t cl_beams[MAX_BEAMS];
286
287//=============================================================================
288
289//
290// cl_main
291//
292dlight_t *CL_AllocDlight (int key);
293void CL_DecayLights (void);
294
295void CL_Init (void);
296
297void CL_EstablishConnection (char *host);
298void CL_Signon1 (void);
299void CL_Signon2 (void);
300void CL_Signon3 (void);
301void CL_Signon4 (void);
302
303void CL_Disconnect (void);
304void CL_Disconnect_f (void);
305void CL_NextDemo (void);
306
307#define MAX_VISEDICTS 256
308extern int cl_numvisedicts;
309extern entity_t *cl_visedicts[MAX_VISEDICTS];
310
311//
312// cl_input
313//
314typedef struct
315{
316 int down[2]; // key nums holding it down
317 int state; // low bit is down state
318} kbutton_t;
319
320extern kbutton_t in_mlook, in_klook;
321extern kbutton_t in_strafe;
322extern kbutton_t in_speed;
323
324void CL_InitInput (void);
325void CL_SendCmd (void);
326void CL_SendMove (usercmd_t *cmd);
327
328void CL_ParseTEnt (void);
329void CL_UpdateTEnts (void);
330
331void CL_ClearState (void);
332
333
334int CL_ReadFromServer (void);
335void CL_WriteToServer (usercmd_t *cmd);
336void CL_BaseMove (usercmd_t *cmd);
337
338
339float CL_KeyState (kbutton_t *key);
340char *Key_KeynumToString (int keynum);
341
342//
343// cl_demo.c
344//
345void CL_StopPlayback (void);
346int CL_GetMessage (void);
347
348void CL_Stop_f (void);
349void CL_Record_f (void);
350void CL_PlayDemo_f (void);
351void CL_TimeDemo_f (void);
352
353//
354// cl_parse.c
355//
356void CL_ParseServerMessage (void);
357void CL_NewTranslation (int slot);
358
359//
360// view
361//
362void V_StartPitchDrift (void);
363void V_StopPitchDrift (void);
364
365void V_RenderView (void);
366void V_UpdatePalette (void);
367void V_Register (void);
368void V_ParseDamage (void);
369void V_SetContentsColor (int contents);
370
371
372//
373// cl_tent
374//
375void CL_InitTEnts (void);
376void CL_SignonReply (void);