From 997165d012446c9af072fb9a9277a30d23e53767 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 1 May 2017 14:57:17 +0200 Subject: [PATCH] [Maps] Temporarily disable distortion for custom maps --- src/Components/Modules/Maps.cpp | 39 +++++++++++++++++++++++++++++++++ src/Components/Modules/Maps.hpp | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index d30d382d..d5e172a2 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -696,6 +696,13 @@ namespace Components Dvar::Var("isDlcInstalled_All").setRaw(hasAllDlcs ? 1 : 0); } + bool Maps::IsCustomMap() + { + Game::GfxWorld*& gameWorld = *reinterpret_cast(0x66DEE94); + if(gameWorld) return gameWorld->checksum == 0xDEADBEEF; + return false; + } + Game::XAssetEntry* Maps::GetAssetEntryPool() { if(Maps::EntryPool.empty()) @@ -811,6 +818,36 @@ namespace Components } } + Game::dvar_t* Maps::GetDistortionDvar() + { + Game::dvar_t*& r_distortion = *reinterpret_cast(0x69F0DCC); + + if(Maps::IsCustomMap()) + { + static Game::dvar_t noDistortion; + ZeroMemory(&noDistortion, sizeof noDistortion); + return &noDistortion; + } + + return r_distortion; + } + + __declspec(naked) void Maps::SetDistortionStub() + { + __asm + { + push eax + pushad + call Maps::GetDistortionDvar + + mov [esp + 20h], eax + popad + + pop eax + retn + } + } + Maps::Maps() { Dvar::OnInit([]() @@ -885,6 +922,8 @@ namespace Components // Allow loading raw suns Utils::Hook(0x51B46A, Maps::LoadRawSun, HOOK_CALL).install()->quick(); + Utils::Hook(0x50AA47, Maps::SetDistortionStub, HOOK_CALL).install()->quick(); + // Intercept map loading for usermap initialization Utils::Hook(0x6245E3, Maps::SpawnServerStub, HOOK_CALL).install()->quick(); Utils::Hook(0x62493E, Maps::SpawnServerStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index ffa039bd..643db4cf 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -68,6 +68,7 @@ namespace Components static unsigned int GetUsermapHash(std::string map); static Game::XAssetEntry* GetAssetEntryPool(); + static bool IsCustomMap(); private: class DLC @@ -119,6 +120,9 @@ namespace Components static void HideModel(); static void HideModelStub(); + static Game::dvar_t* GetDistortionDvar(); + static void SetDistortionStub(); + void reallocateEntryPool(); }; }