forked from MinoMino/minqlx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
quake_common.h
1586 lines (1465 loc) · 45.7 KB
/
quake_common.h
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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 1997-2001 Id Software, Inc.
Copyright (C) 2015 Mino <mino@minomino.org>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Mino: A lot of this is from Q3 sources, but obviously the structs aren't
* exactly the same, so there's a good number of modifications to make it
* fit QL. The end of the file has a bunch of stuff I added. Might want
* to refactor it. TODO.
*/
#ifndef QUAKE_COMMON_H
#define QUAKE_COMMON_H
#include <stdint.h>
#include "patterns.h"
#include "common.h"
#define CS_SCORES1 6
#define CS_SCORES2 7
#define CS_VOTE_TIME 8
#define CS_VOTE_STRING 9
#define CS_VOTE_YES 10
#define CS_VOTE_NO 11
#define CS_ITEMS 15
#define MAX_CLIENTS 64
#define MAX_CHALLENGES 1024
#define MAX_MSGLEN 16384
#define MAX_PS_EVENTS 2
#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility
#define MAX_INFO_STRING 1024
#define MAX_RELIABLE_COMMANDS 64 // max string commands buffered for restransmit
#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString
#define MAX_NAME_LENGTH 32 // max length of a client name
#define MAX_QPATH 64 // max length of a quake game pathname
#define MAX_DOWNLOAD_WINDOW 8 // max of eight download frames
#define MAX_NETNAME 36
#define PACKET_BACKUP 32 // number of old messages that must be kept on client and
// server for delta comrpession and ping estimation
#define PACKET_MASK (PACKET_BACKUP-1)
#define MAX_ENT_CLUSTERS 16
#define MAX_MODELS 256 // these are sent over the net as 8 bits
#define MAX_CONFIGSTRINGS 1024
#define GENTITYNUM_BITS 10 // don't need to send any more
#define MAX_GENTITIES (1<<GENTITYNUM_BITS)
#define MAX_ITEM_MODELS 4
#define MAX_SPAWN_VARS 64
#define MAX_SPAWN_VARS_CHARS 4096
#define BODY_QUEUE_SIZE 8
// bit field limits
#define MAX_STATS 16
#define MAX_PERSISTANT 16
#define MAX_POWERUPS 16
#define MAX_WEAPONS 16
// Button flags
#define BUTTON_ATTACK 1
#define BUTTON_TALK 2 // displays talk balloon and disables actions
#define BUTTON_USE_HOLDABLE 4 // Mino: +button2
#define BUTTON_GESTURE 8 // Mino: +button3
#define BUTTON_WALKING 16
// Block of unused button flags, or at least flags I couldn't trigger.
// Q3 used them for bot commands, so probably unused in QL.
#define BUTTON_UNUSED1 32
#define BUTTON_UNUSED2 64
#define BUTTON_UNUSED3 128
#define BUTTON_UNUSED4 256
#define BUTTON_UNUSED5 512
#define BUTTON_UNUSED6 1024
#define BUTTON_UPMOVE 2048 // Mino: Not in Q3. I'm guessing it's for cg_autohop.
#define BUTTON_ANY 4096 // any key whatsoever
#define BUTTON_IS_ACTIVE 65536 // Mino: No idea what it is, but it goes off after a while of being
// AFK, then goes on after being active for a while.
// eflags
#define EF_DEAD 0x00000001 // don't draw a foe marker over players with EF_DEAD
#define EF_TICKING 0x00000002 // used to make players play the prox mine ticking sound
#define EF_TELEPORT_BIT 0x00000004 // toggled every time the origin abruptly changes
#define EF_AWARD_EXCELLENT 0x00000008 // draw an excellent sprite
#define EF_PLAYER_EVENT 0x00000010
#define EF_BOUNCE 0x00000010 // for missiles
#define EF_BOUNCE_HALF 0x00000020 // for missiles
#define EF_AWARD_GAUNTLET 0x00000040 // draw a gauntlet sprite
#define EF_NODRAW 0x00000080 // may have an event, but no model (unspawned items)
#define EF_FIRING 0x00000100 // for lightning gun
#define EF_KAMIKAZE 0x00000200
#define EF_MOVER_STOP 0x00000400 // will push otherwise
#define EF_AWARD_CAP 0x00000800 // draw the capture sprite
#define EF_TALK 0x00001000 // draw a talk balloon
#define EF_CONNECTION 0x00002000 // draw a connection trouble sprite
#define EF_VOTED 0x00004000 // already cast a vote
#define EF_AWARD_IMPRESSIVE 0x00008000 // draw an impressive sprite
#define EF_AWARD_DEFEND 0x00010000 // draw a defend sprite
#define EF_AWARD_ASSIST 0x00020000 // draw a assist sprite
#define EF_AWARD_DENIED 0x00040000 // denied
#define EF_TEAMVOTED 0x00080000 // already cast a team vote
#define FL_DROPPED_ITEM 0x00001000
#define DAMAGE_NO_PROTECTION 0x00000008
typedef enum {qfalse, qtrue} qboolean;
typedef unsigned char byte;
typedef struct gentity_s gentity_t;
typedef struct gclient_s gclient_t;
typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4];
typedef vec_t vec5_t[5];
typedef int fileHandle_t;
// The permission levels used by QL's admin commands.
typedef enum {
PRIV_BANNED = 0xFFFFFFFF,
PRIV_NONE = 0x0,
PRIV_MOD = 0x1,
PRIV_ADMIN = 0x2,
PRIV_ROOT = 0x3,
} privileges_t;
// Vote type. As opposed to in Q3, votes are counted every frame.
typedef enum {
VOTE_NONE,
VOTE_PENDING,
VOTE_YES,
VOTE_NO,
VOTE_FORCE_PASS,
VOTE_FORCE_FAIL,
VOTE_EXPIRED
} voteState_t;
typedef enum {
CS_FREE, // can be reused for a new connection
CS_ZOMBIE, // client has been disconnected, but don't reuse
// connection for a couple seconds
CS_CONNECTED, // has been assigned to a client_t, but no gamestate yet
CS_PRIMED, // gamestate has been sent, but client hasn't sent a usercmd
CS_ACTIVE // client is fully in game
} clientState_t;
typedef enum {
PREGAME = 0x0,
ROUND_WARMUP = 0x1,
ROUND_SHUFFLE = 0x2,
ROUND_BEGUN = 0x3,
ROUND_OVER = 0x4,
POSTGAME = 0x5,
} roundStateState_t;
typedef enum {
STAT_HEALTH,
STAT_HOLDABLE_ITEM,
STAT_RUNE,
STAT_WEAPONS,
STAT_ARMOR,
STAT_BSKILL,
STAT_CLIENTS_READY,
STAT_MAX_HEALTH,
STAT_SPINUP,
STAT_FLIGHT_THRUST,
STAT_MAX_FLIGHT_FUEL,
STAT_CUR_FLIGHT_FUEL,
STAT_FLIGHT_REFUEL,
STAT_QUADKILLS,
STAT_ARMORTYPE,
STAT_KEY,
STAT_OTHER_HEALTH,
STAT_OTHER_ARMOR,
} statIndex_t;
typedef enum {
GAME_INIT, // ( int levelTime, int randomSeed, int restart );
// init and shutdown will be called every single level
// The game should call G_GET_ENTITY_TOKEN to parse through all the
// entity configuration text and spawn gentities.
GAME_SHUTDOWN, // (void);
GAME_CLIENT_CONNECT, // ( int clientNum, qboolean firstTime, qboolean isBot );
// return NULL if the client is allowed to connect, otherwise return
// a text string with the reason for denial
GAME_CLIENT_BEGIN, // ( int clientNum );
GAME_CLIENT_USERINFO_CHANGED, // ( int clientNum );
GAME_CLIENT_DISCONNECT, // ( int clientNum );
GAME_CLIENT_COMMAND, // ( int clientNum );
GAME_CLIENT_THINK, // ( int clientNum );
GAME_RUN_FRAME, // ( int levelTime );
GAME_CONSOLE_COMMAND, // ( void );
// ConsoleCommand will be called when a command has been issued
// that is not recognized as a builtin function.
// The game can issue trap_argc() / trap_argv() commands to get the command
// and parameters. Return qfalse if the game doesn't recognize it as a command.
BOTAI_START_FRAME // ( int time );
} gameExport_t;
typedef enum {
PM_NORMAL = 0x0,
PM_NOCLIP = 0x1,
PM_SPECTATOR = 0x2,
PM_DEAD = 0x3,
PM_FREEZE = 0x4,
PM_INTERMISSION = 0x5,
PM_TUTORIAL = 0x6,
} pmtype_t;
typedef enum {
EV_NONE = 0x0,
EV_FOOTSTEP = 0x1,
EV_FOOTSTEP_METAL = 0x2,
EV_FOOTSPLASH = 0x3,
EV_FOOTWADE = 0x4,
EV_SWIM = 0x5,
EV_FALL_SHORT = 0x6,
EV_FALL_MEDIUM = 0x7,
EV_FALL_FAR = 0x8,
EV_JUMP_PAD = 0x9,
EV_JUMP = 0xA,
EV_WATER_TOUCH = 0xB,
EV_WATER_LEAVE = 0xC,
EV_WATER_UNDER = 0xD,
EV_WATER_CLEAR = 0xE,
EV_ITEM_PICKUP = 0xF,
EV_GLOBAL_ITEM_PICKUP = 0x10,
EV_NOAMMO = 0x11,
EV_CHANGE_WEAPON = 0x12,
EV_DROP_WEAPON = 0x13,
EV_FIRE_WEAPON = 0x14,
EV_USE_ITEM0 = 0x15,
EV_USE_ITEM1 = 0x16,
EV_USE_ITEM2 = 0x17,
EV_USE_ITEM3 = 0x18,
EV_USE_ITEM4 = 0x19,
EV_USE_ITEM5 = 0x1A,
EV_USE_ITEM6 = 0x1B,
EV_USE_ITEM7 = 0x1C,
EV_USE_ITEM8 = 0x1D,
EV_USE_ITEM9 = 0x1E,
EV_USE_ITEM10 = 0x1F,
EV_USE_ITEM11 = 0x20,
EV_USE_ITEM12 = 0x21,
EV_USE_ITEM13 = 0x22,
EV_USE_ITEM14 = 0x23,
EV_USE_ITEM15 = 0x24,
EV_ITEM_RESPAWN = 0x25,
EV_ITEM_POP = 0x26,
EV_PLAYER_TELEPORT_IN = 0x27,
EV_PLAYER_TELEPORT_OUT = 0x28,
EV_GRENADE_BOUNCE = 0x29,
EV_GENERAL_SOUND = 0x2A,
EV_GLOBAL_SOUND = 0x2B,
EV_GLOBAL_TEAM_SOUND = 0x2C,
EV_BULLET_HIT_FLESH = 0x2D,
EV_BULLET_HIT_WALL = 0x2E,
EV_MISSILE_HIT = 0x2F,
EV_MISSILE_MISS = 0x30,
EV_MISSILE_MISS_METAL = 0x31,
EV_RAILTRAIL = 0x32,
EV_SHOTGUN = 0x33,
EV_BULLET = 0x34,
EV_PAIN = 0x35,
EV_DEATH1 = 0x36,
EV_DEATH2 = 0x37,
EV_DEATH3 = 0x38,
EV_DROWN = 0x39,
EV_OBITUARY = 0x3A,
EV_POWERUP_QUAD = 0x3B,
EV_POWERUP_BATTLESUIT = 0x3C,
EV_POWERUP_REGEN = 0x3D,
EV_POWERUP_ARMORREGEN = 0x3E,
EV_GIB_PLAYER = 0x3F,
EV_SCOREPLUM = 0x40,
EV_PROXIMITY_MINE_STICK = 0x41,
EV_PROXIMITY_MINE_TRIGGER = 0x42,
EV_KAMIKAZE = 0x43,
EV_OBELISKEXPLODE = 0x44,
EV_OBELISKPAIN = 0x45,
EV_INVUL_IMPACT = 0x46,
EV_JUICED = 0x47,
EV_LIGHTNINGBOLT = 0x48,
EV_DEBUG_LINE = 0x49,
EV_TAUNT = 0x4A,
EV_TAUNT_YES = 0x4B,
EV_TAUNT_NO = 0x4C,
EV_TAUNT_FOLLOWME = 0x4D,
EV_TAUNT_GETFLAG = 0x4E,
EV_TAUNT_GUARDBASE = 0x4F,
EV_TAUNT_PATROL = 0x50,
EV_FOOTSTEP_SNOW = 0x51,
EV_FOOTSTEP_WOOD = 0x52,
EV_ITEM_PICKUP_SPEC = 0x53,
EV_OVERTIME = 0x54,
EV_GAMEOVER = 0x55,
EV_MISSILE_MISS_DMGTHROUGH = 0x56,
EV_THAW_PLAYER = 0x57,
EV_THAW_TICK = 0x58,
EV_SHOTGUN_KILL = 0x59,
EV_POI = 0x5A,
EV_DEBUG_HITBOX = 0x5B,
EV_LIGHTNING_DISCHARGE = 0x5C,
EV_RACE_START = 0x5D,
EV_RACE_CHECKPOINT = 0x5E,
EV_RACE_FINISH = 0x5F,
EV_DAMAGEPLUM = 0x60,
EV_AWARD = 0x61,
EV_INFECTED = 0x62,
EV_NEW_HIGH_SCORE = 0x63,
EV_NUM_ETYPES = 0x64,
} entity_event_t;
typedef enum {
IT_BAD,
IT_WEAPON, // EFX: rotate + upscale + minlight
IT_AMMO, // EFX: rotate
IT_ARMOR, // EFX: rotate + minlight
IT_HEALTH, // EFX: static external sphere + rotating internal
IT_POWERUP, // instant on, timer based
// EFX: rotate + external ring that rotates
IT_HOLDABLE, // single use, holdable item
// EFX: rotate + bob
IT_PERSISTANT_POWERUP,
IT_TEAM
} itemType_t;
typedef enum {
PW_NONE = 0x0,
PW_SPAWNARMOR = 0x0,
PW_REDFLAG = 0x1,
PW_BLUEFLAG = 0x2,
PW_NEUTRALFLAG = 0x3,
PW_QUAD = 0x4,
PW_BATTLESUIT = 0x5,
PW_HASTE = 0x6,
PW_INVIS = 0x7,
PW_REGEN = 0x8,
PW_FLIGHT = 0x9,
PW_INVULNERABILITY = 0xA,
NOTPW_SCOUT = 0xB,
NOTPW_GUARD = 0xC,
NOTPW_DOUBLER = 0xD,
NOTPW_ARMORREGEN = 0xE,
PW_FREEZE = 0xF,
PW_NUM_POWERUPS = 0x10,
} powerup_t;
typedef enum {
H_NONE = 0x0,
H_MEGA = 0x1,
H_LARGE = 0x2,
H_MEDIUM = 0x3,
H_SMALL = 0x4,
H_NUM_HEALTHS = 0x5,
} healthPickup_t;
typedef enum {
HI_NONE = 0x0,
HI_TELEPORTER = 0x1,
HI_MEDKIT = 0x2,
HI_KAMIKAZE = 0x3,
HI_PORTAL = 0x4,
HI_INVULNERABILITY = 0x5,
HI_FLIGHT = 0x6,
HI_NUM_HOLDABLE = 0x7,
} holdable_t;
typedef enum {
WP_NONE = 0x0,
WP_GAUNTLET = 0x1,
WP_MACHINEGUN = 0x2,
WP_SHOTGUN = 0x3,
WP_GRENADE_LAUNCHER = 0x4,
WP_ROCKET_LAUNCHER = 0x5,
WP_LIGHTNING = 0x6,
WP_RAILGUN = 0x7,
WP_PLASMAGUN = 0x8,
WP_BFG = 0x9,
WP_GRAPPLING_HOOK = 0xA,
WP_NAILGUN = 0xB,
WP_PROX_LAUNCHER = 0xC,
WP_CHAINGUN = 0xD,
WP_HMG = 0xE,
WP_HANDS = 0xF,
WP_NUM_WEAPONS = 0x10,
} weapon_t;
typedef enum {
WEAPON_READY = 0x0,
WEAPON_RAISING = 0x1,
WEAPON_DROPPING = 0x2,
WEAPON_FIRING = 0x3,
} weaponstate_t;
typedef enum {
RUNE_NONE = 0x0,
RUNE_SCOUT = 0x1,
RUNE_GUARD = 0x2,
RUNE_DAMAGE = 0x3,
RUNE_ARMORREGEN = 0x4,
RUNE_MAX = 0x5,
} rune_t;
typedef enum {
TEAM_BEGIN, // Beginning a team game, spawn at base
TEAM_ACTIVE // Now actively playing
} playerTeamStateState_t;
typedef enum {
TEAM_FREE,
TEAM_RED,
TEAM_BLUE,
TEAM_SPECTATOR,
TEAM_NUM_TEAMS
} team_t;
// https://github.com/brugal/wolfcamql/blob/73e2d707e5dd1fb0fc50d4ad9f00940909c4b3ec/code/game/bg_public.h#L1142-L1188
// means of death
typedef enum {
MOD_UNKNOWN,
MOD_SHOTGUN,
MOD_GAUNTLET,
MOD_MACHINEGUN,
MOD_GRENADE,
MOD_GRENADE_SPLASH,
MOD_ROCKET,
MOD_ROCKET_SPLASH,
MOD_PLASMA,
MOD_PLASMA_SPLASH,
MOD_RAILGUN,
MOD_LIGHTNING,
MOD_BFG,
MOD_BFG_SPLASH,
MOD_WATER,
MOD_SLIME,
MOD_LAVA,
MOD_CRUSH,
MOD_TELEFRAG,
MOD_FALLING,
MOD_SUICIDE,
MOD_TARGET_LASER,
MOD_TRIGGER_HURT,
MOD_NAIL,
MOD_CHAINGUN,
MOD_PROXIMITY_MINE,
MOD_KAMIKAZE,
MOD_JUICED,
MOD_GRAPPLE,
MOD_SWITCH_TEAMS,
MOD_THAW,
MOD_LIGHTNING_DISCHARGE,
MOD_HMG,
MOD_RAILGUN_HEADSHOT
} meansOfDeath_t;
typedef enum {
SPECTATOR_NOT,
SPECTATOR_FREE,
SPECTATOR_FOLLOW,
SPECTATOR_SCOREBOARD
} spectatorState_t;
typedef enum {
CON_DISCONNECTED,
CON_CONNECTING,
CON_CONNECTED
} clientConnected_t;
// movers are things like doors, plats, buttons, etc
typedef enum {
MOVER_POS1,
MOVER_POS2,
MOVER_1TO2,
MOVER_2TO1
} moverState_t;
enum {
PERS_ROUND_SCORE = 0x0,
PERS_COMBOKILL_COUNT = 0x1,
PERS_RAMPAGE_COUNT = 0x2,
PERS_MIDAIR_COUNT = 0x3,
PERS_REVENGE_COUNT = 0x4,
PERS_PERFORATED_COUNT = 0x5,
PERS_HEADSHOT_COUNT = 0x6,
PERS_ACCURACY_COUNT = 0x7,
PERS_QUADGOD_COUNT = 0x8,
PERS_FIRSTFRAG_COUNT = 0x9,
PERS_PERFECT_COUNT = 0xA,
};
enum cvar_flags {
CVAR_ARCHIVE = 1,
CVAR_USERINFO = 2,
CVAR_SERVERINFO = 4,
CVAR_SYSTEMINFO = 8,
CVAR_INIT = 16,
CVAR_LATCH = 32,
CVAR_ROM = 64,
CVAR_USER_CREATED = 128,
CVAR_TEMP = 256,
CVAR_CHEAT = 512,
CVAR_NORESTART = 1024,
CVAR_UNKOWN1 = 2048,
CVAR_UNKOWN2 = 4096,
CVAR_UNKOWN3 = 8192,
CVAR_UNKOWN4 = 16384,
CVAR_UNKOWN5 = 32768,
CVAR_UNKOWN6 = 65536,
CVAR_UNKOWN7 = 131072,
CVAR_UNKOWN8 = 262144,
CVAR_UNKOWN9 = 524288,
CVAR_UNKOWN10 = 1048576
};
// paramters for command buffer stuffing
typedef enum {
EXEC_NOW, // don't return until completed, a VM should NEVER use this,
// because some commands might cause the VM to be unloaded...
EXEC_INSERT, // insert at current position, but don't run yet
EXEC_APPEND // add to end of the command buffer (normal case)
} cbufExec_t;
// Mino: Quite different from Q3. Not sure on everything.
typedef struct cvar_s {
char *name;
char *string;
char *resetString; // cvar_restart will reset to this value
char *latchedString; // for CVAR_LATCH vars
char *defaultString;
char *minimumString;
char *maximumString;
int flags;
qboolean modified;
uint8_t _unknown2[4];
int modificationCount; // incremented each time the cvar is changed
float value; // atof( string )
int integer; // atoi( string )
uint8_t _unknown3[8];
struct cvar_s *next;
struct cvar_s *hashNext;
} cvar_t;
typedef struct {
qboolean allowoverflow; // if false, do a Com_Error
qboolean overflowed; // set to true if the buffer size failed (with allowoverflow set)
qboolean oob; // set to true if the buffer size failed (with allowoverflow set)
byte *data;
int maxsize;
int cursize;
int readcount;
int bit; // for bitwise reads and writes
} msg_t;
typedef struct __attribute__((aligned(4))) usercmd_s {
int serverTime;
int angles[3];
int buttons;
byte weapon;
byte weaponPrimary;
byte fov;
char forwardmove;
char rightmove;
char upmove;
} usercmd_t;
typedef enum {
NS_CLIENT,
NS_SERVER
} netsrc_t;
typedef enum {
NA_BOT,
NA_BAD, // an address lookup failed
NA_LOOPBACK,
NA_BROADCAST,
NA_IP,
NA_IPX,
NA_BROADCAST_IPX
} netadrtype_t;
typedef enum {
TR_STATIONARY,
TR_INTERPOLATE, // non-parametric, but interpolate between snapshots
TR_LINEAR,
TR_LINEAR_STOP,
TR_SINE, // value = base + sin( time / duration ) * delta
TR_GRAVITY
} trType_t;
typedef struct {
netadrtype_t type;
byte ip[4];
byte ipx[10];
unsigned short port;
} netadr_t;
typedef struct {
netsrc_t sock;
int dropped; // between last packet and previous
netadr_t remoteAddress;
int qport; // qport value to write when transmitting
// sequencing variables
int incomingSequence;
int outgoingSequence;
// incoming fragment assembly buffer
int fragmentSequence;
int fragmentLength;
byte fragmentBuffer[MAX_MSGLEN];
// outgoing fragment buffer
// we need to space out the sending of large fragmented messages
qboolean unsentFragments;
int unsentFragmentStart;
int unsentLength;
byte unsentBuffer[MAX_MSGLEN];
} netchan_t;
typedef struct cplane_s {
vec3_t normal;
float dist;
byte type;
byte signbits;
byte pad[2];
} cplane_t;
// a trace is returned when a box is swept through the world
typedef struct {
qboolean allsolid;
qboolean startsolid;
float fraction;
vec3_t endpos;
cplane_t plane;
int surfaceFlags;
int contents;
int entityNum;
} trace_t;
// playerState_t is a full superset of entityState_t as it is used by players,
// so if a playerState_t is transmitted, the entityState_t can be fully derived
// from it.
typedef struct playerState_s {
int commandTime;
int pm_type;
int bobCycle;
int pm_flags;
int pm_time;
vec3_t origin;
vec3_t velocity;
int weaponTime;
int gravity;
int speed;
int delta_angles[3];
int groundEntityNum;
int legsTimer;
int legsAnim;
int torsoTimer;
int torsoAnim;
int movementDir;
vec3_t grapplePoint;
int eFlags;
int eventSequence;
int events[2];
int eventParms[2];
int externalEvent;
int externalEventParm;
int clientNum;
int location;
int weapon;
int weaponPrimary;
int weaponstate;
int fov;
vec3_t viewangles;
int viewheight;
int damageEvent;
int damageYaw;
int damagePitch;
int damageCount;
int stats[16];
int persistant[16];
int powerups[16];
int ammo[16];
int generic1;
int loopSound;
int jumppad_ent;
int jumpTime;
int doubleJumped;
int crouchTime;
int crouchSlideTime;
char forwardmove;
char rightmove;
char upmove;
int ping;
int pmove_framecount;
int jumppad_frame;
int entityEventSequence;
int freezetime;
int thawtime;
int thawClientNum_valid;
int thawClientNum;
int respawnTime;
int localPersistant[16];
int roundDamage;
int roundShots;
int roundHits;
} playerState_t;
typedef struct __attribute__((aligned(8))) {
playerState_t *ps;
usercmd_t cmd;
int tracemask;
int debugLevel;
int noFootsteps;
qboolean gauntletHit;
int numtouch;
int touchents[32];
vec3_t mins;
vec3_t maxs;
int watertype;
int waterlevel;
float xyspeed;
float stepHeight;
int stepTime;
void (*trace)(trace_t *, const vec_t *, const vec_t *, const vec_t *, const vec_t *, int, int);
int (*pointcontents)(const vec_t *, int);
qboolean hookEnemy;
} pmove_t;
typedef struct {
int areabytes;
byte areabits[MAX_MAP_AREA_BYTES]; // portalarea visibility bits
playerState_t ps;
int num_entities;
int first_entity; // into the circular sv_packet_entities[]
// the entities MUST be in increasing state number
// order, otherwise the delta compression will fail
int messageSent; // time the message was transmitted
int messageAcked; // time the message was acked
int messageSize; // used to rate drop packets
} clientSnapshot_t;
typedef struct netchan_buffer_s {
msg_t msg;
byte msgBuffer[MAX_MSGLEN];
struct netchan_buffer_s *next;
} netchan_buffer_t;
typedef struct {
trType_t trType;
int trTime;
int trDuration;
vec3_t trBase;
vec3_t trDelta;
float gravity;
} trajectory_t;
typedef struct entityState_s {
int number;
int eType;
int eFlags;
trajectory_t pos;
trajectory_t apos;
int time;
int time2;
vec3_t origin;
vec3_t origin2;
vec3_t angles;
vec3_t angles2;
int otherEntityNum;
int otherEntityNum2;
int groundEntityNum;
int constantLight;
int loopSound;
int modelindex;
int modelindex2;
int clientNum;
int frame;
int solid;
int event;
int eventParm;
int powerups;
int health;
int armor;
int weapon;
int location;
int legsAnim;
int torsoAnim;
int generic1;
int jumpTime;
int doubleJumped;
} entityState_t;
typedef struct {
entityState_t s;
qboolean linked;
int linkcount;
int svFlags;
int singleClient;
qboolean bmodel;
vec3_t mins;
vec3_t maxs;
int contents;
vec3_t absmin;
vec3_t absmax;
vec3_t currentOrigin;
vec3_t currentAngles;
int ownerNum;
} entityShared_t;
typedef struct {
entityState_t s; // communicated by server to clients
entityShared_t r; // shared by both the server system and game
} sharedEntity_t;
typedef struct client_s {
clientState_t state;
char userinfo[MAX_INFO_STRING]; // name, etc
char reliableCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS];
int reliableSequence; // last added reliable message, not necesarily sent or acknowledged yet
int reliableAcknowledge; // last acknowledged reliable message
int reliableSent; // last sent reliable message, not necesarily acknowledged yet
int messageAcknowledge;
int gamestateMessageNum; // netchan->outgoingSequence of gamestate
int challenge;
usercmd_t lastUsercmd;
int lastMessageNum; // for delta compression
int lastClientCommand; // reliable client message sequence
char lastClientCommandString[MAX_STRING_CHARS];
sharedEntity_t *gentity; // SV_GentityNum(clientnum)
char name[MAX_NAME_LENGTH]; // extracted from userinfo, high bits masked
// Mino: I think everything above this is correct. Below is a mess.
// downloading
char downloadName[MAX_QPATH]; // if not empty string, we are downloading
fileHandle_t download; // file being downloaded
int downloadSize; // total bytes (can't use EOF because of paks)
int downloadCount; // bytes sent
int downloadClientBlock; // last block we sent to the client, awaiting ack
int downloadCurrentBlock; // current block number
int downloadXmitBlock; // last block we xmited
unsigned char *downloadBlocks[MAX_DOWNLOAD_WINDOW]; // the buffers for the download blocks
int downloadBlockSize[MAX_DOWNLOAD_WINDOW];
qboolean downloadEOF; // We have sent the EOF block
int downloadSendTime; // time we last got an ack from the client
int deltaMessage; // frame last client usercmd message
int nextReliableTime; // svs.time when another reliable command will be allowed
int lastPacketTime; // svs.time when packet was last received
int lastConnectTime; // svs.time when connection started
int nextSnapshotTime; // send another snapshot when svs.time >= nextSnapshotTime
qboolean rateDelayed; // true if nextSnapshotTime was set based on rate instead of snapshotMsec
int timeoutCount; // must timeout a few frames in a row so debugging doesn't break
clientSnapshot_t frames[PACKET_BACKUP]; // updates can be delta'd from here
int ping;
int rate; // bytes / second
int snapshotMsec; // requests a snapshot every snapshotMsec unless rate choked
int pureAuthentic;
qboolean gotCP; // TTimo - additional flag to distinguish between a bad pure checksum, and no cp command at all
netchan_t netchan;
netchan_buffer_t *netchan_start_queue;
netchan_buffer_t **netchan_end_queue;
// Mino: Holy crap. A bunch of data was added. I have no idea where it actually goes,
// but this will at least correct sizeof(client_t).
#if defined(__x86_64__) || defined(_M_X64)
uint8_t _unknown2[36808];
#elif defined(__i386) || defined(_M_IX86)
uint8_t _unknown2[36836]; // TODO: Outdated.
#endif
// Mino: Woohoo! How nice of them to put the SteamID last.
uint64_t steam_id;
} client_t;
//
// SERVER
//
typedef struct {
netadr_t adr;
int challenge;
int time; // time the last packet was sent to the autherize server
int pingTime; // time the challenge response was sent to client
int firstTime; // time the adr was first used, for authorize timeout checks
qboolean connected;
} challenge_t;
// this structure will be cleared only when the game dll changes
typedef struct {
qboolean initialized; // sv_init has completed
int time; // will be strictly increasing across level changes
int snapFlagServerBit; // ^= SNAPFLAG_SERVERCOUNT every SV_SpawnServer()
client_t *clients; // [sv_maxclients->integer];
int numSnapshotEntities; // sv_maxclients->integer*PACKET_BACKUP*MAX_PACKET_ENTITIES
int nextSnapshotEntities; // next snapshotEntities to use
entityState_t *snapshotEntities; // [numSnapshotEntities]
int nextHeartbeatTime;
challenge_t challenges[MAX_CHALLENGES]; // to prevent invalid IPs from connecting
netadr_t redirectAddress; // for rcon return messages
netadr_t authorizeAddress; // for rcon return messages
} serverStatic_t;
typedef struct svEntity_s {
struct worldSector_s *worldSector;
struct svEntity_s *nextEntityInWorldSector;
entityState_t baseline; // for delta compression of initial sighting
int numClusters; // if -1, use headnode instead
int clusternums[MAX_ENT_CLUSTERS];
int lastCluster; // if all the clusters don't fit in clusternums
int areanum, areanum2;
int snapshotCounter; // used to prevent double adding from portal views
} svEntity_t;
typedef struct worldSector_s {
int axis; // -1 = leaf node
float dist;
struct worldSector_s *children[2];
svEntity_t *entities;
} worldSector_t;
typedef enum {
SS_DEAD, // no map loaded
SS_LOADING, // spawning level entities
SS_GAME // actively running
} serverState_t;
typedef struct {
serverState_t state;
qboolean restarting; // if true, send configstring changes during SS_LOADING
int serverId; // changes each server start
int restartedServerId; // serverId before a map_restart
int checksumFeed; // the feed key that we use to compute the pure checksum strings
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=475
// the serverId associated with the current checksumFeed (always <= serverId)
int checksumFeedServerId;
int snapshotCounter; // incremented for each snapshot built
int timeResidual; // <= 1000 / sv_frame->value
int nextFrameTime; // when time > nextFrameTime, process world
struct cmodel_s *models[MAX_MODELS];
char *configstrings[MAX_CONFIGSTRINGS];
svEntity_t svEntities[MAX_GENTITIES];
char *entityParsePoint; // used during game VM init
// the game virtual machine will update these on init and changes
sharedEntity_t *gentities;
int gentitySize;
int num_entities; // current number, <= MAX_GENTITIES
playerState_t *gameClients;
int gameClientSize; // will be > sizeof(playerState_t) due to game private data
int restartTime;
} server_t;
typedef struct {
playerTeamStateState_t state;
int captures;
int basedefense;
int carrierdefense;
int flagrecovery;
int fragcarrier;
int assists;