From 64103044df37dc7052f03e527e094055adbd72cf Mon Sep 17 00:00:00 2001 From: GEEKiDoS Date: Tue, 3 May 2022 10:32:15 +0800 Subject: [PATCH] Fetch hWnd from Window::GetWindow() --- src/Components/Modules/RawMouse.cpp | 14 +++++++------- src/Game/Functions.cpp | 1 - src/Game/Functions.hpp | 1 - src/Game/Structs.hpp | 15 --------------- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/Components/Modules/RawMouse.cpp b/src/Components/Modules/RawMouse.cpp index 53ffaa43..5a4976cd 100644 --- a/src/Components/Modules/RawMouse.cpp +++ b/src/Components/Modules/RawMouse.cpp @@ -12,7 +12,7 @@ namespace Components tagPOINT curPos; GetCursorPos(&curPos); - GetWindowRect(Game::g_wv->hWnd, &rc); + GetWindowRect(Window::GetWindow(), &rc); auto isClamped = false; if (curPos.x >= rc.left) { @@ -77,7 +77,7 @@ namespace Components { static auto r_fullscreen = Dvar::Var("r_fullscreen"); - if (GetForegroundWindow() == Game::g_wv->hWnd) + if (GetForegroundWindow() == Window::GetWindow()) { if (r_fullscreen.get()) IN_ClampMouseMove(); @@ -95,11 +95,11 @@ namespace Components tagPOINT curPos; GetCursorPos(&curPos); Game::s_wmv->oldPos = curPos; - ScreenToClient(Game::g_wv->hWnd, &curPos); + ScreenToClient(Window::GetWindow(), &curPos); - Game::g_wv->recenterMouse = Game::CL_MouseEvent(curPos.x, curPos.y, dx, dy); + auto recenterMouse = Game::CL_MouseEvent(curPos.x, curPos.y, dx, dy); - if (Game::g_wv->recenterMouse) + if (recenterMouse) { Game::IN_RecenterMouse(); } @@ -108,7 +108,7 @@ namespace Components void RawMouse::IN_RawMouse_Init() { - if (Game::g_wv->hWnd && RawMouse::M_RawInput.get()) + if (Window::GetWindow() && RawMouse::M_RawInput.get()) { #ifdef DEBUG Logger::Print("Raw Mouse Init.\n"); @@ -118,7 +118,7 @@ namespace Components Rid[0].usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC Rid[0].usUsage = 0x02; // HID_USAGE_GENERIC_MOUSE Rid[0].dwFlags = RIDEV_INPUTSINK; - Rid[0].hwndTarget = Game::g_wv->hWnd; + Rid[0].hwndTarget = Window::GetWindow(); RegisterRawInputDevices(Rid, ARRAYSIZE(Rid), sizeof(Rid[0])); } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index f9d7664e..3f95f023 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -550,7 +550,6 @@ namespace Game level_locals_t* level = reinterpret_cast(0x1A831A8); - WinVars_t* g_wv = reinterpret_cast(0x64A3AC8); WinMouseVars_t* s_wmv = reinterpret_cast(0x649D640); int* window_center_x = reinterpret_cast(0x649D638); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 207feed6..b11f32a5 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -1148,7 +1148,6 @@ namespace Game extern level_locals_t* level; - extern WinVars_t* g_wv; extern WinMouseVars_t* s_wmv; extern int* window_center_x; diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 8a4895dc..944f0572 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -7473,21 +7473,6 @@ namespace Game static_assert(sizeof(level_locals_t) == 0x2F78); - struct WinVars_t - { - HINSTANCE reflib_library; - int reflib_active; - HWND hWnd; - HINSTANCE hInstance; - int hasFocus; - int activationStateChanged; - int recenterMouse; - HHOOK lowLevelKeyboardHook; - unsigned int sysMsgTime; - }; - - static_assert(sizeof(WinVars_t) == 0x24); - struct WinMouseVars_t { int oldButtonState;