aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew <146450267+semiloker@users.noreply.github.com>2026-03-02 22:17:10 +0200
committerGitHub <noreply@github.com>2026-03-03 03:17:10 +0700
commitf917335b132f527c436a32f07636f503614c4e69 (patch)
tree43d86a6848187fb4d3247251389b1a339ef84a54
parentbbef5445f9f0c19ac7135291a5e9ebee272aeb6a (diff)
Fix Windows64 mouse capture and static initialization crashes (#177)
-rw-r--r--Minecraft.Client/Windows64/Windows64_Minecraft.cpp9
-rw-r--r--Minecraft.World/Packet.cpp6
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<int, packetCreateFn> Packet::idToCreateMap;
-unordered_set<int> Packet::clientReceivedPackets = unordered_set<int>();
-unordered_set<int> Packet::serverReceivedPackets = unordered_set<int>();
-unordered_set<int> Packet::sendToAnyClientPackets = unordered_set<int>();
+unordered_set<int> Packet::clientReceivedPackets;
+unordered_set<int> Packet::serverReceivedPackets;
+unordered_set<int> Packet::sendToAnyClientPackets;
// 4J Added
unordered_map<int, Packet::PacketStatistics *> Packet::outgoingStatistics = unordered_map<int, Packet::PacketStatistics *>();