From 4ddb07f6bd395a3e9b8c7815fc2ed8c8df00aa14 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sat, 23 Jan 2021 03:47:22 +0600 Subject: [PATCH] fix bugs with hook --- src/Game.cpp | 5 +++++ src/Hook.cpp | 24 +++++++++++++----------- src/Hook.h | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index eaa428b..5273fc3 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -247,6 +247,11 @@ void Game::FreeCam() CEntity* player_entity = FindPlayerEntity(-1); pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f; Command(CPools::GetPedRef(player),pos.x,pos.y,pos.z); + + // disble them again cause they get enabled + CHud::bScriptDontDisplayRadar = true; + CHud::m_Wants_To_Draw_Hud = false; + CHud::SetHelpMessage((char*)"Player telported",false,false,false); } if (KeyPressed(VK_RCONTROL)) diff --git a/src/Hook.cpp b/src/Hook.cpp index 6399901..5b40958 100644 --- a/src/Hook.cpp +++ b/src/Hook.cpp @@ -1,4 +1,3 @@ -#include "pch.h" #include "Hook.h" #include "vendor/kiero/kiero.h" #include "vendor/kiero/minhook/MinHook.h" @@ -47,11 +46,7 @@ void Hook::Present(void *ptr) if (Globals::init_done) { - if (mouse_visibility != show_mouse) - { - Hook::ShowMouse(show_mouse); - mouse_visibility = show_mouse; - } + Hook::ShowMouse(show_mouse); // Change font size if the game resolution changes if (Globals::screen_size.x != screen::GetScreenWidth() @@ -97,6 +92,9 @@ void Hook::Present(void *ptr) ImGuiStyle& style = ImGui::GetStyle(); ImGui_ImplWin32_Init(RsGlobal.ps->window); + + // shift trigger fix + patch::Nop(0x00531155,5); if (Globals::renderer == Render_DirectX9) { @@ -146,11 +144,15 @@ void Hook::ShowMouse(bool state) } else { - patch::SetRaw(0x541DF5, (void*)"\xE8\x46\xF3\xFE\xFF", 5); // call CControllerConfigManager::AffectPadFromKeyBoard - patch::SetRaw(0x53F417, (void*)"\xE8\xB4\x7A\x20\x00", 5); // call CPad__getMouseState - patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement - // jz loc_53F526 -> jl loc_53F526 - patch::SetUChar(0x6194A0, 0xE9); // jmp setup + if (mouse_visibility != show_mouse) + { + patch::SetRaw(0x541DF5, (void*)"\xE8\x46\xF3\xFE\xFF", 5); // call CControllerConfigManager::AffectPadFromKeyBoard + patch::SetRaw(0x53F417, (void*)"\xE8\xB4\x7A\x20\x00", 5); // call CPad__getMouseState + patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement + // jz loc_53F526 -> jl loc_53F526 + patch::SetUChar(0x6194A0, 0xE9); // jmp setup + mouse_visibility = show_mouse; + } } ImGui::GetIO().MouseDrawCursor = state; diff --git a/src/Hook.h b/src/Hook.h index 93d9741..4805414 100644 --- a/src/Hook.h +++ b/src/Hook.h @@ -1,4 +1,5 @@ #pragma once +#include "pch.h" typedef HRESULT(CALLBACK *f_Present9)(IDirect3DDevice9*, RECT*, RECT*, HWND, RGNDATA*); typedef HRESULT(CALLBACK *f_Present11)(IDXGISwapChain*, UINT, UINT); @@ -26,7 +27,6 @@ protected: static bool show_mouse; static std::function window_func; -public: Hook(); ~Hook(); };