-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
593 lines (486 loc) · 16.1 KB
/
Copy pathclient.h
File metadata and controls
593 lines (486 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// client.h
// R_RocketTrail types -- // Changes to rtype_t must also be made in glquake.h
typedef enum
{
rt_rocket_trail = 0,
rt_smoke,
rt_blood,
rt_tracer,
rt_slight_blood,
rt_tracer2,
rt_voor_trail,
rt_fireball,
rt_ice,
rt_spit,
rt_spell,
rt_vorpal,
rt_setstaff,
rt_magicmissile,
rt_boneshard,
rt_scarab,
rt_acidball,
rt_bloodshot,
} rt_type_t;
// particles stuff
typedef enum
{
pt_static,
pt_grav,
pt_fastgrav,
pt_slowgrav,
pt_fire,
pt_explode,
pt_explode2,
pt_blob,
pt_blob2,
pt_rain,
pt_c_explode,
pt_c_explode2,
pt_spit,
pt_fireball,
pt_ice,
pt_spell,
pt_test,
pt_quake,
pt_rd, // rider's death
pt_vorpal,
pt_setstaff,
pt_magicmissile,
pt_boneshard,
pt_scarab,
pt_acidball,
pt_darken,
pt_snow,
pt_gravwell,
pt_redfire
} ptype_t;
typedef struct particle_s
{
// driver-usable fields
vec3_t org;
float color; // fixme: int/short/byte (palette index???)
// drivers never touch the following fields
struct particle_s *next;
vec3_t vel;
vec3_t min_org;
vec3_t max_org;
float ramp;
float die;
byte type; // ptype_t
byte flags; // int
byte count; // int
} particle_t;
typedef struct
{
vec3_t viewangles;
// intended velocities
float forwardmove;
float sidemove;
float upmove;
byte lightlevel;
} usercmd_t;
typedef struct
{
int length;
char map[MAX_STYLESTRING];
char average; //johnfitz -- flatlightstyles
char peak; //johnfitz -- flatlightstyles
} lightstyle_t;
typedef struct
{
char name[MAX_SCOREBOARDNAME];
float entertime;
int frags;
int colors; // two 4 bit fields
byte translations[VID_GRADES*256];
float playerclass;
} scoreboard_t;
typedef struct
{
int destcolor[3];
int percent; // 0-256
} cshift_t;
#define CSHIFT_CONTENTS 0
#define CSHIFT_DAMAGE 1
#define CSHIFT_BONUS 2
#define CSHIFT_POWERUP 3
#define CSHIFT_INTERVENTION 4
#define NUM_CSHIFTS 5
#define NAME_LENGTH 64
//
// client_state_t should hold all pieces of the client state
//
#define MAX_DLIGHTS 512 //johnfitz -- was 32
typedef struct
{
vec3_t origin;
float radius;
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
int key;
vec3_t color; // lit support via lordhavoc
qboolean dark; // subtracts light instead of adding
} dlight_t;
// keep dlight colours in the one place so that if i need to change them i only need to do it once
#define DL_COLOR_V_SHOT 152, 8
#define DL_COLOR_BALL 150, 6
#define DL_COLOR_TORNATO 160, 8
#define DL_COLOR_LIGHTNING 147, 13
#define DL_COLOR_TELERED 131, 13
#define DL_COLOR_REDCLOUD 136, 8
#define DL_COLOR_FAMSHOT 136, 8
#define DL_COLOR_SPELL 39, 3
#define DL_COLOR_SPELL_M 132, 5
#define DL_COLOR_GHOST 19, 5
#define DL_COLOR_ACID_MUZZFL (int []) {191, 188}, 2
#define DL_COLOR_YELLOWRED_FLASH 251, 2
#define DL_COLOR_GREEN_SMOKE 176, 13
#define DL_COLOR_TELESMK 17, 4
#define DL_COLOR_GREY_SMOKE 3, 5
#define DL_COLOR_WHITE_SMOKE 16, 8
#define DL_COLOR_WHITE_FLASH 16, 16
#define DL_COLOR_RED_SMOKE 129, 8
#define DL_COLOR_RED_FLASH 128, 16
#define DL_COLOR_REDSPARK (int []) {253, 254, 174, 175, 142, 143}, 6
#define DL_COLOR_ICE 144, 16
#define DL_COLOR_FLAME 166, 10
#define DL_COLOR_FLAME2 174, 2
#define DL_COLOR_FLAME3 168, 8
#define DL_COLOR_FLAME4 170, 6
#define DL_COLOR_FLAME5 164, 12
#define DL_COLOR_SUN 169, 7
#define DL_COLOR_FLAMEWALL 162, 13
#define DL_COLOR_FLAMEWALL2 162, 14
#define DL_COLOR_FLAMEWALL3 166, 8
#define DL_COLOR_15 15 // dark grey 104
#define DL_COLOR_29 29 // dim white 232
#define DL_COLOR_27 27 // dim white 212
#define DL_COLOR_31 31 // white 252
#define DL_COLOR_88 88
#define DL_COLOR_120 120
#define DL_COLOR_135 135
#define DL_COLOR_140 140 // red
#define DL_COLOR_185 185
#define DL_COLOR_252 252 // bright orange
#define DL_COLOR_254 254 // bright yellow (torch powerup)
#define DL_COLOR_175 175 // yellow
#define DL_COLOR_255 255 // full white
#define DL_COLOR_G_MAGENTA 239, 4 // glow magenta
#define DL_COLOR_G_GREEN 243, 4 // glow green
#define DL_COLOR_G_BLUE 247, 4 // glow blue
#define DL_COLOR_G_ORANGE 251, 4 // glow orange
#define DL_COLOR_BLDRN_EXPL 251, 5
#define DL_COLOR_ACID_EXPL 186, 6
#define DL_COLOR_GOLEMMIS 128, 16 // all red
#define DL_COLOR_SPIKE 169, 4
#define DL_COLOR_SHARD0 (int []) {27, 47, 249, 250}, 4
#define DL_COLOR_SHARD1 (int []) {13, 14, 15, 16, 17, 20, 21}, 7
#define DL_COLOR_SHARD2 (int []) {211, 212, 213, 226}, 4
#define DL_COLOR_LBALL_EXPL (int []) {28, 31, 44, 45, 46, 47}, 6
#define DL_COLOR_BOMB (int []) {170, 171, 172, 173, 174, 175, 255}, 7
#define DL_COLOR_ACID_HIT (int []) {191, 245, 246}, 3
#define DL_COLOR_BONE_EXPLOSION (int []) {27, 28, 29, 30, 31, 45, 46}, 7
#define DL_COLOR_MM_EXPLOSION (int []) {28, 31, 47, 159}, 4
#define DL_COLOR_MEZZO_REF (int []) {135, 139, 140, 143}, 4
#define DL_COLOR_RED_ARROW (int []) {135, 137, 140, 143}, 4 // red arrow, skin1
#define DL_COLOR_FIREBALL (int []) {163, 165, 167, 169, 171, 173, 175, 252, 254}, 9
#define DL_COLOR_GLOWBALL (int []) {249, 250, 255}, 3
#define DL_COLOR_PESTSHOT (int []) {185, 186, 187, 188, 189, 190, 191, 243, 244, 245, 246}, 11
#define DL_COLOR_ICESHOT1 (int []) {28, 47, 149, 151, 152, 153, 154, 155, 156, 157, 159}, 11
#define DL_COLOR_ICESHOT2 (int []) {25, 26, 27, 28, 29, 30, 31, 255}, 8
#define DL_COLOR_GOOP (int []) {131, 133, 135, 137, 139, 141, 143, 252, 254}, 9
#define DL_COLOR_SNAKEARR (int []) {183, 184, 185, 186, 187, 188, 189, 190, 191, 245, 246}, 11
#define DL_COLOR_ACIDSHOT (int []) {108, 109, 110, 111, 185, 186, 187, 188, 189, 190, 243, 244, 245, 246}, 14
#define MAX_EFRAGS 8192 // fx 4096 // was 2048 // orig. was 640
#define MAX_MAPSTRING 2048
#define MAX_DEMOS 8
#define MAX_DEMONAME 16
#define SIGNONS 4 // signon messages to receive before connected
typedef enum
{
ca_dedicated, // a dedicated server with no ability to start a client
ca_disconnected, // full screen console with no connection
ca_connected // valid netcon, talking to a server
} cactive_t;
//
// the client_static_t structure is persistant through an arbitrary number
// of server connections
//
typedef struct
{
cactive_t state;
// personalization data sent to server
char mapstring[MAX_QPATH];
char spawnparms[MAX_MAPSTRING]; // to restart a level
// demo loop control
int demonum; // -1 = don't play demos
char demos[MAX_DEMOS][MAX_DEMONAME]; // when not playing
// demo recording info must be here, because record is started before
// entering a map (and clearing client_state_t)
qboolean demorecording;
qboolean demoplayback;
qboolean timedemo;
int forcetrack; // -1 = use normal cd track
FILE *demofile;
FILE *introdemofile;
int td_lastframe; // to meter out one message a frame
int td_startframe; // host_framecount at start
float td_starttime; // realtime at second frame of timedemo
int stufftext_frame; // host_framecount when svc_stufftext is received
// connection information
int signon; // 0 to SIGNONS
struct qsocket_s *netcon;
sizebuf_t message; // writing buffer to send to server
} client_static_t;
extern client_static_t cls;
//
// the client_state_t structure is wiped completely at every
// server signon
//
typedef struct
{
int movemessages; // since connecting to this server
// throw out the first couple, so the player
// doesn't accidentally do something the
// first frame
usercmd_t cmd; // last command sent to the server
usercmd_t pendingcmd; // accumulated state from mice or other external controllers
// information for local display
int stats[MAX_CL_STATS]; // health, etc
int inv_order[MAX_INVENTORY];
int inv_count, inv_startpos, inv_selected;
int items; // inventory bit flags
float item_gettime[32]; // cl.time of aquiring item, for blinking
float faceanimtime; // use anim frame if cl.time < this
entvars_t v; // NOTE: not every field will be update - you must specifically add
// them in functions SV_WriteClientdatatToMessage() and CL_ParseClientdata()
cshift_t cshifts[NUM_CSHIFTS]; // color shifts for damage, powerups
cshift_t prev_cshifts[NUM_CSHIFTS]; // and content types
char puzzle_pieces[8][10]; // puzzle piece names
// the client maintains its own idea of view angles, which are
// sent to the server each frame. The server sets punchangle when
// the view is temporarliy offset, and an angle reset commands at the start
// of each level and after teleporting.
vec3_t mviewangles[2]; // during demo playback viewangles is lerped
// between these
vec3_t viewangles;
vec3_t mvelocity[2]; // update by server, used for lean+bob
// (0 is newest)
vec3_t velocity; // lerped between mvelocity[0] and [1]
vec3_t punchangle; // temporary offset
float idealroll;
float rollvel;
// pitch drifting vars
float idealpitch;
float pitchvel;
qboolean nodrift;
float driftmove;
double laststop;
float viewheight;
float crouch; // local amount for smoothing stepups
qboolean paused; // send over by server
qboolean onground;
qboolean inwater;
qboolean fixangle; // freeze view angle until next server frame
int intermission; // don't change view angle, full screen, etc
int completed_time; // latched at intermission start
double mtime[2]; // the timestamp of last two messages
double time; // clients view of time, should be between
// servertime and oldservertime to generate
// a lerp point for other data
double oldtime; // previous cl.time, time-oldtime is used
// to decay light values and smooth step ups
float last_received_message; // (realtime) for net trouble icon
//
// information that is static for the entire time connected to a server
//
struct model_s *model_precache[MAX_MODELS];
struct sfx_s *sound_precache[MAX_SOUNDS];
char worldname[MAX_QPATH];
char levelname[256]; // for display on solo scoreboard
int viewentity; // cl_entities[cl.viewentity] = player
int maxclients;
int gametype;
// refresh related state
struct model_s *worldmodel; // cl_entities[0].model
struct efrag_s *free_efrags;
int num_entities; // held in cl_entities array
int num_statics; // held in cl_staticentities array
entity_t viewent; // the gun model
struct EffectT Effects[MAX_EFFECTS];
int cdtrack, looptrack; // cd audio
char midi_name[128]; // midi file name
byte current_frame, last_frame, reference_frame;
byte current_sequence, last_sequence;
byte need_build;
// frag scoreboard
scoreboard_t *scores; // [cl.maxclients]
double last_angle_time; // JPG - for smooth chasecam
vec3_t lerpangles; // JPG - angles now used by view.c so that smooth chasecam doesn't fuck up demos
qboolean noclip_anglehack;
int protocol;
unsigned protocolflags;
// light level at player's position including dlights
// this is sent back to the server each frame
// architectually ugly but it works
int light_level;
client_frames2_t frames[3]; // 0 = base, 1 = building, 2 = 0 & 1 merged
short RemoveList[MAX_CLIENT_STATES],NumToRemove;
long info_mask, info_mask2;
} client_state_t;
//
// cvars
//
extern cvar_t cl_name;
extern cvar_t cl_color;
extern cvar_t cl_playerclass;
extern cvar_t cl_run;
extern cvar_t cl_upspeed;
extern cvar_t cl_forwardspeed;
extern cvar_t cl_sidespeed;
extern cvar_t cl_backspeed; // keep for compatibility
extern cvar_t cl_movespeedkey;
extern cvar_t cl_yawspeed;
extern cvar_t cl_pitchspeed;
extern cvar_t cl_maxpitch; // variable pitch clamping
extern cvar_t cl_minpitch; // variable pitch clamping
extern cvar_t cl_anglespeedkey;
extern cvar_t cl_shownet;
extern cvar_t cl_nolerp;
extern cvar_t cl_lerpmuzzleflash;
extern cvar_t cl_prettylights;
extern cvar_t cl_coloredlight;
extern cvar_t cl_extradlight;
extern cvar_t cl_extradlightstatic;
extern cvar_t cl_extradlighteffect;
extern cvar_t cl_pitchdriftspeed;
extern cvar_t lookspring;
extern cvar_t lookstrafe;
extern cvar_t sensitivity;
extern cvar_t m_pitch;
extern cvar_t m_yaw;
extern cvar_t m_forward;
extern cvar_t m_side;
#define MAX_TEMP_ENTITIES 512 // was 64 // lightning bolts, etc
#define MAX_STATIC_ENTITIES 4096 // fx 512 // was 128 //bjp 256 // torches, etc
extern client_state_t cl;
// FIXME, allocate dynamically
extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_entities[MAX_EDICTS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
extern dlight_t cl_dlights[MAX_DLIGHTS];
//=============================================================================
//
// cl_main.c
//
dlight_t *CL_AllocDlight (int key);
void CL_ColorDlight (dlight_t *dl, float r, float g, float b);
void CL_ColorDlightPalette (dlight_t *dl, int i);
void CL_ColorDlightPaletteLength (dlight_t *dl, int start, int length);
void CL_ColorDlightPaletteIndices (dlight_t *dl, int *indices, int count);
void CL_DecayLights (void);
void CL_Init (void);
void CL_EstablishConnection (char *host);
void CL_Signon1 (void);
void CL_Signon2 (void);
void CL_Signon3 (void);
void CL_Signon4 (void);
void CL_SignonReply (void);
void CL_Reconnect (void);
void CL_Disconnect (void);
void CL_RemoveGIPFiles (char *path);
qboolean CL_CopyFiles(char *source, char *pat, char *dest);
// bumped for new value of MAX_EDICTS
#define MAX_VISEDICTS MAX_EDICTS // was 256
extern int cl_numvisedicts;
extern entity_t *cl_visedicts[MAX_VISEDICTS];
//
// cl_input.c
//
typedef struct
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
// kbutton_t states:
// DOWN 1
// IMPULSE DOWN 2 // used for "attack" and "use" only
// IMPULSE UP 4 // not used
extern kbutton_t in_mlook, in_klook;
extern kbutton_t in_strafe;
extern kbutton_t in_speed;
extern kbutton_t in_attack; // JPG - added this for completeness
void CL_InitInput (void);
void CL_AccumulateCmd (void);
void CL_SendCmd (void);
void CL_SendMove (usercmd_t *cmd);
void CL_ClearState (void);
int CL_ReadFromServer (void);
void CL_WriteToServer (usercmd_t *cmd);
void CL_AdjustAngles (void);
void CL_BaseMove (usercmd_t *cmd);
float CL_KeyState (kbutton_t *key);
char *Key_KeynumToString (int keynum);
//
// cl_demo.c
//
void CL_NextDemo (void);
void CL_StopPlayback (void);
int CL_GetMessage (void);
void CL_Stop_f (void);
void CL_Record_f (void);
void CL_PlayDemo_f (void);
void CL_TimeDemo_f (void);
//
// cl_effect.c
//
void CL_InitEffects (void);
void CL_ClearEffects (void);
void CL_ParseEffect (void);
void CL_EndEffect (void);
//
// sv_effect.c
//
void SV_UpdateEffects(sizebuf_t *sb);
void SV_ParseEffect(sizebuf_t *sb);
//
// cl_parse.c
//
void CL_ParseServerMessage (void);
void CL_NewTranslation (int slot);
//
// view.c
//
void V_StartPitchDrift (void);
void V_StopPitchDrift (void);
void V_Register (void);
void V_ParseDamage (void);
void V_SetContentsColor (int contents);
void V_ReloadPalette (void);
//
// cl_tent.c
//
void CL_InitTEnts (void);
void CL_ClearTEnts (void);
void CL_ParseTEnt (void);
void CL_UpdateTEnts (void);
//
// chase.c
//
void TraceLine (vec3_t start, vec3_t end, vec3_t impact);