From fb5e911f22d1100383178a0994823ae72bb28960 Mon Sep 17 00:00:00 2001 From: yamashi Date: Wed, 16 Dec 2020 19:54:27 +0100 Subject: [PATCH] Add antialiasing control --- src/Options.cpp | 2 ++ src/Options.h | 1 + src/dllmain.cpp | 6 +++--- ...nc_compute_patch.cpp => options_patch.cpp} | 20 +++++++++++-------- 4 files changed, 18 insertions(+), 11 deletions(-) rename src/{async_compute_patch.cpp => options_patch.cpp} (72%) diff --git a/src/Options.cpp b/src/Options.cpp index ca50174a..ef0fa78e 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -50,6 +50,7 @@ Options::Options(HMODULE aModule) this->PatchRemovePedestrians = config.value("remove_pedestrians", this->PatchRemovePedestrians); this->PatchSkipStartMenu = config.value("skip_start_menu", this->PatchSkipStartMenu); this->PatchAsyncCompute = config.value("disable_async_compute", this->PatchAsyncCompute); + this->PatchAntialiasing = config.value("disable_antialiasing", this->PatchAntialiasing); } nlohmann::json config; @@ -64,6 +65,7 @@ Options::Options(HMODULE aModule) config["remove_pedestrians"] = this->PatchRemovePedestrians; config["skip_start_menu"] = this->PatchSkipStartMenu; config["disable_async_compute"] = this->PatchAsyncCompute; + config["disable_antialiasing"] = this->PatchAntialiasing; std::ofstream o(configPath); o << config.dump(4) << std::endl; diff --git a/src/Options.h b/src/Options.h index 2fc510af..4648cf22 100644 --- a/src/Options.h +++ b/src/Options.h @@ -19,6 +19,7 @@ struct Options bool PatchUnlockMenu{ false }; bool PatchRemovePedestrians{ false }; bool PatchAsyncCompute{ false }; + bool PatchAntialiasing{ false }; bool PatchSkipStartMenu{ true }; float CPUMemoryPoolFraction{ 0.5f }; float GPUMemoryPoolFraction{ 1.f }; diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 90e6223a..f2f937b9 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -20,7 +20,7 @@ void StringInitializerPatch(Image* apImage); void SpinLockPatch(Image* apImage); void StartScreenPatch(Image* apImage); void RemovePedsPatch(Image* apImage); -void AsyncComputePatch(Image* apImage); +void OptionsPatch(Image* apImage); void Initialize(HMODULE mod) { @@ -56,8 +56,8 @@ void Initialize(HMODULE mod) if(options.PatchRemovePedestrians) RemovePedsPatch(&image); - if(options.PatchAsyncCompute) - AsyncComputePatch(&image); + if(options.PatchAsyncCompute || options.PatchAntialiasing) + OptionsPatch(&image); spdlog::default_logger()->flush(); } diff --git a/src/async_compute_patch.cpp b/src/options_patch.cpp similarity index 72% rename from src/async_compute_patch.cpp rename to src/options_patch.cpp index 831efbb9..04c257b7 100644 --- a/src/async_compute_patch.cpp +++ b/src/options_patch.cpp @@ -25,24 +25,28 @@ static_assert(offsetof(GameProperty, pBoolean) == 0x30); bool HookGamePropertyGetBoolean(GameProperty* apThis, uint8_t* apVariable, uint8_t aKind) { - auto* pLocation = apThis->pBoolean; - if (!pLocation) + auto* pVariable = apThis->pBoolean; + if (!pVariable) return false; - if (strcmp(apThis->pCategory, "Rendering/AsyncCompute") == 0) + if (Options::Get().PatchAsyncCompute && strcmp(apThis->pCategory, "Rendering/AsyncCompute") == 0) { - *pLocation = false; + *pVariable = false; + } + else if (Options::Get().PatchAntialiasing && strcmp(apThis->pName, "Antialiasing") == 0) + { + *pVariable = false; } if (aKind != apThis->kind) return false; - *apVariable = *pLocation; + *apVariable = *pVariable; return true; } -void AsyncComputePatch(Image* apImage) +void OptionsPatch(Image* apImage) { uint8_t* pLocation = FindSignature(apImage->pTextStart, apImage->pTextEnd, { 0x44, 0x3A, 0x41, 0x28, 0x75, 0x11, 0x48, 0x8B, 0x41, 0x30, 0x48, 0x85, 0xC0 }); @@ -64,8 +68,8 @@ void AsyncComputePatch(Image* apImage) pLocation[11] = 0xE0; VirtualProtect(pLocation, 32, oldProtect, nullptr); - spdlog::info("\tAsync compute patch: success"); + spdlog::info("\tHidden options patch: success"); } else - spdlog::info("\tAsync compute patch: failed"); + spdlog::info("\tHidden options patch: failed"); }