DirectionalFromSun exposed to INI

Debug menu even in Master builds
This commit is contained in:
Silent 2017-11-15 00:06:36 +01:00
parent fbe5c6c6bf
commit 2272250483

View file

@ -312,9 +312,7 @@ CRGBA* HudColour = *AddressByVersion<CRGBA**>(0x58ADF6, 0x58B5C6, 0x440648);
CLinkListSA<CPed*>& ms_weaponPedsForPC = **AddressByVersion<CLinkListSA<CPed*>**>(0x53EACA, 0x53EF6A, 0x551101); CLinkListSA<CPed*>& ms_weaponPedsForPC = **AddressByVersion<CLinkListSA<CPed*>**>(0x53EACA, 0x53EF6A, 0x551101);
CLinkListSA<AlphaObjectInfo>& m_alphaList = **AddressByVersion<CLinkListSA<AlphaObjectInfo>**>(0x733A4D, 0x73427D, 0x76DCA3); CLinkListSA<AlphaObjectInfo>& m_alphaList = **AddressByVersion<CLinkListSA<AlphaObjectInfo>**>(0x733A4D, 0x73427D, 0x76DCA3);
#ifndef NDEBUG
DebugMenuAPI gDebugMenuAPI; DebugMenuAPI gDebugMenuAPI;
#endif
// Custom variables // Custom variables
@ -1061,24 +1059,16 @@ static void DoPCScreenChange_Mod()
} }
} }
#ifndef NDEBUG static bool bUseAaronSun;
static bool bUseAaronSun = true;
static bool bFixedPCVehLight = true;
#endif
static CVector curVecToSun; static CVector curVecToSun;
static void (*orgSetLightsWithTimeOfDayColour)( RpWorld* ); static void (*orgSetLightsWithTimeOfDayColour)( RpWorld* );
static void SetLightsWithTimeOfDayColour_SilentPatch( RpWorld* world ) static void SetLightsWithTimeOfDayColour_SilentPatch( RpWorld* world )
{ {
static CVector* const VectorToSun = *AddressByVersion<CVector**>( 0x6FC5B7 + 3, 0, 0 ); // TODO: DO static CVector* const VectorToSun = *AddressByVersion<CVector**>( 0x6FC5B7 + 3, 0, 0 ); // TODO: DO
static int& CurrentStoredValue = **AddressByVersion<int**>( 0x6FC632 + 1, 0, 0 ); // TODO: DO static int& CurrentStoredValue = **AddressByVersion<int**>( 0x6FC632 + 1, 0, 0 ); // TODO: DO
static CVector& vecDirnLightToSun = **AddressByVersion<CVector**>( 0x5BC040 + 2, 0, 0 ); // TODO: Do
#ifndef NDEBUG
static CVector& vecDirnLightToSun = *(CVector*)0xB7CB14;
curVecToSun = bUseAaronSun ? VectorToSun[CurrentStoredValue] : vecDirnLightToSun; curVecToSun = bUseAaronSun ? VectorToSun[CurrentStoredValue] : vecDirnLightToSun;
#else
curVecToSun = VectorToSun[CurrentStoredValue];
#endif
orgSetLightsWithTimeOfDayColour( world ); orgSetLightsWithTimeOfDayColour( world );
} }
@ -2197,11 +2187,7 @@ BOOL InjectDelayedPatches_10()
ReadRotorFixExceptions(wcModulePath); ReadRotorFixExceptions(wcModulePath);
const bool bHookDoubleRwheels = ReadDoubleRearWheels(wcModulePath); const bool bHookDoubleRwheels = ReadDoubleRearWheels(wcModulePath);
#ifndef NDEBUG
const bool bHasDebugMenu = DebugMenuLoad(); const bool bHasDebugMenu = DebugMenuLoad();
#else
constexpr bool bHasDebugMenu = false;
#endif
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 )
{ {
@ -2372,42 +2358,48 @@ BOOL InjectDelayedPatches_10()
// Fix directional light position // Fix directional light position
ReadCall( 0x53E997, orgSetLightsWithTimeOfDayColour ); if ( int INIoption = GetPrivateProfileIntW(L"SilentPatch", L"DirectionalFromSun", -1, wcModulePath); INIoption != -1 )
InjectHook( 0x53E997, SetLightsWithTimeOfDayColour_SilentPatch );
Patch<const void*>( 0x735618 + 2, &curVecToSun.x );
Patch<const void*>( 0x73561E + 2, &curVecToSun.y );
Patch<const void*>( 0x735624 + 1, &curVecToSun.z );
#ifndef NDEBUG
if ( bHasDebugMenu )
{ {
DebugMenuAddVar( "SilentPatch", "Directional from sun", &bUseAaronSun, nullptr ); bUseAaronSun = INIoption != 0;
// Switch for fixed PC vehicle lighting ReadCall( 0x53E997, orgSetLightsWithTimeOfDayColour );
DebugMenuAddVar( "SilentPatch", "Fixed PC vehicle light", &bFixedPCVehLight, []() { InjectHook( 0x53E997, SetLightsWithTimeOfDayColour_SilentPatch );
if ( bFixedPCVehLight ) Patch<const void*>( 0x735618 + 2, &curVecToSun.x );
{ Patch<const void*>( 0x73561E + 2, &curVecToSun.y );
Memory::VP::Patch<float>(0x5D88D1 + 6, 0); Patch<const void*>( 0x735624 + 1, &curVecToSun.z );
Memory::VP::Patch<float>(0x5D88DB + 6, 0);
Memory::VP::Patch<float>(0x5D88E5 + 6, 0);
Memory::VP::Patch<float>(0x5D88F9 + 6, 0); if ( bHasDebugMenu )
Memory::VP::Patch<float>(0x5D8903 + 6, 0); {
Memory::VP::Patch<float>(0x5D890D + 6, 0); DebugMenuAddVar( "SilentPatch", "Directional from sun", &bUseAaronSun, nullptr );
}
else
{
Memory::VP::Patch<float>(0x5D88D1 + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88DB + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88E5 + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88F9 + 6, 0.75f); #ifndef NDEBUG
Memory::VP::Patch<float>(0x5D8903 + 6, 0.75f); // Switch for fixed PC vehicle lighting
Memory::VP::Patch<float>(0x5D890D + 6, 0.75f); static bool bFixedPCVehLight = true;
} DebugMenuAddVar( "SilentPatch", "Fixed PC vehicle light", &bFixedPCVehLight, []() {
} ); if ( bFixedPCVehLight )
{
Memory::VP::Patch<float>(0x5D88D1 + 6, 0);
Memory::VP::Patch<float>(0x5D88DB + 6, 0);
Memory::VP::Patch<float>(0x5D88E5 + 6, 0);
Memory::VP::Patch<float>(0x5D88F9 + 6, 0);
Memory::VP::Patch<float>(0x5D8903 + 6, 0);
Memory::VP::Patch<float>(0x5D890D + 6, 0);
}
else
{
Memory::VP::Patch<float>(0x5D88D1 + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88DB + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88E5 + 6, 0.25f);
Memory::VP::Patch<float>(0x5D88F9 + 6, 0.75f);
Memory::VP::Patch<float>(0x5D8903 + 6, 0.75f);
Memory::VP::Patch<float>(0x5D890D + 6, 0.75f);
}
} );
#endif
}
} }
#endif
// Moonphases // Moonphases
// Not taking effect with new skygfx since aap has it too now // Not taking effect with new skygfx since aap has it too now