diff --git a/SilentPatch/Common.cpp b/SilentPatch/Common.cpp index ed34edd..af7fd80 100644 --- a/SilentPatch/Common.cpp +++ b/SilentPatch/Common.cpp @@ -4,6 +4,21 @@ #include "Patterns.h" #include "StoredCar.h" + +// ============= handling.cfg name matching fix ============= +namespace HandlingNameLoadFix +{ + void strncpy_Fix( const char** destination, const char* source, size_t ) + { + *destination = source; + } + + int strncmp_Fix( const char* str1, const char** str2, size_t ) + { + return strcmp( str1, *str2 ); + } +}; + namespace Common { namespace Patches { void III_VC_Common() @@ -18,6 +33,16 @@ namespace Common { ReadCall( addr, CStoredCar::orgRestoreCar ); InjectHook( addr, &CStoredCar::RestoreCar_SilentPatch ); } + + // Fixed handling.cfg name matching (names don't need unique prefixes anymore) + { + using namespace HandlingNameLoadFix; + + auto findExactWord = pattern( "8D 44 24 10 83 C4 0C 57" ).get_one(); + + InjectHook( findExactWord.get( -5 ), strncpy_Fix ); + InjectHook( findExactWord.get( 0xD ), strncmp_Fix ); + } } } } \ No newline at end of file diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index d7b829b..7e910a4 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1430,6 +1430,20 @@ namespace KeyboardInputFix } } +// ============= handling.cfg name matching fix ============= +namespace HandlingNameLoadFix +{ + void strncpy_Fix( const char** destination, const char* source, size_t ) + { + *destination = source; + } + + int strncmp_Fix( const char* str1, const char** str2, size_t ) + { + return strcmp( str1, *str2 ); + } +}; + #ifndef NDEBUG @@ -3583,6 +3597,15 @@ void Patch_SA_10() Nop( 0x541E2B, 2 ); Nop( 0x541E3C, 2 ); } + + + // Fixed handling.cfg name matching (names don't need unique prefixes anymore) + { + using namespace HandlingNameLoadFix; + + InjectHook( 0x6F4F58, strncpy_Fix ); + InjectHook( 0x6F4F64, strncmp_Fix ); + } } void Patch_SA_11() @@ -4875,6 +4898,16 @@ void Patch_SA_NewSteam_Common() Nop( updatePads.get( 20 ), 2 ); Nop( updatePads.get( 37 ), 2 ); } + + // Fixed handling.cfg name matching (names don't need unique prefixes anymore) + { + using namespace HandlingNameLoadFix; + + auto findExactWord = pattern( "8B 55 08 56 8D 4D EC" ).get_one(); // 0x6F849B + + InjectHook( findExactWord.get( -5 ), strncpy_Fix ); + InjectHook( findExactWord.get( 9 ), strncmp_Fix ); + } }