Skip cdstream fix if FLA uses enhanced IMGs

This commit is contained in:
Silent 2017-09-26 16:36:49 +02:00
parent 258d1cccc9
commit d6e0f3e74f
3 changed files with 19 additions and 8 deletions

View file

@ -8,21 +8,32 @@
int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock; int32_t (*FLAUtils::GetExtendedID8Func)(const uint8_t* ptr) = FLAUtils::GetExtendedID8_Stock;
int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock; int32_t (*FLAUtils::GetExtendedID16Func)(const uint16_t* ptr) = FLAUtils::GetExtendedID16_Stock;
static HMODULE flaModule = nullptr;
void FLAUtils::Init() void FLAUtils::Init()
{ {
const HMODULE hFLA = GetASIModuleHandle(TEXT("$fastman92limitAdjuster")); flaModule = GetASIModuleHandle(TEXT("$fastman92limitAdjuster"));
if ( hFLA != nullptr ) if ( flaModule != nullptr )
{ {
const auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom8bitBefore" )); const auto function8 = reinterpret_cast<decltype(GetExtendedID8Func)>(GetProcAddress( flaModule, "GetExtendedIDfrom8bitBefore" ));
if ( function8 != nullptr ) if ( function8 != nullptr )
{ {
GetExtendedID8Func = function8; GetExtendedID8Func = function8;
} }
const auto function16 = reinterpret_cast<decltype(GetExtendedID16Func)>(GetProcAddress( hFLA, "GetExtendedIDfrom16bitBefore" )); const auto function16 = reinterpret_cast<decltype(GetExtendedID16Func)>(GetProcAddress( flaModule, "GetExtendedIDfrom16bitBefore" ));
if ( function16 != nullptr ) if ( function16 != nullptr )
{ {
GetExtendedID16Func = function16; GetExtendedID16Func = function16;
} }
} }
}
bool FLAUtils::UsesEnhancedIMGs()
{
if ( flaModule == nullptr ) return false;
const auto func = reinterpret_cast<bool(*)()>(GetProcAddress( flaModule, "IsHandlingOfEnhancedIMGarchivesEnabled" ));
if ( func == nullptr ) return false;
return func();
} }

View file

@ -36,6 +36,7 @@ public:
}; };
static void Init(); static void Init();
static bool UsesEnhancedIMGs();
private: private:
static constexpr int32_t MAX_UINT8_ID = 0xFF; static constexpr int32_t MAX_UINT8_ID = 0xFF;

View file

@ -2912,9 +2912,11 @@ BOOL InjectDelayedPatches_10()
InjectHook(0x713ACB, HandleMoonStuffStub, PATCH_JUMP); InjectHook(0x713ACB, HandleMoonStuffStub, PATCH_JUMP);
} }
FLAUtils::Init();
// Race condition in CdStream fixed // Race condition in CdStream fixed
// Not taking effect with modloader // Not taking effect with modloader
if ( !ModCompat::ModloaderCdStreamRaceConditionAware( modloaderModule ) ) if ( !ModCompat::ModloaderCdStreamRaceConditionAware( modloaderModule ) && !FLAUtils::UsesEnhancedIMGs() )
{ {
ReadCall( 0x406C78, CdStreamSync::orgCdStreamInitThread ); ReadCall( 0x406C78, CdStreamSync::orgCdStreamInitThread );
InjectHook( 0x406C78, CdStreamSync::CdStreamInitThread ); InjectHook( 0x406C78, CdStreamSync::CdStreamInitThread );
@ -2980,9 +2982,6 @@ BOOL InjectDelayedPatches_10()
} }
} }
#endif #endif
FLAUtils::Init();
return FALSE; return FALSE;
} }