Skip to content

Commit

Permalink
Refactor HudNatives
Browse files Browse the repository at this point in the history
  • Loading branch information
KadDarem committed Feb 13, 2025
1 parent d8dacab commit 58a7a2a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions code/components/extra-natives-rdr3/src/HudNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

static void* g_sm_bootstrapInstance;
static void* g_uiMinimap;
static uint8_t* g_minimapType;

static hook::cdecl_stub<void(void*, char)> g_uiMinimap_SetType([]()
{
Expand All @@ -19,6 +20,9 @@ static HookFunction hookFunction([]()
uint32_t uiMinimapOffset = *hook::get_pattern<uint32_t>("33 D2 48 8B CB 45 8D 44 24 ? E8", -16);

g_uiMinimap = (char*)g_sm_bootstrapInstance + uiMinimapOffset;

auto location = hook::get_pattern<uint8_t>("20 14 EF 43 01 00 00 00 10 62 ? ? 00 00 00 00 ?", 12)
g_minimapType = hook::get_address<uint8_t*>(location)
}

fx::ScriptEngine::RegisterNativeHandler("SET_MINIMAP_TYPE", [](fx::ScriptContext& context)
Expand All @@ -31,17 +35,7 @@ static HookFunction hookFunction([]()

fx::ScriptEngine::RegisterNativeHandler("GET_MINIMAP_TYPE", [](fx::ScriptContext& context)
{
uint8_t* pMinimapType = hook::get_address<uint8_t*>(hook::get_pattern<uint8_t>("20 14 EF 43 01 00 00 00 10 62 ? ? 00 00 00 00 ?", 12));

if (!pMinimapType)
{
context.SetResult<int>(-1);
return;
}

uint8_t minimapType = *pMinimapType;

context.SetResult<int>(minimapType);
context.SetResult<int>(*g_minimapType);
});

/*
Expand Down

0 comments on commit 58a7a2a

Please sign in to comment.