From 6276ef2e24c147226b796cb19b9cd0c2f19e7de9 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sat, 20 Aug 2022 12:30:34 +0200 Subject: [PATCH] [Structs] Complete client_t --- src/Components/Modules/Bots.cpp | 3 +- src/Components/Modules/Chat.cpp | 2 + src/Components/Modules/Download.cpp | 4 +- .../Modules/GSC/ScriptExtension.cpp | 2 +- src/Components/Modules/SlowMotion.cpp | 2 +- src/Game/Functions.hpp | 2 +- src/Game/Structs.hpp | 58 ++++++++++++++----- 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index 72c3836b..57a334dc 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -294,7 +294,8 @@ namespace Components Bots::Bots() { - AssertOffset(Game::client_s, bIsTestClient, 0x41AF0); + AssertOffset(Game::client_t, bIsTestClient, 0x41AF0); + AssertOffset(Game::client_t, ping, 0x212C8); // Replace connect string Utils::Hook::Set(0x48ADA6, "connect bot%d \"\\cg_predictItems\\1\\cl_anonymous\\0\\color\\4\\head\\default\\model\\multi\\snaps\\20\\rate\\5000\\name\\%s\\protocol\\%d\\checksum\\%d\\statver\\%d %u\\qport\\%d\""); diff --git a/src/Components/Modules/Chat.cpp b/src/Components/Modules/Chat.cpp index 087d32ed..b2fe70c4 100644 --- a/src/Components/Modules/Chat.cpp +++ b/src/Components/Modules/Chat.cpp @@ -410,6 +410,8 @@ namespace Components Chat::Chat() { + AssertOffset(Game::client_t, steamID, 0x43F00); + cg_chatWidth = Dvar::Register("cg_chatWidth", 52, 1, std::numeric_limits::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message"); sv_disableChat = Dvar::Register("sv_disableChat", false, Game::DVAR_NONE, "Disable chat messages from clients"); Events::OnSVInit(AddChatCommands); diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index d48b1cda..7561cfe8 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -761,13 +761,13 @@ namespace Components else { // Score and ping are irrelevant - const char* namePtr = Game::PartyHost_GetMemberName(reinterpret_cast(0x1081C00), i); + const char* namePtr = Game::PartyHost_GetMemberName(Game::g_lobbyData, i); if (!namePtr || !namePtr[0]) continue; playerInfo["name"] = namePtr; } - players.push_back(playerInfo); + players.emplace_back(playerInfo); } info["players"] = players; diff --git a/src/Components/Modules/GSC/ScriptExtension.cpp b/src/Components/Modules/GSC/ScriptExtension.cpp index 3953bc47..e3c5cbae 100644 --- a/src/Components/Modules/GSC/ScriptExtension.cpp +++ b/src/Components/Modules/GSC/ScriptExtension.cpp @@ -276,7 +276,7 @@ namespace Components const auto* ent = Game::GetPlayerEntity(entref); auto* client = Script::GetClient(ent); - client->ping = static_cast(ping); + client->ping = ping; }); } diff --git a/src/Components/Modules/SlowMotion.cpp b/src/Components/Modules/SlowMotion.cpp index b1247bd9..4c403705 100644 --- a/src/Components/Modules/SlowMotion.cpp +++ b/src/Components/Modules/SlowMotion.cpp @@ -70,7 +70,7 @@ namespace Components // set snapshot num to 1 behind (T6 does this, why shouldn't we?) for (int i = 0; i < *Game::svs_clientCount; ++i) { - Game::svs_clients[i].snapNum = *Game::svs_time - 1; + Game::svs_clients[i].nextSnapshotTime = *Game::svs_time - 1; } } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 332062e9..e8e1272d 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -954,7 +954,7 @@ namespace Game typedef bool(__cdecl * SV_Loaded_t)(); extern SV_Loaded_t SV_Loaded; - typedef void(__cdecl * SV_ClientThink_t)(client_s*, usercmd_s*); + typedef void(__cdecl * SV_ClientThink_t)(client_t* cl, usercmd_s* cmd); extern SV_ClientThink_t SV_ClientThink; typedef void(__cdecl * SV_DropClient_t)(client_t* drop, const char* reason, bool tellThem); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 85c6305b..53da9032 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -6317,14 +6317,34 @@ namespace Game static_assert(sizeof(clientHeader_t) == 1624); -#pragma pack(push, 1) + struct svscmd_info_t + { + char cmd[1024]; + int time; + int type; + }; - typedef struct client_s + struct clientSnapshot_t + { + playerState_s ps; + int num_entities; + int num_clients; + int first_entity; + int first_client; + int messageSent; + int messageAcked; + int messageSize; + int serverTime; + int timeDelta; + int baselineSnap; + }; + + struct client_t { clientHeader_t header; const char* dropReason; // 1624 char userinfo[1024]; // 1628 - char __pad3[132096]; // 2652 + svscmd_info_t reliableCommandInfo[128]; // 2652 int reliableSequence; // 134748 int reliableAcknowledge; // 134752 int reliableSent; // 134756 @@ -6339,21 +6359,31 @@ namespace Game int nextReliableTime; // 135860 int lastPacketTime; // 135864 int lastConnectTime; // 135868 - int snapNum; // 135872 - int __pad5; // 135876 - short ping; // 135880 - char __pad6[14]; // 135882 + int nextSnapshotTime; // 135872 + int timeoutCount; // 135876 + int ping; // 135880 + int rate; + int snapshotMsec; + int snapshotBackoffCount; int pureAuthentic; // 135896 - char __pad7[133138]; // 135900 - short scriptID; // 269038 + char netchanOutgoingBuffer[131072]; + char netchanIncomingBuffer[2048]; + char playerGuid[17]; + unsigned short scriptId; // 269038 int bIsTestClient; // 269040 int serverID; // 269044 - char __pad8[9224]; // 269048 + bool usingOnlineStatsOffline; + char stats[8192]; + char statsModifiedFlags[1024]; + bool statsModified; + char statPacketsReceived; + bool steamAuthorized; + char steamAuthFailCount; unsigned __int64 steamID; // 278272 - char __pad9[403592]; // 278280 - } client_t; - -#pragma pack(pop) + bool sendMatchData; + int matchDataSendTime; + clientSnapshot_t frames[32]; + }; static_assert(sizeof(client_t) == 0xA6790);