From c6c9fe60132d7a3b720abf12ecb08341620d6b71 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 5 Mar 2024 23:34:46 +0100 Subject: [PATCH] Enable directional lights on flying car components Fixes detached car parts rendering as near black Fixes #16 --- SilentPatchSA/SilentPatchSA.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index b8a764e..fe220c0 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -2500,6 +2500,18 @@ namespace ShootingStarsFix } +// ============= Enable directional lights on flying car components ============= +namespace LitFlyingComponents +{ + static void (*orgWorldAdd)(CEntity*); + static void WorldAdd_SetLightObjectFlag(CEntity* entity) + { + entity->bLightObject = true; + orgWorldAdd(entity); + } +} + + // ============= LS-RP Mode stuff ============= namespace LSRPMode { @@ -5274,6 +5286,14 @@ void Patch_SA_10(HINSTANCE hInstance) InterceptCall(0x714610, orgRwIm3DTransform, RwIm3DTransform_UnsetTexture); } + + // Enable directional lights on flying car components + { + using namespace LitFlyingComponents; + + InterceptCall(0x6A8BBE, orgWorldAdd, WorldAdd_SetLightObjectFlag); + } + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE ); @@ -6998,6 +7018,16 @@ void Patch_SA_NewBinaries_Common(HINSTANCE hInstance) InterceptCall(rwIm3dTransform, orgRwIm3DTransform, RwIm3DTransform_UnsetTexture); } + + + // Enable directional lights on flying car components + { + using namespace LitFlyingComponents; + + auto worldAdd = get_pattern("53 E8 ? ? ? ? 8B 4D F4 83 C4 04 5F 5E 8B C3", 1); + + InterceptCall(worldAdd, orgWorldAdd, WorldAdd_SetLightObjectFlag); + } }