From a04006909c1e05c4d3957e66d02b5ff4da694f1b Mon Sep 17 00:00:00 2001 From: Nishimura-Katsuo <38635886+Nishimura-Katsuo@users.noreply.github.com> Date: Tue, 24 Aug 2021 00:50:39 -0600 Subject: [PATCH] Added screen shake setting --- features/Misc.cpp | 14 +++++++++++++- features/Settings.cpp | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/features/Misc.cpp b/features/Misc.cpp index bf204ba..41eb235 100644 --- a/features/Misc.cpp +++ b/features/Misc.cpp @@ -374,6 +374,7 @@ wchar_t* __fastcall UnitVisualname(D2::Types::LivingUnit *pUnit) { // This feature class registers itself. class : public Feature { + DWORD disableShake = 0; public: void init() { if (!Settings["disableSplash"]) { @@ -382,7 +383,7 @@ class : public Feature { } MemoryPatch(0x4f5621) << NOP_TO(0x4f5672); // Allow multiple windows open - MemoryPatch(0x476D40) << ASM::RET; // Ignore shaking requests + MemoryPatch(0x43BF60) << ASM::RET; // Prevent battle.net connections MemoryPatch(0x515FB1) << BYTE(0x01); // Delay of 1 on cleaning up sounds after quiting game MemoryPatch(0x4781AC) << BYTESEQ{ 0x6A, 0x05, 0x90, 0x90, 0x90 }; // Hyperjoin for TCP/IP games @@ -425,6 +426,17 @@ class : public Feature { void gameLoop() { gamestart = gamestart ? gamestart : GetTickCount(); flashy += speed; + + if (Settings["disableShake"] != disableShake) { + if (Settings["disableShake"]) { + MemoryPatch(0x476D40) << ASM::RET; // Ignore shaking requests + } + else { + MemoryPatch(0x476D40) << REVERT(1); + } + } + + disableShake = Settings["disableShake"]; } void oogLoop() { diff --git a/features/Settings.cpp b/features/Settings.cpp index 5d0c60f..1b5f2dc 100644 --- a/features/Settings.cpp +++ b/features/Settings.cpp @@ -174,6 +174,14 @@ std::vector> SettingsColumns = { SaveSettings(); }), nullptr, // Empty Gap + new DialogToggleInfo(L"Disable screen shake", + []() -> std::wstring { + return Settings["disableShake"] ? L"\u00FFc2On" : L"\u00FFc1Off"; + }, [](MouseButton button, bool down) -> void { + if (down) return; + Settings["disableShake"] = !Settings["disableShake"]; + SaveSettings(); + }), new DialogToggleInfo(L"Disable splash on start", []() -> std::wstring { return Settings["disableSplash"] ? L"\u00FFc2On" : L"\u00FFc1Off";