From 5154c47ae229a9e0afe3d6fa8110d8a04d2005e9 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 2 Apr 2020 17:59:01 +0200 Subject: [PATCH] Sorted HierarchyTypoFix + added "transmision" typos from Dumper --- SilentPatchSA/SilentPatchSA.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index e8089d8..620c283 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1369,20 +1369,36 @@ TestFirelaAndFlags_UpdateMovingCollision: namespace HierarchyTypoFix { // Allow wheel_lm vs wheel_lm_dummy and miscX vs misc_X typos + // Must be sorted by second parameter constexpr std::pair typosAndFixes[] = { - { "wheel_lm_dummy", "wheel_lm" }, + { "boat_moving_hi", "boat_moving" }, { "misc_a", "misca" }, { "misc_b", "miscb" }, - { "boat_moving_hi", "boat_moving" }, + { "transmission_f", "transmision_f" }, + { "transmission_r", "transmision_r" }, + { "wheel_lm_dummy", "wheel_lm" }, }; int strcasecmp( const char* dataName, const char* nodeName ) { + /*assert( std::is_sorted(std::begin(typosAndFixes), std::end(typosAndFixes), [] (const auto& a, const auto& b) { + return _stricmp( a.second, b.second ) < 0; + }) );*/ + + const int origComp = _stricmp( dataName, nodeName ); + if ( origComp == 0 ) return 0; + for ( const auto& typo : typosAndFixes ) { - if ( _stricmp( dataName, typo.first ) == 0 && _stricmp( nodeName, typo.second ) == 0 ) return 0; + const int nodeComp = _stricmp( typo.second, nodeName ); + if ( nodeComp > 0 ) break; + + if ( nodeComp == 0 && _stricmp( typo.first, dataName ) == 0 ) + { + return 0; + } } - return _stricmp( dataName, nodeName ); + return origComp; } }