From dc3cc28693fcf642b5812ca7cfc0ebd6b64ab871 Mon Sep 17 00:00:00 2001 From: Edo Date: Wed, 3 May 2023 00:10:14 +0100 Subject: [PATCH] [Auth]: Remove whitespace (#996) --- src/Components/Modules/Auth.cpp | 4 ++-- src/Components/Modules/Console.cpp | 22 +++++++++++++++++++++- src/Components/Modules/Console.hpp | 5 +++++ src/Components/Modules/Maps.cpp | 12 ------------ src/Components/Modules/Zones.cpp | 12 ++++++------ src/Game/Functions.cpp | 2 ++ src/Game/Functions.hpp | 8 +++++++- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index af3dbb3c..3024699b 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -71,7 +71,7 @@ namespace Components TokenContainer.cancel = false; } } - + void Auth::SendConnectDataStub(Game::netsrc_t sock, Game::netadr_t adr, const char* format, int len) { // Ensure our certificate is loaded @@ -88,7 +88,7 @@ namespace Components Logger::Error(Game::ERR_SERVERDISCONNECT, "Your online profile is invalid. A new key has been generated."); return; } - + std::string connectString(format, len); Game::SV_Cmd_TokenizeString(connectString.data()); diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 08b53d69..3699c58b 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -1,4 +1,4 @@ -#include +#include #include "Console.hpp" #include "TextRenderer.hpp" @@ -56,6 +56,8 @@ namespace Components Game::SafeArea Console::OriginalSafeArea; + bool Console::isCommand; + const char** Console::GetAutoCompleteFileList(const char* path, const char* extension, Game::FsListBehavior_e behavior, int* numfiles, int allocTrackType) { if (path == reinterpret_cast(0xBAADF00D) || path == reinterpret_cast(0xCDCDCDCD) || ::Utils::Memory::IsBadReadPtr(path)) return nullptr; @@ -807,6 +809,20 @@ namespace Components return reinterpret_cast(0x471500)(dvarName, r, g, b, a, min, max, flags, description); } + bool Console::Con_IsDvarCommand_Stub(const char* cmd) + { + isCommand = Game::Con_IsDvarCommand(cmd); + return isCommand; + } + + void Console::Cmd_ForEach_Stub(void(*callback)(const char* str)) + { + if (!isCommand) + { + Game::Cmd_ForEach(callback); + } + } + void Console::Con_ToggleConsole() { Game::Field_Clear(Game::g_consoleField); @@ -885,6 +901,10 @@ namespace Components // Don't resize the console Utils::Hook(0x64DC6B, 0x64DCC2, HOOK_JUMP).install()->quick(); + // Con_DrawInput + Utils::Hook(0x5A45BD, Con_IsDvarCommand_Stub, HOOK_CALL).install()->quick(); + Utils::Hook(0x5A466C, Cmd_ForEach_Stub, HOOK_CALL).install()->quick(); + #ifdef _DEBUG AddConsoleCommand(); #endif diff --git a/src/Components/Modules/Console.hpp b/src/Components/Modules/Console.hpp index 0ccad217..3bd9207a 100644 --- a/src/Components/Modules/Console.hpp +++ b/src/Components/Modules/Console.hpp @@ -49,6 +49,8 @@ namespace Components static Game::SafeArea OriginalSafeArea; + static bool isCommand; + static void ShowPrompt(); static void RefreshStatus(); static void RefreshOutput(); @@ -75,6 +77,9 @@ namespace Components static void AddConsoleCommand(); static Game::dvar_t* RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, float max, unsigned __int16 flags, const char* description); + + static bool Con_IsDvarCommand_Stub(const char* cmd); + static void Cmd_ForEach_Stub(void(*callback)(const char* str)); static LRESULT CALLBACK ConWndProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); static ATOM CALLBACK RegisterClassHook(WNDCLASSA* lpWndClass); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index da4a65f3..072319f5 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -813,18 +813,6 @@ namespace Components Utils::Hook::Set(0x64A029, 0x1C200000); // 450 MiB Utils::Hook::Set(0x64A057, 0x1C200000); -#if DEBUG - // Hunk debugging - Utils::Hook::Set(0x4FF57B, 0xCC); - Utils::Hook::Nop(0x4FF57C, 4); -#else - // Temporarily disable distortion warnings - Utils::Hook::Nop(0x50DBFF, 5); - Utils::Hook::Nop(0x50DC4F, 5); - Utils::Hook::Nop(0x50DCA3, 5); - Utils::Hook::Nop(0x50DCFE, 5); -#endif - // Intercept BSP name resolving Utils::Hook(0x4C5979, Maps::GetBSPName, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 2206df39..115306a5 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -3407,10 +3407,10 @@ namespace Components constexpr auto fileCountMultiplier = 8; constexpr auto maxFileCount = 8191 * fileCountMultiplier; - int RelocateFileCount(std::uint32_t dwSize, int unk1, int unk2, int unk3) + Game::HunkUser* Hunk_UserCreate_Stub(int maxSize, const char* name, bool fixed, int type) { - dwSize *= fileCountMultiplier; - return Utils::Hook::Call(0x430E90)(dwSize, unk1, unk2, unk3); + maxSize *= fileCountMultiplier; + return Utils::Hook::Call(0x430E90)(maxSize, name, fixed, type); } void Zones::LoadMaterialAsset(Game::Material** asset) @@ -3554,8 +3554,8 @@ namespace Components Utils::Hook::Set(0x64AF78, maxFileCount); Utils::Hook::Set(0x64B04F, maxFileCount); Utils::Hook::Set(0x45A8CE, maxFileCount); - Utils::Hook(0x45A806, RelocateFileCount, HOOK_CALL).install()->quick(); - Utils::Hook(0x45A6A0, RelocateFileCount, HOOK_CALL).install()->quick(); + Utils::Hook(0x45A806, Hunk_UserCreate_Stub, HOOK_CALL).install()->quick(); + Utils::Hook(0x45A6A0, Hunk_UserCreate_Stub, HOOK_CALL).install()->quick(); #ifndef DEBUG // Ignore missing soundaliases for now @@ -3662,4 +3662,4 @@ namespace Components #endif } } -#pragma optimize( "", on ) \ No newline at end of file +#pragma optimize( "", on ) diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 1d5af994..51e4e8d6 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -25,10 +25,12 @@ namespace Game Cmd_AddCommand_t Cmd_AddCommand = Cmd_AddCommand_t(0x470090); Cmd_AddServerCommand_t Cmd_AddServerCommand = Cmd_AddServerCommand_t(0x4DCE00); Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand = Cmd_ExecuteSingleCommand_t(0x609540); + Cmd_ForEach_t Cmd_ForEach = Cmd_ForEach_t(0x45D680); Con_DrawMiniConsole_t Con_DrawMiniConsole = Con_DrawMiniConsole_t(0x464F30); Con_DrawSolidConsole_t Con_DrawSolidConsole = Con_DrawSolidConsole_t(0x5A5040); Con_CancelAutoComplete_t Con_CancelAutoComplete = Con_CancelAutoComplete_t(0x435580); + Con_IsDvarCommand_t Con_IsDvarCommand = Con_IsDvarCommand_t(0x5A3FF0); DB_AllocStreamPos_t DB_AllocStreamPos = DB_AllocStreamPos_t(0x418380); DB_PushStreamPos_t DB_PushStreamPos = DB_PushStreamPos_t(0x458A20); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 2618d37c..832d36de 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -60,7 +60,10 @@ namespace Game typedef void(*Cmd_ExecuteSingleCommand_t)(int localClientNum, int controllerIndex, const char* cmd); extern Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand; - typedef char* (*Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); + typedef void(*Cmd_ForEach_t)(void(*callback)(const char* str)); + extern Cmd_ForEach_t Cmd_ForEach; + + typedef char*(*Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); extern Con_DrawMiniConsole_t Con_DrawMiniConsole; typedef void (*Con_DrawSolidConsole_t)(); @@ -69,6 +72,9 @@ namespace Game typedef bool(*Con_CancelAutoComplete_t)(); extern Con_CancelAutoComplete_t Con_CancelAutoComplete; + typedef bool(*Con_IsDvarCommand_t)(const char* cmd); + extern Con_IsDvarCommand_t Con_IsDvarCommand; + typedef bool(*Encode_Init_t)(const char* ); extern Encode_Init_t Encode_Init;