III: Register Skimmer for SIT_IN_BOAT if an old version of III Aircraft is installed

This commit is contained in:
Silent 2024-05-12 23:08:31 +02:00
parent 1162f4d4bd
commit c2aa895cbf
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1

View File

@ -25,6 +25,28 @@
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
// ============= Mod compatibility stuff =============
namespace ModCompat
{
// If an old version of III Aircraft is installed, register Skimmer for the "Sit in boat" feature.
// If III Aircraft is ever updated, it will start exporting GetBuildNumber and will be expected to register
// Skimmer with SilentPatch by itself (in case an update un-hardcodes its ID). For the current builds, do it ourselves.
bool IIIAircraftNeedsSkimmerFallback(HMODULE module)
{
if (module == nullptr) return false; // III Aircraft not installed
bool bOldModVersion = true;
auto func = (uint32_t(*)())GetProcAddress(module, "GetBuildNumber");
if (func != nullptr)
{
bOldModVersion = func() < 0x200;
}
return bOldModVersion;
}
}
struct PsGlobalType
{
HWND window;
@ -825,6 +847,7 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul
const ModuleList moduleList;
const HMODULE skygfxModule = moduleList.Get(L"skygfx");
const HMODULE iiiAircraftModule = moduleList.Get(L"IIIAircraft");
if (skygfxModule != nullptr)
{
auto attachCarPipe = reinterpret_cast<void(*)(RwObject*)>(GetProcAddress(skygfxModule, "AttachCarPipeToRwObject"));
@ -834,6 +857,11 @@ void InjectDelayedPatches_III_Common( bool bHasDebugMenu, const wchar_t* wcModul
}
}
if (ModCompat::IIIAircraftNeedsSkimmerFallback(iiiAircraftModule))
{
SVF::RegisterFeature(156, SVF::Feature::SIT_IN_BOAT);
}
// Locale based metric/imperial system INI/debug menu
{
using namespace Localization;