-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Structs.h
282 lines (257 loc) · 7.49 KB
/
Structs.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
// Copyright DarkNeutrino 2021
#ifndef STRUCTS_H
#define STRUCTS_H
#include "Uthash.h"
#include "enet/protocol.h"
#include <Enums.h>
#include <Queue.h>
#include <Types.h>
#include <enet/enet.h>
#include <libmapvxl/libmapvxl.h>
#include <signal.h>
#include <sys/types.h>
#include <time.h>
#define VERSION "0.1.1"
#define MAP_MAX_X MAP_X_MAX
#define MAP_MAX_Y MAP_Y_MAX
#define MAP_MAX_Z MAP_Z_MAX
//#define DEBUG
typedef union
{
uint8 ip[4];
uint32 ip32;
} IPUnion;
typedef struct
{
char accessLevel[32];
const char** accessPassword;
uint8 permLevelOffset;
} PermLevel;
typedef struct Grenade
{
uint8 sent;
float fuse;
uint8 exploded;
Vector3f position;
Vector3f velocity;
uint64 timeSinceSent;
struct Grenade *next, *prev;
} Grenade;
typedef struct
{ // Seriously what the F. Thank voxlap motion for this mess.
Vector3f position;
Vector3f prevLegitPos;
Vector3f eyePos;
Vector3f velocity;
Vector3f strafeOrientation;
Vector3f heightOrientation;
Vector3f forwardOrientation;
Vector3f previousOrientation;
} Movement;
typedef struct
{ // Yet again thanks voxlap.
Vector3f forward;
Vector3f strafe;
Vector3f height;
} Orientation;
typedef struct stringNode
{
char* string;
struct stringNode *next, *prev;
} stringNode;
typedef struct
{
uint8 mapCount;
stringNode* currentMap;
// compressed map
Queue* compressedMap;
uint32 compressedSize;
Vector3i resultLine[50];
long unsigned int mapSize;
MapVxl map;
stringNode* mapList;
} Map;
typedef struct
{
uint8 score[2];
uint8 scoreLimit;
IntelFlag intelFlags;
Vector3f intel[2];
Vector3f base[2];
uint8 playerIntelTeam[2];
uint8 intelHeld[2];
} GameModeVars;
typedef struct
{
uint8 countOfUsers;
uint8 teamUserCount[2];
//
uint8 numPlayers;
uint8 maxPlayers;
//
Color3i colorFog;
Color3i colorTeam[2];
char nameTeam[2][11];
GameMode currentGameMode;
GameModeVars gameMode;
// respawn area
Quad3D spawns[2];
uint32 inputFlags;
} Protocol;
typedef struct
{
uint64 timeSinceLastWU;
uint64 sinceLastBaseEnter;
uint64 sinceLastBaseEnterRestock;
uint64 startOfRespawnWait;
uint64 sinceLastShot;
uint64 sinceLastBlockDest;
uint64 sinceLastBlockPlac;
uint64 sinceLast3BlockDest;
uint64 sinceLastGrenadeThrown;
uint64 sinceLastWeaponInput;
uint64 sinceReloadStart;
uint64 sinceLastPrimaryWeaponInput;
uint64 sinceLastMessageForSpam;
uint64 sinceLastMessage;
uint64 sincePossibleSpadenade;
uint64 sincePeriodicMessage;
} Timers;
typedef struct
{
unsigned long long updateTime;
unsigned long long lastUpdateTime;
unsigned long long timeSinceStart;
float timeSinceStartSimulated;
} GlobalTimers;
typedef struct
{
Queue* queues;
State state;
Weapon weapon;
Team team;
Tool item;
PermLevel roleList[5]; // Change me based on the number of access levels you require
Timers timers;
WeaponDefaultClip defaultClip;
WeaponDefaultReserve defaultReserve;
uint32 kills;
uint32 deaths;
Color3i color;
char name[17];
char client;
int version_minor;
int version_major;
int version_revision;
char os_info[255];
ENetPeer* peer;
uint8 respawnTime;
Color4i toolColor;
int HP;
uint8 grenades;
uint8 blocks;
uint8 weaponReserve;
short weaponClip;
Vector3i resultLine[50];
IPUnion ipUnion;
uint8 alive;
uint8 input;
uint8 allowKilling;
uint8 allowTeamKilling;
uint16 ups;
uint8 muted;
uint8 adminMuted;
uint8 canBuild;
Grenade* grenade;
uint8 toldToMaster;
uint8 hasIntel;
uint8 isInvisible;
uint8 welcomeSent;
uint8 toRefill;
uint8 reloading;
uint64 permLevel;
uint8 spamCounter;
uint8 periodicDelayIndex;
stringNode* currentPeriodicMessage;
uint8 movForward;
uint8 movBackwards;
uint8 movLeft;
uint8 movRight;
uint8 jumping;
uint8 crouching;
uint8 sneaking;
uint8 sprinting;
uint8 primary_fire;
uint8 secondary_fire;
Vector3f locAtClick;
// Bellow this point is stuff used for calculating movement.
Movement movement;
uint8 airborne;
uint8 wade;
float lastclimb;
} Player;
typedef struct
{
// Master
ENetHost* client;
ENetPeer* peer;
ENetEvent event;
uint8 enableMasterConnection;
uint64 timeSinceLastSend;
} Master;
typedef struct
{
Player srvPlayer;
uint8 player;
uint32 commandPermissions;
uint32 argc;
char* argv[32]; // 32 roles^W commands should be more than enough for anyone
} CommandArguments;
typedef struct Command
{
char id[30];
uint8 parseArguments; // Should we even bother parsing it? Would be useful for commands whose one and only argument is a message, or which don't even have any arguments
void (*command)(void* serverP, CommandArguments arguments);
uint32 PermLevel; // 32 roles should be more then enough for anyone
char commandDesc[1024];
UT_hash_handle hh;
struct Command* next;
} Command;
// Command but with removed hash map and linked list stuff for easy managment
typedef struct
{
char id[30];
uint8 parseArguments; // Should we even bother parsing it? Would be useful for commands whose one and only argument is a message, or which don't even have any arguments
void (*command)(void* serverP, CommandArguments arguments);
uint32 PermLevel; // 32 roles should be more then enough for anyone
char commandDesc[1024];
} CommandManager;
typedef struct
{
ENetHost* host;
Player player[32];
Protocol protocol;
Master master;
uint16 port;
Map map;
GlobalTimers globalTimers;
Command* commandsMap;
Command* commandsList;
stringNode* welcomeMessages;
uint8 welcomeMessageCount;
stringNode* periodicMessages;
uint8 periodicMessageCount;
uint8* periodicDelays;
uint8 globalAK;
uint8 globalAB;
const char* managerPasswd;
const char* adminPasswd;
const char* modPasswd;
const char* guardPasswd;
const char* trustedPasswd;
char mapName[20];
char serverName[31];
char gamemodeName[7];
volatile sig_atomic_t running; // volatile keyword is required to have an access to this variable in any thread
} Server;
#endif