Skip to content

Commit

Permalink
Merge Sync for custom radio stations (mr-564)
Browse files Browse the repository at this point in the history
4bf7006 - fix(game): sync for custom radio stations
  • Loading branch information
prikolium-cfx committed Oct 21, 2024
2 parents 31adb74 + 4bf7006 commit 498bcf4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions code/components/gta-core-five/src/PatchVehicleRadioSync.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <StdInc.h>
#include <Hooking.h>
#include <CrossBuildRuntime.h>

static hook::cdecl_stub<void*(int)> GetRadioStationByArrayIndex([]()
{
return hook::get_pattern("3B 0D ? ? ? ? 73 ? 48 8B 05 ? ? ? ? 8B C9");
});

static hook::cdecl_stub<int(void*)> 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<char>("E8 ? ? ? ? 48 83 BB ? ? ? ? ? 48 8B F0 48 89 83");
hook::call(location, GetRadioStationByMetaIndex);

location = hook::get_pattern<char>("E8 ? ? ? ? 83 C0 ? 89 83");
hook::call(location, GetRadioStationMetaIndex);
}
});

0 comments on commit 498bcf4

Please sign in to comment.