diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index e346b47..274c56c 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -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(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;