[General]: Clean structs (#692)

This commit is contained in:
Edo 2023-01-02 17:04:34 +00:00 committed by GitHub
parent 165681f393
commit 9f39834090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 125 additions and 106 deletions

View File

@ -66,12 +66,12 @@ namespace Components
if (!CheatsOk(ent)) if (!CheatsOk(ent))
return; return;
ent->client->flags ^= Game::PLAYER_FLAG_NOCLIP; ent->client->flags ^= Game::PF_NOCLIP;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Debug("Noclip toggled for entity {}", entNum); Logger::Debug("Noclip toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF")); Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
}); });
Add("ufo", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params) Add("ufo", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
@ -79,12 +79,12 @@ namespace Components
if (!CheatsOk(ent)) if (!CheatsOk(ent))
return; return;
ent->client->flags ^= Game::PLAYER_FLAG_UFO; ent->client->flags ^= Game::PF_UFO;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Debug("UFO toggled for entity {}", entNum); Logger::Debug("UFO toggled for entity {}", entNum);
Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF")); Game::SV_GameSendServerCommand(entNum, Game::SV_CMD_CAN_IGNORE, VA("%c \"%s\"", 0x65, (ent->client->flags & Game::PF_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
}); });
Add("god", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params) Add("god", [](Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)

View File

@ -130,7 +130,7 @@ namespace Components
} }
} }
Game::cmd_function_t* Command::Find(const std::string& command) Game::cmd_function_s* Command::Find(const std::string& command)
{ {
auto* cmdFunction = *Game::cmd_functions; auto* cmdFunction = *Game::cmd_functions;
@ -147,9 +147,9 @@ namespace Components
return nullptr; return nullptr;
} }
Game::cmd_function_t* Command::Allocate() Game::cmd_function_s* Command::Allocate()
{ {
return Utils::Memory::GetAllocator()->allocate<Game::cmd_function_t>(); return Utils::Memory::GetAllocator()->allocate<Game::cmd_function_s>();
} }
void Command::MainCallback() void Command::MainCallback()

View File

@ -5,7 +5,7 @@ namespace Components
class Command : public Component class Command : public Component
{ {
public: public:
static_assert(sizeof(Game::cmd_function_t) == 0x18); static_assert(sizeof(Game::cmd_function_s) == 0x18);
class Params class Params
{ {
@ -49,7 +49,7 @@ namespace Components
Command() = default; Command() = default;
static Game::cmd_function_t* Allocate(); static Game::cmd_function_s* Allocate();
static void Add(const char* name, const std::function<void()>& callback); static void Add(const char* name, const std::function<void()>& callback);
static void Add(const char* name, const std::function<void(Command::Params*)>& callback); static void Add(const char* name, const std::function<void(Command::Params*)>& callback);
@ -57,7 +57,7 @@ namespace Components
static void AddSV(const char* name, const std::function<void(Command::Params*)>& callback); static void AddSV(const char* name, const std::function<void(Command::Params*)>& callback);
static void Execute(std::string command, bool sync = true); static void Execute(std::string command, bool sync = true);
static Game::cmd_function_t* Find(const std::string& command); static Game::cmd_function_s* Find(const std::string& command);
private: private:
static std::unordered_map<std::string, std::function<void(Command::Params*)>> FunctionMap; static std::unordered_map<std::string, std::function<void(Command::Params*)>> FunctionMap;

View File

@ -269,9 +269,9 @@ namespace Components
void Debug::Com_Bug_f(Command::Params* params) void Debug::Com_Bug_f(Command::Params* params)
{ {
char newFileName[0x105]{}; char newFileName[MAX_PATH]{};
char to_ospath[MAX_PATH]{}; char to_ospath[MAX_OSPATH]{};
char from_ospath[MAX_PATH]{}; char from_ospath[MAX_OSPATH]{};
const char* bug; const char* bug;
if (!*Game::logfile) if (!*Game::logfile)

View File

@ -630,7 +630,7 @@ namespace Components
{ {
const auto* ent = Scr_GetPlayerEntity(entref); const auto* ent = Scr_GetPlayerEntity(entref);
Game::Scr_AddBool((ent->client->flags & Game::PLAYER_FLAG_FROZEN) != 0); Game::Scr_AddBool((ent->client->flags & Game::PF_FROZEN) != 0);
}); });
} }

View File

@ -79,7 +79,7 @@ namespace Components
this->wasFreed = true; this->wasFreed = true;
// Unchain our searchpath // Unchain our searchpath
for (Game::searchpath_t** pathPtr = Game::fs_searchpaths; *pathPtr; pathPtr = &(*pathPtr)->next) for (auto** pathPtr = Game::fs_searchpaths; *pathPtr; pathPtr = &(*pathPtr)->next)
{ {
if (*pathPtr == &this->searchPath) if (*pathPtr == &this->searchPath)
{ {

View File

@ -43,7 +43,7 @@ namespace Components
bool wasFreed; bool wasFreed;
unsigned int hash; unsigned int hash;
std::string mapname; std::string mapname;
Game::searchpath_t searchPath; Game::searchpath_s searchPath;
}; };
Maps(); Maps();

View File

@ -29,7 +29,7 @@ namespace Game
FS_Delete_t FS_Delete = FS_Delete_t(0x48A5B0); FS_Delete_t FS_Delete = FS_Delete_t(0x48A5B0);
FS_BuildOSPath_t FS_BuildOSPath = FS_BuildOSPath_t(0x4702C0); FS_BuildOSPath_t FS_BuildOSPath = FS_BuildOSPath_t(0x4702C0);
searchpath_t** fs_searchpaths = reinterpret_cast<searchpath_t**>(0x63D96E0); searchpath_s** fs_searchpaths = reinterpret_cast<searchpath_s**>(0x63D96E0);
int FS_FOpenFileReadCurrentThread(const char* filename, int* file) int FS_FOpenFileReadCurrentThread(const char* filename, int* file)
{ {

View File

@ -80,7 +80,7 @@ namespace Game
typedef void(*FS_BuildOSPath_t)(const char* base, const char* game, const char* qpath, char* ospath); typedef void(*FS_BuildOSPath_t)(const char* base, const char* game, const char* qpath, char* ospath);
extern FS_BuildOSPath_t FS_BuildOSPath; extern FS_BuildOSPath_t FS_BuildOSPath;
extern searchpath_t** fs_searchpaths; extern searchpath_s** fs_searchpaths;
extern int FS_FOpenFileReadCurrentThread(const char* filename, int* file); extern int FS_FOpenFileReadCurrentThread(const char* filename, int* file);

View File

@ -267,7 +267,7 @@ namespace Game
CmdArgs* cmd_args = reinterpret_cast<CmdArgs*>(0x1AAC5D0); CmdArgs* cmd_args = reinterpret_cast<CmdArgs*>(0x1AAC5D0);
CmdArgs* sv_cmd_args = reinterpret_cast<CmdArgs*>(0x1ACF8A0); CmdArgs* sv_cmd_args = reinterpret_cast<CmdArgs*>(0x1ACF8A0);
cmd_function_t** cmd_functions = reinterpret_cast<cmd_function_t**>(0x1AAC658); cmd_function_s** cmd_functions = reinterpret_cast<cmd_function_s**>(0x1AAC658);
source_t** sourceFiles = reinterpret_cast<source_t**>(0x7C4A98); source_t** sourceFiles = reinterpret_cast<source_t**>(0x7C4A98);

View File

@ -51,10 +51,10 @@ namespace Game
typedef void(*CG_SetupWeaponDef_t)(int localClientNum, unsigned int weapIndex); typedef void(*CG_SetupWeaponDef_t)(int localClientNum, unsigned int weapIndex);
extern CG_SetupWeaponDef_t CG_SetupWeaponDef; extern CG_SetupWeaponDef_t CG_SetupWeaponDef;
typedef void(*Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_t* allocedCmd, int isKey); typedef void(*Cmd_AddCommand_t)(const char* cmdName, void(*function), cmd_function_s* allocedCmd, int isKey);
extern Cmd_AddCommand_t Cmd_AddCommand; extern Cmd_AddCommand_t Cmd_AddCommand;
typedef void(*Cmd_AddServerCommand_t)(const char* name, void(*callback), cmd_function_t* data); typedef void(*Cmd_AddServerCommand_t)(const char* name, void(*callback), cmd_function_s* data);
extern Cmd_AddServerCommand_t Cmd_AddServerCommand; extern Cmd_AddServerCommand_t Cmd_AddServerCommand;
typedef void(*Cmd_ExecuteSingleCommand_t)(int localClientNum, int controllerIndex, const char* cmd); typedef void(*Cmd_ExecuteSingleCommand_t)(int localClientNum, int controllerIndex, const char* cmd);
@ -610,7 +610,7 @@ namespace Game
extern CmdArgs* cmd_args; extern CmdArgs* cmd_args;
extern CmdArgs* sv_cmd_args; extern CmdArgs* sv_cmd_args;
extern cmd_function_t** cmd_functions; extern cmd_function_s** cmd_functions;
extern float* cgameFOVSensitivityScale; extern float* cgameFOVSensitivityScale;

View File

@ -4,6 +4,9 @@
#define NUM_CUSTOM_CLASSES 15 #define NUM_CUSTOM_CLASSES 15
#define FX_ELEM_FIELD_COUNT 90 #define FX_ELEM_FIELD_COUNT 90
#define MAX_QPATH 64
#define MAX_OSPATH 256
// This allows us to compile our structures in IDA, for easier reversing :3 // This allows us to compile our structures in IDA, for easier reversing :3
#ifndef __cplusplus #ifndef __cplusplus
#define IDA #define IDA
@ -614,7 +617,7 @@ namespace Game
CLASS_NUM_COUNT = 0x6, CLASS_NUM_COUNT = 0x6,
}; };
typedef enum enum hitLocation_t
{ {
HITLOC_NONE, HITLOC_NONE,
HITLOC_HELMET, HITLOC_HELMET,
@ -637,7 +640,7 @@ namespace Game
HITLOC_GUN, HITLOC_GUN,
HITLOC_SHIELD, HITLOC_SHIELD,
HITLOC_NUM HITLOC_NUM
} hitLocation_t; };
enum svscmd_type enum svscmd_type
{ {
@ -664,7 +667,7 @@ namespace Game
static_assert(sizeof(CmdArgs) == 0x84); static_assert(sizeof(CmdArgs) == 0x84);
typedef struct cmd_function_s struct cmd_function_s
{ {
cmd_function_s* next; cmd_function_s* next;
const char* name; const char* name;
@ -672,7 +675,7 @@ namespace Game
const char* autoCompleteExt; const char* autoCompleteExt;
void(__cdecl* function)(); void(__cdecl* function)();
int flags; int flags;
} cmd_function_t; };
#pragma pack(push, 4) #pragma pack(push, 4)
struct kbutton_t struct kbutton_t
@ -2096,7 +2099,7 @@ namespace Game
int extrapolatedSnapshot; int extrapolatedSnapshot;
int newSnapshots; int newSnapshots;
int serverId; int serverId;
char mapname[64]; char mapname[MAX_QPATH];
int parseEntitiesIndex; int parseEntitiesIndex;
int parseClientsIndex; int parseClientsIndex;
int mouseDx[2]; int mouseDx[2];
@ -5810,9 +5813,9 @@ namespace Game
struct iwd_t struct iwd_t
{ {
char iwdFilename[256]; char iwdFilename[MAX_OSPATH];
char iwdBasename[256]; char iwdBasename[MAX_OSPATH];
char iwdGamename[256]; char iwdGamename[MAX_OSPATH];
char* handle; char* handle;
int checksum; int checksum;
int pure_checksum; int pure_checksum;
@ -5851,12 +5854,13 @@ namespace Game
char name[256]; char name[256];
}; };
typedef struct { struct directory_t
char path[256]; // c:\quake3 {
char gamedir[256]; // baseq3 char path[MAX_OSPATH];
} directory_t; char gamedir[MAX_OSPATH];
};
typedef struct searchpath_s struct searchpath_s
{ {
searchpath_s* next; searchpath_s* next;
iwd_t* iwd; iwd_t* iwd;
@ -5865,7 +5869,7 @@ namespace Game
int ignore; int ignore;
int ignorePureCheck; int ignorePureCheck;
int language; int language;
} searchpath_t; };
struct SafeArea struct SafeArea
{ {
@ -5891,9 +5895,35 @@ namespace Game
typedef char mapname_t[40]; typedef char mapname_t[40];
struct TraceExtents
{
float midPoint[3];
float halfDelta[3];
float halfDeltaAbs[3];
float invDeltaAbs[3];
float start[3];
float end[3];
};
struct TraceCheckCount
{
int global;
int* partitions;
};
struct TraceThreadInfo
{
TraceCheckCount checkcount;
};
struct CM_WorldTraceCallbacks
{
bool(*isGlassSolid)(unsigned int);
};
struct traceWork_t struct traceWork_t
{ {
/*TraceExtents*/int extents; TraceExtents extents;
float delta[3]; float delta[3];
float deltaLen; float deltaLen;
float deltaLenSq; float deltaLenSq;
@ -5908,8 +5938,8 @@ namespace Game
float offset[3]; float offset[3];
float radiusOffset[3]; float radiusOffset[3];
float boundingRadius; float boundingRadius;
/*TraceThreadInfo*/ int threadInfo; TraceThreadInfo threadInfo;
/*CM_WorldTraceCallbacks*/ void* callbacks; CM_WorldTraceCallbacks* callbacks;
}; };
struct gameState_t struct gameState_t
@ -6583,7 +6613,7 @@ namespace Game
struct FxEditorEffectDef struct FxEditorEffectDef
{ {
char name[64]; char name[MAX_QPATH];
int elemCount; int elemCount;
FxEditorElemDef elems[32]; FxEditorElemDef elems[32];
}; };
@ -6720,29 +6750,29 @@ namespace Game
DB_ZONE_DEV = 0x40 DB_ZONE_DEV = 0x40
}; };
enum playerFlag enum
{ {
PLAYER_FLAG_NOCLIP = 1 << 0, PF_NOCLIP = 1 << 0,
PLAYER_FLAG_UFO = 1 << 1, PF_UFO = 1 << 1,
PLAYER_FLAG_FROZEN = 1 << 2, PF_FROZEN = 1 << 2,
}; };
typedef enum enum sessionState_t
{ {
SESS_STATE_PLAYING = 0x0, SESS_STATE_PLAYING = 0x0,
SESS_STATE_DEAD = 0x1, SESS_STATE_DEAD = 0x1,
SESS_STATE_SPECTATOR = 0x2, SESS_STATE_SPECTATOR = 0x2,
SESS_STATE_INTERMISSION = 0x3 SESS_STATE_INTERMISSION = 0x3
} sessionState_t; };
typedef enum enum clientConnected_t
{ {
CON_DISCONNECTED = 0x0, CON_DISCONNECTED = 0x0,
CON_CONNECTING = 0x1, CON_CONNECTING = 0x1,
CON_CONNECTED = 0x2 CON_CONNECTED = 0x2
} clientConnected_t; };
typedef enum enum visionSetMode_t
{ {
VISIONSET_NORMAL, VISIONSET_NORMAL,
VISIONSET_NIGHT, VISIONSET_NIGHT,
@ -6750,7 +6780,7 @@ namespace Game
VISIONSET_THERMAL, VISIONSET_THERMAL,
VISIONSET_PAIN, VISIONSET_PAIN,
VISIONSETCOUNT VISIONSETCOUNT
} visionSetMode_t; };
enum hintType_t enum hintType_t
{ {
@ -6959,8 +6989,8 @@ namespace Game
const char* name; const char* name;
int ofs; int ofs;
fieldtype_t type; fieldtype_t type;
void(__cdecl* setter)(gentity_s*, int); void(*setter)(gentity_s*, int);
void(__cdecl* getter)(gentity_s*, int); void(*getter)(gentity_s*, int);
}; };
struct client_fields_s struct client_fields_s
@ -6968,12 +6998,12 @@ namespace Game
const char* name; const char* name;
int ofs; int ofs;
fieldtype_t type; fieldtype_t type;
void(__cdecl* setter)(gclient_s*, const client_fields_s*); void(*setter)(gclient_s*, const client_fields_s*);
void(__cdecl* getter)(gclient_s*, const client_fields_s*); void(*getter)(gclient_s*, const client_fields_s*);
}; };
typedef void(__cdecl* ScriptCallbackEnt)(gentity_s*, int); typedef void(*ScriptCallbackEnt)(gentity_s*, int);
typedef void(__cdecl* ScriptCallbackClient)(gclient_s*, const client_fields_s*); typedef void(*ScriptCallbackClient)(gclient_s*, const client_fields_s*);
struct lockonFireParms struct lockonFireParms
{ {
@ -7098,7 +7128,7 @@ namespace Game
char serverCommands[128][1024]; char serverCommands[128][1024];
bool isServerRestarting; bool isServerRestarting;
int lastClientArchiveIndex; int lastClientArchiveIndex;
char demoName[64]; char demoName[MAX_QPATH];
int demorecording; int demorecording;
int demoplaying; int demoplaying;
int isTimeDemo; int isTimeDemo;
@ -7192,7 +7222,7 @@ namespace Game
punctuation_t* punctuations; //the punctuations used in the script punctuation_t* punctuations; //the punctuations used in the script
punctuation_t** punctuationtable; punctuation_t** punctuationtable;
token_t token; //available token token_t token; //available token
struct script_s* next; //next script in a chain script_s* next; //next script in a chain
} script_t; } script_t;
typedef struct define_s typedef struct define_s
@ -7203,8 +7233,8 @@ namespace Game
int numparms; //number of define parameters int numparms; //number of define parameters
token_t* parms; //define parameters token_t* parms; //define parameters
token_t* tokens; //macro tokens (possibly containing parm tokens) token_t* tokens; //macro tokens (possibly containing parm tokens)
struct define_s* next; //next defined macro in a list define_s* next; //next defined macro in a list
struct define_s* hashnext; //next define in the hash chain define_s* hashnext; //next define in the hash chain
} define_t; } define_t;
typedef struct indent_s typedef struct indent_s
@ -7212,13 +7242,13 @@ namespace Game
int type; //indent type int type; //indent type
int skip; //true if skipping current indent int skip; //true if skipping current indent
script_t* script; //script the indent was in script_t* script; //script the indent was in
struct indent_s* next; //next indent on the indent stack indent_s* next; //next indent on the indent stack
} indent_t; } indent_t;
typedef struct source_s typedef struct source_s
{ {
char filename[64]; //file name of the script char filename[MAX_QPATH]; //file name of the script
char includepath[64]; //path to include files char includepath[MAX_QPATH]; //path to include files
punctuation_t* punctuations; //punctuations to use punctuation_t* punctuations; //punctuations to use
script_t* scriptstack; //stack with scripts of the source script_t* scriptstack; //stack with scripts of the source
token_t* tokens; //tokens to read first token_t* tokens; //tokens to read first
@ -8958,7 +8988,7 @@ namespace Game
struct animation_s struct animation_s
{ {
char name[64]; char name[MAX_QPATH];
int initialLerp; int initialLerp;
float moveSpeed; float moveSpeed;
int duration; int duration;
@ -10387,17 +10417,6 @@ namespace Game
int index; int index;
}; };
struct TraceCheckCount
{
int global;
int* partitions;
};
struct TraceThreadInfo
{
TraceCheckCount checkcount;
};
struct ProfileAtom struct ProfileAtom
{ {
unsigned int value[1]; unsigned int value[1];