Make ESC key close the console instead of only closing the console autocomplete

This commit is contained in:
Jan 2021-09-21 22:04:19 +02:00
parent afc097b432
commit 93d28c3644
4 changed files with 37 additions and 0 deletions

View File

@ -407,6 +407,29 @@ namespace Components
// Passthrough to the game's own IsDynClassname
return Utils::Hook::Call<BOOL(char*)>(0x444810)(a1);
}
void QuickPatch::CL_KeyEvent_OnEscape()
{
if (Game::Con_CancelAutoComplete())
return;
// Close console
Game::Key_RemoveCatcher(0, ~Game::KEYCATCH_CONSOLE);
}
__declspec(naked) void QuickPatch::CL_KeyEvent_ConsoleEscape_Stub()
{
__asm
{
pushad
call CL_KeyEvent_OnEscape
popad
// Exit CL_KeyEvent function
mov ebx, 0x4F66F2
jmp ebx
}
}
QuickPatch::QuickPatch()
{
@ -428,6 +451,9 @@ namespace Components
// Filtering any mapents that is intended for Spec:Ops gamemode (CODO) and prevent them from spawning
Utils::Hook(0x5FBD6E, QuickPatch::IsDynClassnameStub, HOOK_CALL).install()->quick();
// Hook escape handling on open console to change behaviour to close the console instead of only canceling autocomplete
Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick();
// bounce dvar
sv_enableBounces = Game::Dvar_RegisterBool("sv_enableBounces", false, Game::DVAR_FLAG_REPLICATED, "Enables bouncing on the server");
Utils::Hook(0x4B1B2D, QuickPatch::BounceStub, HOOK_JUMP).install()->quick();

View File

@ -48,5 +48,8 @@ namespace Components
static Game::dvar_t* g_playerEjection;
static void PlayerEjectionStub();
static BOOL IsDynClassnameStub(char* a1);
static void CL_KeyEvent_OnEscape();
static void CL_KeyEvent_ConsoleEscape_Stub();
};
}

View File

@ -75,6 +75,7 @@ namespace Game
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);
DB_AllocStreamPos_t DB_AllocStreamPos = DB_AllocStreamPos_t(0x418380);
DB_PushStreamPos_t DB_PushStreamPos = DB_PushStreamPos_t(0x458A20);
@ -155,6 +156,7 @@ namespace Game
Info_ValueForKey_t Info_ValueForKey = Info_ValueForKey_t(0x47C820);
Key_SetCatcher_t Key_SetCatcher = Key_SetCatcher_t(0x43BD00);
Key_RemoveCatcher_t Key_RemoveCatcher = Key_RemoveCatcher_t(0x408260);
Key_IsKeyCatcherActive_t Key_IsKeyCatcherActive = Key_IsKeyCatcherActive_t(0x4DA010);
LargeLocalInit_t LargeLocalInit = LargeLocalInit_t(0x4A62A0);

View File

@ -157,6 +157,9 @@ namespace Game
typedef void (__cdecl * Con_DrawSolidConsole_t)();
extern Con_DrawSolidConsole_t Con_DrawSolidConsole;
typedef bool(__cdecl * Con_CancelAutoComplete_t)();
extern Con_CancelAutoComplete_t Con_CancelAutoComplete;
typedef char *(__cdecl *DB_AllocStreamPos_t)(int alignment);
extern DB_AllocStreamPos_t DB_AllocStreamPos;
@ -375,6 +378,9 @@ namespace Game
typedef void(__cdecl * Key_SetCatcher_t)(int localClientNum, int catcher);
extern Key_SetCatcher_t Key_SetCatcher;
typedef void(__cdecl * Key_RemoveCatcher_t)(int localClientNum, int andMask);
extern Key_RemoveCatcher_t Key_RemoveCatcher;
typedef bool(__cdecl * Key_IsKeyCatcherActive_t)(int localClientNum, int catcher);
extern Key_IsKeyCatcherActive_t Key_IsKeyCatcherActive;