From 9c2f56d8268cafe7c4671f5bc86bad519f012dcf Mon Sep 17 00:00:00 2001 From: 11EJDE11 Date: Sun, 23 Aug 2026 18:35:20 +1200 Subject: [PATCH 1/2] Fix slowdown when loading games --- src/Misc/Bugfixes.Perf.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Misc/Bugfixes.Perf.cpp b/src/Misc/Bugfixes.Perf.cpp index 6e6a67fe..8f3b6e11 100644 --- a/src/Misc/Bugfixes.Perf.cpp +++ b/src/Misc/Bugfixes.Perf.cpp @@ -33,6 +33,7 @@ #include #include #include +#include /*** the following hooks replace the original checks that disable certain visual @@ -101,3 +102,16 @@ DEFINE_HOOK(0x6D7847, TacticalClass_DrawPixelEffects_Details, 0x5) ? 0x6D7858 : 0x6D7BF2; } + +// Do_Blit's 50ms wait guards the cursor restore after the primary-surface blit, but that restore +// (0x7B92D0) and the draw before it (0x7B90C0) are both no-ops unless IsCaptured(). Loading screens +// pass mouse_captured = true while the mouse is uncaptured, so vanilla sleeps 40+ times per scenario +// load guarding nothing - about two seconds. When captured, this is the vanilla path unchanged. +DEFINE_HOOK(0x4F4B8E, GScreenClass_DoBlit_SkipUncapturedCursorWait, 0x8) +{ + // Do_Blit already tested WWMouse for null at 0x4F4B8A. + if (WWMouseClass::Instance->IsCaptured()) + Sleep(50); + + return 0x4F4B96; +} From ab97e662a2012c51a1c7778c5e32b912cf8a7293 Mon Sep 17 00:00:00 2001 From: 11EJDE11 Date: Sun, 23 Aug 2026 21:29:40 +1200 Subject: [PATCH 2/2] Move to Bugfixes.cpp --- src/Misc/Bugfixes.Perf.cpp | 14 -------------- src/Misc/Bugfixes.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Misc/Bugfixes.Perf.cpp b/src/Misc/Bugfixes.Perf.cpp index 8f3b6e11..6e6a67fe 100644 --- a/src/Misc/Bugfixes.Perf.cpp +++ b/src/Misc/Bugfixes.Perf.cpp @@ -33,7 +33,6 @@ #include #include #include -#include /*** the following hooks replace the original checks that disable certain visual @@ -102,16 +101,3 @@ DEFINE_HOOK(0x6D7847, TacticalClass_DrawPixelEffects_Details, 0x5) ? 0x6D7858 : 0x6D7BF2; } - -// Do_Blit's 50ms wait guards the cursor restore after the primary-surface blit, but that restore -// (0x7B92D0) and the draw before it (0x7B90C0) are both no-ops unless IsCaptured(). Loading screens -// pass mouse_captured = true while the mouse is uncaptured, so vanilla sleeps 40+ times per scenario -// load guarding nothing - about two seconds. When captured, this is the vanilla path unchanged. -DEFINE_HOOK(0x4F4B8E, GScreenClass_DoBlit_SkipUncapturedCursorWait, 0x8) -{ - // Do_Blit already tested WWMouse for null at 0x4F4B8A. - if (WWMouseClass::Instance->IsCaptured()) - Sleep(50); - - return 0x4F4B96; -} diff --git a/src/Misc/Bugfixes.cpp b/src/Misc/Bugfixes.cpp index 327c56f2..ee44fbf1 100644 --- a/src/Misc/Bugfixes.cpp +++ b/src/Misc/Bugfixes.cpp @@ -20,6 +20,7 @@ #include #include #include +#include // skip error "А mouse is required for playing Yurts Revenge" - remove the GetSystemMetrics check DEFINE_JUMP(LJMP, 0x6BD8A4, 0x6BD8C2); // WinMain @@ -51,3 +52,16 @@ DEFINE_HOOK(0x55E08F, KeyboardProcess_PressTab, 0x5) return 0x55E099; } + +// Do_Blit's 50ms wait guards the cursor restore after the primary-surface blit, but that restore +// (0x7B92D0) and the draw before it (0x7B90C0) are both no-ops unless IsCaptured(). Loading screens +// pass mouse_captured = true while the mouse is uncaptured, so vanilla sleeps 40+ times per scenario +// load guarding nothing - about two seconds. When captured, this is the vanilla path unchanged. +DEFINE_HOOK(0x4F4B8E, GScreenClass_DoBlit_SkipUncapturedCursorWait, 0x8) +{ + // Do_Blit already tested WWMouse for null at 0x4F4B8A. + if (WWMouseClass::Instance->IsCaptured()) + Sleep(50); + + return 0x4F4B96; +}