From 16da563af02fd2685f50f69f1d15c4e734d019ac Mon Sep 17 00:00:00 2001 From: Jesse <69196954+ThisAMJ@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:25:36 +1100 Subject: [PATCH] feat: `sar_workshop_skip` needs cheats for now because (src) mods are cops but if you want it in your casual workshop, go ahead! --- src/Modules/Client.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Modules/Client.cpp b/src/Modules/Client.cpp index 528042323..7bb9280ce 100644 --- a/src/Modules/Client.cpp +++ b/src/Modules/Client.cpp @@ -528,6 +528,21 @@ DETOUR_T(void, Client::AddShadowToReceiver, unsigned short handle, void *pRender } Hook g_AddShadowToReceiverHook(&Client::AddShadowToReceiver_Hook); +static void (*MsgPreSkipToNextLevel)(); + +CON_COMMAND(sar_workshop_skip, "sar_workshop_skip - Skips to the next level in workshop\n") { + if (!sv_cheats.GetBool()) { + return console->Print("This command requires sv_cheats\n"); + } + if (strncmp("workshop/", engine->GetCurrentMapName().c_str(), 9)) { + return console->Print("This command only works in workshop maps.\n"); + } + // open the console so that it works on binds lmao (the menu has to be visible probably) + // debug with -vguimessages launch option + engine->ExecuteCommand("showconsole"); + MsgPreSkipToNextLevel(); +} + bool Client::Init() { bool readJmp = false; @@ -645,6 +660,12 @@ bool Client::Init() { g_DrawTranslucentRenderablesHook.SetFunc(Client::DrawTranslucentRenderables); g_DrawOpaqueRenderablesHook.SetFunc(Client::DrawOpaqueRenderables); +#ifdef _WIN32 + MsgPreSkipToNextLevel = (decltype(MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "57 8B F9 E8 ? ? ? ? 8B C8 E8 ? ? ? ? 0B C2"); +#else + MsgPreSkipToNextLevel = (decltype(MsgPreSkipToNextLevel))Memory::Scan(client->Name(), "53 83 EC 08 E8 ? ? ? ? 83 EC 0C 50 E8 ? ? ? ? 83 C4 10 09 C2"); +#endif + if (sar.game->Is(SourceGame_Portal2)) { #ifdef _WIN32 Client::CalcViewModelLag = (decltype(Client::CalcViewModelLag))Memory::Scan(client->Name(), "53 8B DC 83 EC 08 83 E4 F0 83 C4 04 55 8B 6B 04 89 6C 24 04 8B EC 83 EC 1C 56 6A 00 6A 00 8D 45 F4 8B F1 8B 4B 0C 50 51 E8 ? ? ? ?");