Merge branch 'develop' into feature/xinput

This commit is contained in:
Edo 2021-09-09 10:39:59 +02:00 committed by GitHub
commit 035b7f19d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 114 additions and 89 deletions

View File

@ -181,9 +181,9 @@ namespace Components
Game::client_t* client = &Game::svs_clients[num]; Game::client_t* client = &Game::svs_clients[num];
SteamID guid; SteamID guid;
guid.bits = client->steamid; guid.bits = client->steamID;
Bans::InsertBan({ guid, client->addr.ip }); Bans::InsertBan({ guid, client->netchan.remoteAddress.ip });
Game::SV_KickClientError(client, reason); Game::SV_KickClientError(client, reason);
} }

View File

@ -437,7 +437,7 @@ namespace Components
ucmd.rightmove = g_botai[i].right; ucmd.rightmove = g_botai[i].right;
ucmd.weapon = g_botai[i].weapon; ucmd.weapon = g_botai[i].weapon;
client->deltaMessage = client->outgoingSequence - 1; client->deltaMessage = client->netchan.outgoingSequence - 1;
Game::SV_ClientThink(client, &ucmd); Game::SV_ClientThink(client, &ucmd);
} }

View File

@ -134,7 +134,7 @@ namespace Components
if (client->state >= 3) if (client->state >= 3)
{ {
std::string ip = Game::NET_AdrToString(client->addr); std::string ip = Game::NET_AdrToString(client->netchan.remoteAddress);
if (ip.find_first_of(":") != std::string::npos) if (ip.find_first_of(":") != std::string::npos)
ip.erase(ip.begin() + ip.find_first_of(":"), ip.end()); // erase port ip.erase(ip.begin() + ip.find_first_of(":"), ip.end()); // erase port
Game::Scr_AddString(ip.data()); Game::Scr_AddString(ip.data());

View File

@ -177,7 +177,7 @@ namespace Components
{ {
if (Game::svs_clients[i].state >= 3) if (Game::svs_clients[i].state >= 3)
{ {
list.append(Utils::String::VA(" %llX", Game::svs_clients[i].steamid)); list.append(Utils::String::VA(" %llX", Game::svs_clients[i].steamID));
Utils::InfoString info(Game::svs_clients[i].connectInfoString); Utils::InfoString info(Game::svs_clients[i].connectInfoString);
list.append(Utils::String::VA(" %llX", strtoull(info.get("realsteamId").data(), nullptr, 16))); list.append(Utils::String::VA(" %llX", strtoull(info.get("realsteamId").data(), nullptr, 16)));
@ -218,7 +218,7 @@ namespace Components
{ {
if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>()) if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>())
{ {
Dvar::Var("sv_dontrotate").setRaw(0); Dvar::Var("sv_dontrotate").set(0);
return; return;
} }

View File

@ -387,7 +387,7 @@ namespace Components
if (client->state >= 3) if (client->state >= 3)
{ {
if (address.getIP().full == Network::Address(client->addr).getIP().full) if (address.getIP().full == Network::Address(client->netchan.remoteAddress).getIP().full)
{ {
return client; return client;
} }

View File

@ -20,6 +20,7 @@ namespace Components
{ {
return this->dvar; return this->dvar;
} }
template <> char* Dvar::Var::get() template <> char* Dvar::Var::get()
{ {
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING && this->dvar->current.string) if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING && this->dvar->current.string)
@ -29,10 +30,12 @@ namespace Components
return const_cast<char*>(""); return const_cast<char*>("");
} }
template <> const char* Dvar::Var::get() template <> const char* Dvar::Var::get()
{ {
return this->get<char*>(); return this->get<char*>();
} }
template <> int Dvar::Var::get() template <> int Dvar::Var::get()
{ {
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT) if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT)
@ -42,10 +45,12 @@ namespace Components
return 0; return 0;
} }
template <> unsigned int Dvar::Var::get() template <> unsigned int Dvar::Var::get()
{ {
return static_cast<unsigned int>(this->get<int>()); return static_cast<unsigned int>(this->get<int>());
} }
template <> float Dvar::Var::get() template <> float Dvar::Var::get()
{ {
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT) if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT)
@ -55,6 +60,7 @@ namespace Components
return 0; return 0;
} }
template <> float* Dvar::Var::get() template <> float* Dvar::Var::get()
{ {
static float val[4] = { 0 }; static float val[4] = { 0 };
@ -66,6 +72,7 @@ namespace Components
return val; return val;
} }
template <> bool Dvar::Var::get() template <> bool Dvar::Var::get()
{ {
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL) if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL)
@ -75,6 +82,7 @@ namespace Components
return false; return false;
} }
template <> std::string Dvar::Var::get() template <> std::string Dvar::Var::get()
{ {
return this->get<const char*>(); return this->get<const char*>();
@ -84,57 +92,46 @@ namespace Components
{ {
this->set(const_cast<const char*>(string)); this->set(const_cast<const char*>(string));
} }
void Dvar::Var::set(const char* string) void Dvar::Var::set(const char* string)
{ {
if (this->dvar && this->dvar->name) assert(this->dvar->type == Game::DVAR_TYPE_STRING);
if (this->dvar)
{ {
Game::Dvar_SetCommand(this->dvar->name, string); Game::Dvar_SetString(this->dvar, string);
} }
} }
void Dvar::Var::set(const std::string& string) void Dvar::Var::set(const std::string& string)
{ {
this->set(string.data()); this->set(string.data());
} }
void Dvar::Var::set(int integer) void Dvar::Var::set(int integer)
{ {
if (this->dvar && this->dvar->name) assert(this->dvar->type == Game::DVAR_TYPE_INT);
if (this->dvar)
{ {
Game::Dvar_SetCommand(this->dvar->name, Utils::String::VA("%i", integer)); Game::Dvar_SetInt(this->dvar, integer);
} }
} }
void Dvar::Var::set(float value) void Dvar::Var::set(float value)
{ {
if (this->dvar && this->dvar->name) assert(this->dvar->type == Game::DVAR_TYPE_FLOAT);
{
Game::Dvar_SetCommand(this->dvar->name, Utils::String::VA("%f", value));
}
}
void Dvar::Var::setRaw(int integer)
{
if (this->dvar) if (this->dvar)
{ {
this->dvar->current.integer = integer; Game::Dvar_SetFloat(this->dvar, value);
this->dvar->latched.integer = integer;
} }
} }
void Dvar::Var::setRaw(float value) void Dvar::Var::set(bool enabled)
{ {
assert(this->dvar->type == Game::DVAR_TYPE_BOOL);
if (this->dvar) if (this->dvar)
{ {
this->dvar->current.value = value; Game::Dvar_SetBool(this->dvar, enabled);
this->dvar->latched.value = value;
}
}
void Dvar::Var::setRaw(bool value)
{
if (this->dvar)
{
this->dvar->current.enabled = value;
this->dvar->latched.enabled = value;
} }
} }
@ -142,14 +139,17 @@ namespace Components
{ {
return Game::Dvar_RegisterBool(name, value, flag.val, description); return Game::Dvar_RegisterBool(name, value, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterString(name, value, flag.val, description); return Game::Dvar_RegisterString(name, value, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description);

View File

@ -31,11 +31,7 @@ namespace Components
void set(int integer); void set(int integer);
void set(float value); void set(float value);
void set(bool enabled);
// TODO: Add others
void setRaw(int integer);
void setRaw(float value);
void setRaw(bool value);
private: private:
Game::dvar_t* dvar; Game::dvar_t* dvar;

View File

@ -22,7 +22,7 @@ namespace Components
{ {
if (!Game::CL_IsCgameInitialized()) if (!Game::CL_IsCgameInitialized())
{ {
Dvar::Var("com_timescale").setRaw(1.0f); Dvar::Var("com_timescale").set(1.0f);
} }
}); });

View File

@ -560,7 +560,7 @@ namespace Components
} }
hasDlc.push_back(hasAllMaps); hasDlc.push_back(hasAllMaps);
Dvar::Var(Utils::String::VA("isDlcInstalled_%d", pack.index)).setRaw(hasAllMaps ? 1 : 0); Dvar::Var(Utils::String::VA("isDlcInstalled_%d", pack.index)).set(hasAllMaps ? 1 : 0);
} }
// Must have all of dlc 3 to 5 or it causes issues // Must have all of dlc 3 to 5 or it causes issues
@ -571,7 +571,7 @@ namespace Components
sentMessage = true; sentMessage = true;
} }
Dvar::Var("isDlcInstalled_All").setRaw(hasAllDlcs ? 1 : 0); Dvar::Var("isDlcInstalled_All").set(hasAllDlcs ? 1 : 0);
} }
bool Maps::IsCustomMap() bool Maps::IsCustomMap()

View File

@ -289,6 +289,10 @@ namespace Game
Dvar_SetFromStringByName_t Dvar_SetFromStringByName = Dvar_SetFromStringByName_t(0x4F52E0); Dvar_SetFromStringByName_t Dvar_SetFromStringByName = Dvar_SetFromStringByName_t(0x4F52E0);
Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource = Dvar_SetFromStringByNameFromSource_t(0x4FC770); Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource = Dvar_SetFromStringByNameFromSource_t(0x4FC770);
Dvar_SetStringByName_t Dvar_SetStringByName = Dvar_SetStringByName_t(0x44F060); Dvar_SetStringByName_t Dvar_SetStringByName = Dvar_SetStringByName_t(0x44F060);
Dvar_SetString_t Dvar_SetString = Dvar_SetString_t(0x4A9580);
Dvar_SetBool_t Dvar_SetBool = Dvar_SetBool_t(0x4A9510);
Dvar_SetFloat_t Dvar_SetFloat = Dvar_SetFloat_t(0x40BB20);
Dvar_SetInt_t Dvar_SetInt = Dvar_SetInt_t(0x421DA0);
SL_ConvertToString_t SL_ConvertToString = SL_ConvertToString_t(0x4EC1D0); SL_ConvertToString_t SL_ConvertToString = SL_ConvertToString_t(0x4EC1D0);
SL_GetString_t SL_GetString = SL_GetString_t(0x4CDC10); SL_GetString_t SL_GetString = SL_GetString_t(0x4CDC10);
@ -634,7 +638,7 @@ namespace Game
{ {
if (client->state < 5) if (client->state < 5)
{ {
Components::Network::SendCommand(client->addr, "error", reason); Components::Network::SendCommand(client->netchan.remoteAddress, "error", reason);
} }
SV_KickClient(client, reason.data()); SV_KickClient(client, reason.data());

View File

@ -262,6 +262,18 @@ namespace Game
typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value); typedef void (__cdecl * Dvar_SetStringByName_t)(const char* cvar, const char* value);
extern Dvar_SetStringByName_t Dvar_SetStringByName; extern Dvar_SetStringByName_t Dvar_SetStringByName;
typedef void (__cdecl * Dvar_SetString_t)(dvar_t* cvar, const char* value);
extern Dvar_SetString_t Dvar_SetString;
typedef void (__cdecl * Dvar_SetBool_t)(dvar_t* cvar, bool enabled);
extern Dvar_SetBool_t Dvar_SetBool;
typedef void (__cdecl * Dvar_SetFloat_t)(dvar_t* cvar, float value);
extern Dvar_SetFloat_t Dvar_SetFloat;
typedef void (__cdecl * Dvar_SetInt_t)(dvar_t* cvar, int integer);
extern Dvar_SetInt_t Dvar_SetInt;
typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color); typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color);
extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName; extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName;

View File

@ -74,7 +74,7 @@ namespace Game
ASSET_TYPE_INVALID = -1, ASSET_TYPE_INVALID = -1,
}; };
typedef enum typedef enum : unsigned int
{ {
DVAR_FLAG_NONE = 0x0, //no flags DVAR_FLAG_NONE = 0x0, //no flags
DVAR_FLAG_SAVED = 0x1, //saves in config_mp.cfg for clients DVAR_FLAG_SAVED = 0x1, //saves in config_mp.cfg for clients
@ -152,7 +152,7 @@ namespace Game
DVAR_SOURCE_DEVGUI = 0x3, DVAR_SOURCE_DEVGUI = 0x3,
}; };
typedef enum typedef enum : char
{ {
DVAR_TYPE_BOOL = 0x0, DVAR_TYPE_BOOL = 0x0,
DVAR_TYPE_FLOAT = 0x1, DVAR_TYPE_FLOAT = 0x1,
@ -3212,7 +3212,7 @@ namespace Game
const char *name; const char *name;
const char *description; const char *description;
unsigned int flags; unsigned int flags;
char type; dvar_type type;
bool modified; bool modified;
DvarValue current; DvarValue current;
DvarValue latched; DvarValue latched;
@ -5015,6 +5015,35 @@ namespace Game
char ipx[10]; char ipx[10];
}; };
struct netProfileInfo_t
{
char __pad0[0x5E0];
};
static_assert(sizeof(netProfileInfo_t) == 0x5E0);
struct netchan_t
{
int outgoingSequence;
netsrc_t sock;
int dropped;
int incomingSequence;
netadr_t remoteAddress;
int qport;
int fragmentSequence;
int fragmentLength;
char* fragmentBuffer;
int fragmentBufferSize;
int unsentFragments;
int unsentFragmentStart;
int unsentLength;
char* unsentBuffer;
int unsentBufferSize;
netProfileInfo_t prof;
};
static_assert(sizeof(netchan_t) == 0x62C);
struct FxEditorElemAtlas struct FxEditorElemAtlas
{ {
int behavior; int behavior;
@ -5376,50 +5405,34 @@ namespace Game
#pragma pack(push, 1) #pragma pack(push, 1)
typedef struct client_s typedef struct client_s
{ {
// 0 clientstate_t state; // 0
clientstate_t state; char __pad0[4]; // 4
// 4 int deltaMessage; // 8
char _pad[4]; char __pad1[12]; // 12
// 8 netchan_t netchan; // 24
int deltaMessage; char __pad2[20]; // 1604
// 12 const char* delayDropReason; // 1624
char __pad[12]; char connectInfoString[1024]; // 1628
// 24 char __pad3[132096]; // 2652
int outgoingSequence; int reliableSequence; // 134748
// 28 int reliableAcknowledge; // 134752
char pad[12]; int reliableSent; // 134756
// 40 char __pad4[1084]; // 134760
netadr_t addr; char name[16]; // 135844
// 60 char __pad5[12]; // 135860
char pad1[1568]; int snapNum; // 135872
// 1628 int __pad6; // 135876
char connectInfoString[1024]; short ping; // 135880
// 2652 char __pad7[133158]; // 135882
char pad2[133192]; int isBot; // 269040
// 135844 char __pad8[9228]; // 269044
char name[16]; unsigned __int64 steamID; // 278272
// 135860 char __pad9[403592]; // 278280
char pad3[12];
// 135872
int snapNum;
// 135876
int pad4;
// 135880
short ping;
// 135882
//char pad5[142390];
char pad5[133158];
// 269040
int isBot;
// 269044
char pad6[9228];
// 278272
unsigned __int64 steamid;
// 278280
char pad7[403592];
} client_t; } client_t;
#pragma pack(pop) #pragma pack(pop)
static_assert(sizeof(client_t) == 0xA6790);
struct CModelAllocData struct CModelAllocData
{ {
void* mainArray; void* mainArray;