From e1a0d881f4c29512fe7ae383b5315e51ef6c4854 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sun, 5 Sep 2021 21:59:20 +0200 Subject: [PATCH 1/5] Update client_s --- src/Game/Structs.hpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index e64e5d09..46eb7935 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -4624,47 +4624,56 @@ namespace Game // 0 clientstate_t state; // 4 - char _pad[4]; + char __pad0[4]; // 8 int deltaMessage; // 12 - char __pad[12]; + char __pad1[12]; // 24 int outgoingSequence; // 28 - char pad[12]; + char __pad2[12]; // 40 netadr_t addr; // 60 - char pad1[1568]; + char __pad3[1568]; // 1628 char connectInfoString[1024]; // 2652 - char pad2[133192]; + char __pad4[132096]; + // 134748 + int reliableSequence; + // 134752 + int reliableAcknowledge; + // 134756 + int reliableSent; + // 134760 + char __pad5[1084]; // 135844 char name[16]; // 135860 - char pad3[12]; + char __pad6[12]; // 135872 int snapNum; // 135876 - int pad4; + int __pad7; // 135880 short ping; // 135882 - //char pad5[142390]; - char pad5[133158]; + char __pad8[133158]; // 269040 int isBot; // 269044 - char pad6[9228]; + char __pad9[9228]; // 278272 - unsigned __int64 steamid; + unsigned __int64 steamId; // 278280 - char pad7[403592]; + char __pad10[403592]; } client_t; #pragma pack(pop) + static_assert(sizeof(client_t) == 681872); + struct CModelAllocData { void* mainArray; From 15631bcec220c3b17eb41e81ebc2f579c42c613b Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 8 Sep 2021 10:05:34 +0200 Subject: [PATCH 2/5] Removed static assert --- src/Game/Structs.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 46eb7935..95a49359 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -4666,14 +4666,12 @@ namespace Game // 269044 char __pad9[9228]; // 278272 - unsigned __int64 steamId; + unsigned __int64 steamID; // 278280 char __pad10[403592]; } client_t; #pragma pack(pop) - static_assert(sizeof(client_t) == 681872); - struct CModelAllocData { void* mainArray; From 252c210156d96ed59ee04223c57f1e3410eb431c Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 8 Sep 2021 10:56:42 +0200 Subject: [PATCH 3/5] Reversed more client header in preparation for netchan fix --- src/Game/Structs.hpp | 59 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 95a49359..87d08726 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -4215,6 +4215,51 @@ namespace Game char ipx[10]; }; + struct netProfileInfo_t + { + char __pad0[0x5E0]; + }; + + static_assert(sizeof(netProfileInfo_t) == 0x5E0); + + struct netchan_t + { + // 0 + int outgoingSequence; + // 4 + netsrc_t sock; + // 8 + int dropped; + // 12 + int incomingSequence; + // 16 + netadr_t remoteAddress; + // 36 + int qport; + // 40 + int fragmentSequence; + // 44 + int fragmentLength; + // 48 + char* fragmentBuffer; + // 52 + int fragmentBufferSize; + // 56 + int unsentFragments; + // 60 + int unsentFragmentStart; + // 64 + int unsentLength; + // 68 + char* unsentBuffer; + // 72 + int unsentBufferSize; + // 76 + netProfileInfo_t prof; + }; + + static_assert(sizeof(netchan_t) == 0x62C); + struct FxEditorElemAtlas { int behavior; @@ -4630,13 +4675,11 @@ namespace Game // 12 char __pad1[12]; // 24 - int outgoingSequence; - // 28 - char __pad2[12]; - // 40 - netadr_t addr; - // 60 - char __pad3[1568]; + netchan_t netchan; + // 1604 + char __pad3[20]; + // 1624 + const char* delayDropReason; // 1628 char connectInfoString[1024]; // 2652 @@ -4672,6 +4715,8 @@ namespace Game } client_t; #pragma pack(pop) + static_assert(sizeof(client_t) == 681872); + struct CModelAllocData { void* mainArray; From 4966a647110546569bc7582dce1d1216a101f041 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 8 Sep 2021 11:19:30 +0200 Subject: [PATCH 4/5] Fix compilation --- src/Components/Modules/Bans.cpp | 4 ++-- src/Components/Modules/Bots.cpp | 2 +- src/Components/Modules/Client.cpp | 2 +- src/Components/Modules/Dedicated.cpp | 2 +- src/Components/Modules/Download.cpp | 2 +- src/Game/Functions.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index 7fdef6cb..d3f5d306 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -181,9 +181,9 @@ namespace Components Game::client_t* client = &Game::svs_clients[num]; 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); } diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 4cbbde53..7e0f16ba 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -437,7 +437,7 @@ namespace Components ucmd.rightmove = g_botai[i].right; ucmd.weapon = g_botai[i].weapon; - client->deltaMessage = client->outgoingSequence - 1; + client->deltaMessage = client->netchan.outgoingSequence - 1; Game::SV_ClientThink(client, &ucmd); } diff --git a/src/Components/Modules/Client.cpp b/src/Components/Modules/Client.cpp index 0f3e991f..4f5f9770 100644 --- a/src/Components/Modules/Client.cpp +++ b/src/Components/Modules/Client.cpp @@ -134,7 +134,7 @@ namespace Components 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) ip.erase(ip.begin() + ip.find_first_of(":"), ip.end()); // erase port Game::Scr_AddString(ip.data()); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 71e1630e..1061bba2 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -152,7 +152,7 @@ namespace Components { 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); list.append(Utils::String::VA(" %llX", strtoull(info.get("realsteamId").data(), nullptr, 16))); diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index f4c25566..d2bb9649 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -387,7 +387,7 @@ namespace Components 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; } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 0ed7b3cc..99f0b6c0 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -606,7 +606,7 @@ namespace Game { if (client->state < 5) { - Components::Network::SendCommand(client->addr, "error", reason); + Components::Network::SendCommand(client->netchan.remoteAddress, "error", reason); } SV_KickClient(client, reason.data()); From 9cb16ceabf5ee04d82921ee5b0a3b77b68a5c30d Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 8 Sep 2021 23:15:10 +0200 Subject: [PATCH 5/5] Addressed review --- src/Game/Structs.hpp | 87 ++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 63 deletions(-) diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 87d08726..ff7365ac 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -4224,37 +4224,21 @@ namespace Game struct netchan_t { - // 0 int outgoingSequence; - // 4 netsrc_t sock; - // 8 int dropped; - // 12 int incomingSequence; - // 16 netadr_t remoteAddress; - // 36 int qport; - // 40 int fragmentSequence; - // 44 int fragmentLength; - // 48 char* fragmentBuffer; - // 52 int fragmentBufferSize; - // 56 int unsentFragments; - // 60 int unsentFragmentStart; - // 64 int unsentLength; - // 68 char* unsentBuffer; - // 72 int unsentBufferSize; - // 76 netProfileInfo_t prof; }; @@ -4666,56 +4650,33 @@ namespace Game #pragma pack(push, 1) typedef struct client_s { - // 0 - clientstate_t state; - // 4 - char __pad0[4]; - // 8 - int deltaMessage; - // 12 - char __pad1[12]; - // 24 - netchan_t netchan; - // 1604 - char __pad3[20]; - // 1624 - const char* delayDropReason; - // 1628 - char connectInfoString[1024]; - // 2652 - char __pad4[132096]; - // 134748 - int reliableSequence; - // 134752 - int reliableAcknowledge; - // 134756 - int reliableSent; - // 134760 - char __pad5[1084]; - // 135844 - char name[16]; - // 135860 - char __pad6[12]; - // 135872 - int snapNum; - // 135876 - int __pad7; - // 135880 - short ping; - // 135882 - char __pad8[133158]; - // 269040 - int isBot; - // 269044 - char __pad9[9228]; - // 278272 - unsigned __int64 steamID; - // 278280 - char __pad10[403592]; + clientstate_t state; // 0 + char __pad0[4]; // 4 + int deltaMessage; // 8 + char __pad1[12]; // 12 + netchan_t netchan; // 24 + char __pad2[20]; // 1604 + const char* delayDropReason; // 1624 + char connectInfoString[1024]; // 1628 + char __pad3[132096]; // 2652 + int reliableSequence; // 134748 + int reliableAcknowledge; // 134752 + int reliableSent; // 134756 + char __pad4[1084]; // 134760 + char name[16]; // 135844 + char __pad5[12]; // 135860 + int snapNum; // 135872 + int __pad6; // 135876 + short ping; // 135880 + char __pad7[133158]; // 135882 + int isBot; // 269040 + char __pad8[9228]; // 269044 + unsigned __int64 steamID; // 278272 + char __pad9[403592]; // 278280 } client_t; #pragma pack(pop) - static_assert(sizeof(client_t) == 681872); + static_assert(sizeof(client_t) == 0xA6790); struct CModelAllocData {