From 799a7583efc769db2d9ca4a556e3c28df569d16e Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 7 Aug 2016 17:52:13 +0200 Subject: [PATCH] Fix selectstringtableentryindvar --- src/Components/Modules/QuickPatch.cpp | 22 +++++++++++++++++++++- src/Components/Modules/QuickPatch.hpp | 2 ++ src/Game/Functions.cpp | 1 + src/Game/Functions.hpp | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index fc62d16b..361bf09f 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -10,7 +10,7 @@ namespace Components return &id; } - void QuickPatch::OnShutdown(QuickPatch::Callback callback) + void QuickPatch::OnShutdown(QuickPatch::Callback* callback) { QuickPatch::ShutdownSignal.connect(callback); } @@ -114,6 +114,23 @@ namespace Components } } + void QuickPatch::SelectStringTableEntryInDvarStub() + { + Command::Params args; + + if (args.Length() >= 4) + { + Game::dvar_t* dvar = Game::Dvar_FindVar(args[3]); + + if (!dvar || dvar->flags & Game::DVAR_FLAG_WRITEPROTECTED || dvar->flags & Game::DVAR_FLAG_CHEAT || dvar->flags & Game::DVAR_FLAG_READONLY) + { + return; + } + } + + Game::CL_SelectStringTableEntryInDvar_f(); + } + QuickPatch::QuickPatch() { // protocol version (workaround for hacks) @@ -335,6 +352,9 @@ namespace Components Utils::Hook(0x4A9F56, QuickPatch::MsgReadBitsCompressCheckCL, HOOK_CALL).Install()->Quick(); // CL_ParseServerMessage Utils::Hook(0x5AA009, QuickPatch::CL_HandleRelayPacketCheck, HOOK_CALL).Install()->Quick(); // CL_HandleRelayPacket + // Patch selectStringTableEntryInDvar + Utils::Hook::Set(0x405959, QuickPatch::SelectStringTableEntryInDvarStub); + Command::Add("unlockstats", [] (Command::Params params) { QuickPatch::UnlockStats(); diff --git a/src/Components/Modules/QuickPatch.hpp b/src/Components/Modules/QuickPatch.hpp index bf27e9e6..e685c3d4 100644 --- a/src/Components/Modules/QuickPatch.hpp +++ b/src/Components/Modules/QuickPatch.hpp @@ -21,6 +21,8 @@ namespace Components static int64_t* GetStatsID(); static void ShutdownStub(int channel, const char* message); + static void SelectStringTableEntryInDvarStub(); + static int MsgReadBitsCompressCheckSV(const char *from, char *to, int size); static int MsgReadBitsCompressCheckCL(const char *from, char *to, int size); static void CL_HandleRelayPacketCheck(Game::msg_t* msg, int client); diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index efd37845..8119a7e0 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -15,6 +15,7 @@ namespace Game CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = (CL_DrawStretchPicPhysical_t)0x4FC120; CL_HandleRelayPacket_t CL_HandleRelayPacket = (CL_HandleRelayPacket_t)0x5A8C70; CL_ResetViewport_t CL_ResetViewport = (CL_ResetViewport_t)0x4A8830; + CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = (CL_SelectStringTableEntryInDvar_f_t)0x4A4560; Cmd_AddCommand_t Cmd_AddCommand = (Cmd_AddCommand_t)0x470090; Cmd_AddServerCommand_t Cmd_AddServerCommand = (Cmd_AddServerCommand_t)0x4DCE00; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 6f140350..8ae620d6 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -30,6 +30,9 @@ namespace Game typedef void(__cdecl * CL_ResetViewport_t)(); extern CL_ResetViewport_t CL_ResetViewport; + typedef void(__cdecl * CL_SelectStringTableEntryInDvar_f_t)(); + extern CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f; + typedef void(__cdecl * Cmd_AddCommand_t)(const char* name, void(*callback), cmd_function_t* data, char); extern Cmd_AddCommand_t Cmd_AddCommand;