From f917335b132f527c436a32f07636f503614c4e69 Mon Sep 17 00:00:00 2001 From: Andrew <146450267+semiloker@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:17:10 +0200 Subject: [PATCH] Fix Windows64 mouse capture and static initialization crashes (#177) --- Minecraft.Client/Windows64/Windows64_Minecraft.cpp | 9 +++++++++ Minecraft.World/Packet.cpp | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index e24bc374..7d38ff99 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -403,6 +403,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (LOWORD(wParam) == WA_INACTIVE) KMInput.SetCapture(false); break; + case WM_SETFOCUS: + { + // Re-capture when window receives focus (e.g., after clicking on it) + Minecraft *pMinecraft = Minecraft::GetInstance(); + bool shouldCapture = pMinecraft && app.GetGameStarted() && !ui.GetMenuDisplayed(0) && pMinecraft->screen == NULL; + if (shouldCapture) + KMInput.SetCapture(true); + } + break; case WM_KILLFOCUS: KMInput.SetCapture(false); KMInput.ClearAllState(); diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index 93f02399..f1630db5 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -169,9 +169,9 @@ Packet::Packet() : createTime( System::currentTimeMillis() ) unordered_map Packet::idToCreateMap; -unordered_set Packet::clientReceivedPackets = unordered_set(); -unordered_set Packet::serverReceivedPackets = unordered_set(); -unordered_set Packet::sendToAnyClientPackets = unordered_set(); +unordered_set Packet::clientReceivedPackets; +unordered_set Packet::serverReceivedPackets; +unordered_set Packet::sendToAnyClientPackets; // 4J Added unordered_map Packet::outgoingStatistics = unordered_map();