diff --git a/code/components/gta-core-five/src/PatchVehicleRadioSync.cpp b/code/components/gta-core-five/src/PatchVehicleRadioSync.cpp new file mode 100644 index 0000000000..bd658b9436 --- /dev/null +++ b/code/components/gta-core-five/src/PatchVehicleRadioSync.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +static hook::cdecl_stub GetRadioStationByArrayIndex([]() +{ + return hook::get_pattern("3B 0D ? ? ? ? 73 ? 48 8B 05 ? ? ? ? 8B C9"); +}); + +static hook::cdecl_stub GetRadioStationArrayIndex([]() +{ + return hook::get_pattern("44 8B 05 ? ? ? ? 33 C0 45 85 C0 74 ? 48 8B 15"); +}); + +void* GetRadioStationByMetaIndex(int idx, int unk) +{ + return GetRadioStationByArrayIndex(idx); +} + +int GetRadioStationMetaIndex(void* station, int unk) +{ + return GetRadioStationArrayIndex(station); +} + +static HookFunction hookFunction([]() +{ + if(xbr::IsGameBuildOrGreater<2944>()) + { + auto location = hook::get_pattern("E8 ? ? ? ? 48 83 BB ? ? ? ? ? 48 8B F0 48 89 83"); + hook::call(location, GetRadioStationByMetaIndex); + + location = hook::get_pattern("E8 ? ? ? ? 83 C0 ? 89 83"); + hook::call(location, GetRadioStationMetaIndex); + } +});