mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
Metric/Imperial check based on Windows locale settings and on INI/debug menu override (SA 1.0 only for now)
This commit is contained in:
parent
4d02505521
commit
10130d0f37
1 changed files with 39 additions and 0 deletions
|
@ -1543,6 +1543,25 @@ namespace TrueInvicibility
|
|||
}
|
||||
}
|
||||
|
||||
namespace Localization
|
||||
{
|
||||
static int8_t forcedUnits = -1; // 0 - metric, 1 - imperial
|
||||
|
||||
bool IsMetric_LocaleBased()
|
||||
{
|
||||
if ( forcedUnits != -1 ) return forcedUnits == 0;
|
||||
|
||||
unsigned int LCData;
|
||||
if ( GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_IMEASURE|LOCALE_RETURN_NUMBER, reinterpret_cast<LPTSTR>(&LCData), sizeof(LCData) / sizeof(TCHAR) ) != 0 )
|
||||
{
|
||||
return LCData == 0;
|
||||
}
|
||||
|
||||
// If fails, default to metric. Hopefully never fails though
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ============= LS-RP Mode stuff =============
|
||||
namespace LSRPMode
|
||||
{
|
||||
|
@ -2940,6 +2959,19 @@ BOOL InjectDelayedPatches_10()
|
|||
}
|
||||
}
|
||||
|
||||
// Locale based metric/imperial system INI/debug menu
|
||||
{
|
||||
using namespace Localization;
|
||||
|
||||
forcedUnits = static_cast<int8_t>(GetPrivateProfileIntW(L"SilentPatch", L"Units", -1, wcModulePath));
|
||||
if ( bHasDebugMenu )
|
||||
{
|
||||
static const char * const str[] = { "Default", "Metric", "Imperial" };
|
||||
DebugMenuEntry *e = DebugMenuAddVar( "SilentPatch", "Forced units", &forcedUnits, nullptr, 1, -1, 1, str );
|
||||
DebugMenuEntrySetWrap(e, true);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
if ( const int QPCDays = GetPrivateProfileIntW(L"Debug", L"AddDaysToQPC", 0, wcModulePath); QPCDays != 0 )
|
||||
{
|
||||
|
@ -4075,6 +4107,13 @@ void Patch_SA_10()
|
|||
Nop( 0x44ACDC, 6 );
|
||||
|
||||
|
||||
// Locale based metric/imperial system
|
||||
{
|
||||
using namespace Localization;
|
||||
|
||||
InjectHook( 0x56D220, IsMetric_LocaleBased, PATCH_JUMP );
|
||||
}
|
||||
|
||||
#if FULL_PRECISION_D3D
|
||||
// Test - full precision D3D device
|
||||
Patch<uint8_t>( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE );
|
||||
|
|
Loading…
Reference in a new issue