From 11ce4945375e9ca7b1dbbfd5e5312eabe8ae5b47 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Mon, 29 Jul 2024 11:09:38 +0800 Subject: [PATCH] conviction: character lighting fix - fixes #1592 --- .../dllmain.cpp | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/source/SplinterCellConviction.FusionMod/dllmain.cpp b/source/SplinterCellConviction.FusionMod/dllmain.cpp index 2ab21741f..10913dd67 100644 --- a/source/SplinterCellConviction.FusionMod/dllmain.cpp +++ b/source/SplinterCellConviction.FusionMod/dllmain.cpp @@ -267,12 +267,6 @@ void __fastcall sub_1002581C(void* self, int edx) //return hb_1002581C.fun(self, edx); } -SafetyHookInline sub_78C666_hook{}; -int __cdecl sub_78C666(char* a1, int a2) -{ - return sub_78C666_hook.ccall(a1, a2); -} - namespace FFileManagerArc { SafetyHookInline shLookup{}; @@ -541,7 +535,6 @@ void Init() auto bSkipSystemDetection = iniReader.ReadInteger("MAIN", "SkipSystemDetection", 1) != 0; auto bPartialUltraWideSupport = iniReader.ReadInteger("MAIN", "PartialUltraWideSupport", 1) != 0; bDisableBlackAndWhiteFilter = iniReader.ReadInteger("MAIN", "DisableBlackAndWhiteFilter", 0) != 0; - auto bDisableCharacterLighting = iniReader.ReadInteger("MAIN", "DisableCharacterLighting", 0) != 0; bBlacklistControlScheme = iniReader.ReadInteger("CONTROLS", "BlacklistControlScheme", 1) != 0; auto bUnlockDLC = iniReader.ReadInteger("UNLOCKS", "UnlockDLC", 1) != 0; @@ -644,24 +637,6 @@ void Init() hb_8330DB.fun = injector::MakeCALL(pattern.get_first(10), sub_8330DB, true).get(); } - if (bDisableCharacterLighting) - { - auto pattern = hook::pattern("E8 ? ? ? ? 33 C9 38 48 1C"); - static auto CharacterLightingHook1 = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& ctx) - { - sub_78C666_hook.ccall("l3d-char-lighting"); - }); - - pattern = hook::pattern("E9 ? ? ? ? 8D 45 90 68 ? ? ? ? 50 E8 ? ? ? ? 85 C0 59 59 74 0B 81 C6 ? ? ? ? E9 ? ? ? ? 8D 45 88 50 68 ? ? ? ? FF 75 90 E8 ? ? ? ? 83 C4 0C 85 C0 74 12 F3 0F 10 45 ? F3 0F 11 86 ? ? ? ? E9 ? ? ? ? 8D 45 88"); - static auto CharacterLightingHook2 = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& ctx) - { - *(uint8_t*)ctx.esi ^= 1; - }); - - pattern = hook::pattern("55 8D AC 24 ? ? ? ? 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 85 ? ? ? ? 8B 85 ? ? ? ? 56 57 8B BD"); - sub_78C666_hook = safetyhook::create_inline(pattern.get_first(0), sub_78C666); - } - // controller scheme force X360 { auto pattern = hook::pattern("66 81 FF ? ? 75 0E 66 81 FE ? ? 75 13"); @@ -978,6 +953,7 @@ void InitLeadD3DRender() CIniReader iniReader(""); auto bDisableDOF = iniReader.ReadInteger("MAIN", "DisableDOF", 1) != 0; auto bDisableBlackAndWhiteFilter = iniReader.ReadInteger("MAIN", "DisableBlackAndWhiteFilter", 0) != 0; + auto bDisableCharacterLighting = iniReader.ReadInteger("MAIN", "DisableCharacterLighting", 0) != 0; auto bEnhancedSonarVision = iniReader.ReadInteger("MAIN", "EnhancedSonarVision", 0) != 0; gBlacklistIndicators = iniReader.ReadInteger("MAIN", "BlacklistIndicators", 0); auto bPartialUltraWideSupport = iniReader.ReadInteger("MAIN", "PartialUltraWideSupport", 1) != 0; @@ -994,6 +970,12 @@ void InitLeadD3DRender() hb_100177B7.fun = injector::MakeCALL(pattern.get_first(), sub_100177B7, true).get(); } + if (bDisableCharacterLighting) + { + auto pattern = hook::module_pattern(GetModuleHandle(L"LeadD3DRender"), "80 78 44 00"); + injector::WriteMemory(pattern.get_first(3), 1, true); + } + if (bEnhancedSonarVision) { static bool bNightVision = false;