forked from MinoMino/minqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quake_common.h
1690 lines (1564 loc) · 52.4 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 <[email protected]>
Copyright (C) 2022-2024 Thomas Jones <[email protected]>
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/>.
*/
#ifndef QUAKE_COMMON_H
#define QUAKE_COMMON_H
#include <stdint.h>
#include "common.h"
#include "patterns.h"
#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 compression 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_SOUNDS 256
#define MAX_LOCATIONS 64
#define MAX_CONFIGSTRINGS 1024
#define GENTITYNUM_BITS 10 // don't need to send any more
#define MAX_GENTITIES (1 << GENTITYNUM_BITS)
#define ENTITYNUM_NONE (MAX_GENTITIES - 1)
#define ENTITYNUM_WORLD (MAX_GENTITIES - 2)
#define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES - 2)
#define MAX_ITEM_MODELS 4
#define MAX_SPAWN_VARS 64
#define MAX_SPAWN_VARS_CHARS 4096
#define BODY_QUEUE_SIZE 8
// configstrings
#define CS_MUSIC 2
#define CS_MESSAGE 3 // from the map worldspawn's message field
#define CS_MOTD 4 // g_motd string for server message of the day (not used in QL)
#define CS_WARMUP 5 // server time when the match will be restarted
#define CS_SCORES1 6 // 1st place score
#define CS_SCORES2 7 // 2nd place score
#define CS_VOTE_TIME 8
#define CS_VOTE_STRING 9
#define CS_VOTE_YES 10
#define CS_VOTE_NO 11
#define CS_GAME_VERSION 12
#define CS_LEVEL_START_TIME 13 // so the timer only shows the current level
#define CS_INTERMISSION 14 // when 1, fraglimit/timelimit has been hit and intermission will start in a second or two
#define CS_ITEMS 15 // string of 0's and 1's that tell the client which items are present/to load.
#define CS_BOTINFO 16 // internal debugging stuff
#define CS_MODELS 17
#define CS_SOUNDS (CS_MODELS + MAX_MODELS) // 273
#define CS_PLAYERS (CS_SOUNDS + MAX_SOUNDS) // 529
#define CS_LOCATIONS (CS_PLAYERS + MAX_CLIENTS) // 593
#define CS_LAST_GENERIC (CS_LOCATIONS + MAX_LOCATIONS) // 657
#define CS_FLAGSTATUS 658
#define CS_SCORES1PLAYER 659 // 1st place player's name
#define CS_SCORES2PLAYER 660 // 2nd place player's name
#define CS_ROUND_WARMUP 661
#define CS_ROUND_START_TIME 662
#define CS_TEAMCOUNT_RED 663
#define CS_TEAMCOUNT_BLUE 664
#define CS_SHADERSTATE 665
#define CS_NEXTMAP 666
#define CS_PRACTICE 667
#define CS_FREECAM 668
#define CS_PAUSE_START_TIME 669 // if this is non-zero, the game is paused
#define CS_PAUSE_END_TIME 670 // 0 = pause, !0 = timeout
#define CS_TIMEOUTS_RED 671 // TOs REMAINING
#define CS_TIMEOUTS_BLUE 672
#define CS_MODEL_OVERRIDE 673
#define CS_PLAYER_CYLINDERS 674
#define CS_DEBUGFLAGS 675
#define CS_ENABLEBREATH 676
#define CS_DMGTHROUGHDEPTH 677
#define CS_AUTHOR 678 // from the map worldspawn's author field
#define CS_AUTHOR2 679
#define CS_ADVERT_DELAY 680
#define CS_PMOVEINFO 681
#define CS_ARMORINFO 682
#define CS_WEAPONINFO 683
#define CS_PLAYERINFO 684
#define CS_SCORE1STPLAYER 685 // Score of the duel player on the left
#define CS_SCORE2NDPLAYER 686 // Score of the duel player on the right
#define CS_CLIENTNUM1STPLAYER 687 // ClientNum of the duel player on the left
#define CS_CLIENTNUM2NDPLAYER 688 // ClientNum of the duel player on the right
#define CS_ATMOSEFFECT 689 // unused, was per-map rain/snow effects
#define CS_MOST_DAMAGEDEALT_PLYR 690
#define CS_MOST_ACCURATE_PLYR 691
#define CS_REDTEAMBASE 692
#define CS_BLUETEAMBASE 693
#define CS_BEST_ITEMCONTROL_PLYR 694
#define CS_MOST_VALUABLE_OFFENSIVE_PLYR 695
#define CS_MOST_VALUABLE_DEFENSIVE_PLYR 696
#define CS_MOST_VALUABLE_PLYR 697
#define CS_GENERIC_COUNT_RED 698
#define CS_GENERIC_COUNT_BLUE 699
#define CS_AD_SCORES 700
#define CS_ROUND_WINNER 701
#define CS_CUSTOM_SETTINGS 702
#define CS_ROTATIONMAPS 703
#define CS_ROTATIONVOTES 704
#define CS_DISABLE_VOTE_UI 705
#define CS_ALLREADY_TIME 706
#define CS_INFECTED_SURVIVOR_MINSPEED 707
#define CS_RACE_POINTS 708
#define CS_DISABLE_LOADOUT 709
#define CS_MATCH_GUID 710
#define CS_STARTING_WEAPONS 711
#define CS_STEAM_ID 712
#define CS_STEAM_WORKSHOP_IDS 713
#define CS_MAX 714
// 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
// angle helpers
#define ANGLE2SHORT(x) ((int)((x) * 65536 / 360) & 65535)
#define SHORT2ANGLE(x) ((x) * (360.0 / 65536))
// entity->svFlags
// the server does not know how to interpret most of the values
// in entityStates (level eType), so the game must explicitly flag
// special server behaviors
#define SVF_NOCLIENT 0x00000001 // don't send entity to clients, even if it has effects
#define SVF_CLIENTMASK 0x00000002
#define SVF_BOT 0x00000008 // set if the entity is a bot
#define SVF_BROADCAST 0x00000020 // send to all connected clients
#define SVF_PORTAL 0x00000040 // merge a second pvs at origin2 into snapshots
#define SVF_USE_CURRENT_ORIGIN 0x00000080 // entity->r.currentOrigin instead of entity->s.origin
// for link position (missiles and movers)
#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient)
#define SVF_NOSERVERINFO 0x00000200 // don't send CS_SERVERINFO updates to this client
// so that it can be updated for ping tools without
// lagging clients
#define SVF_CAPSULE 0x00000400 // use capsule for collision detection instead of bbox
#define SVF_NOTSINGLECLIENT 0x00000800 // send entity to everyone but one client
// (entityShared_t->singleClient)
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 {
KEY_SILVER = 0x0,
KEY_GOLD = 0x1,
KEY_MASTER = 0x2,
} keys_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;