Fixed handling.cfg name matching (names don't need unique prefixes anymore)

III (all), VC (all), SA (all supported)
This commit is contained in:
Silent 2018-04-24 23:59:40 +02:00
parent 34a8b4b648
commit ed397348d1
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
2 changed files with 58 additions and 0 deletions

View file

@ -4,6 +4,21 @@
#include "Patterns.h" #include "Patterns.h"
#include "StoredCar.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 Common {
namespace Patches { namespace Patches {
void III_VC_Common() void III_VC_Common()
@ -18,6 +33,16 @@ namespace Common {
ReadCall( addr, CStoredCar::orgRestoreCar ); ReadCall( addr, CStoredCar::orgRestoreCar );
InjectHook( addr, &CStoredCar::RestoreCar_SilentPatch ); 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<void>( -5 ), strncpy_Fix );
InjectHook( findExactWord.get<void>( 0xD ), strncmp_Fix );
}
} }
} }
} }

View file

@ -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 #ifndef NDEBUG
@ -3583,6 +3597,15 @@ void Patch_SA_10()
Nop( 0x541E2B, 2 ); Nop( 0x541E2B, 2 );
Nop( 0x541E3C, 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() void Patch_SA_11()
@ -4875,6 +4898,16 @@ void Patch_SA_NewSteam_Common()
Nop( updatePads.get<void>( 20 ), 2 ); Nop( updatePads.get<void>( 20 ), 2 );
Nop( updatePads.get<void>( 37 ), 2 ); Nop( updatePads.get<void>( 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<void>( -5 ), strncpy_Fix );
InjectHook( findExactWord.get<void>( 9 ), strncmp_Fix );
}
} }