Skip to content

Commit

Permalink
conviction: character lighting fix
Browse files Browse the repository at this point in the history
- fixes #1592
  • Loading branch information
ThirteenAG committed Jul 29, 2024
1 parent 6652208 commit 11ce494
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions source/SplinterCellConviction.FusionMod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(a1, a2);
}

namespace FFileManagerArc
{
SafetyHookInline shLookup{};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<int>("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");
Expand Down Expand Up @@ -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;
Expand All @@ -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<uint8_t>(pattern.get_first(3), 1, true);
}

if (bEnhancedSonarVision)
{
static bool bNightVision = false;
Expand Down

0 comments on commit 11ce494

Please sign in to comment.