Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ extern CGameSA* pGame;

static BOOL m_bVehicleSunGlare = false;

// PreRender re-asserts rpATOMICRENDER on all wheel atomics every frame, which re-shows
// the Rhino's middle wheels that SetupModelNodes hides at init. Re-clear the flag here so
// it stays the last write of the frame and the wheels remain invisible like in vanilla.
static RwObject* __cdecl ClearAtomicRenderFlagCB(RwObject* object, void* /*data*/)
{
object->flags &= ~0x04; // rpATOMICRENDER
return object;
}

static void __fastcall RehideRhinoMiddleWheels(CAutomobileSAInterface* vehicle)
{
if (!vehicle || vehicle->m_nModelIndex != 432 /* Rhino */)
return;

for (auto comp : {eCarNodes::WHEEL_LM, eCarNodes::WHEEL_RM})
{
if (RwFrame* frame = vehicle->m_aCarNodes[static_cast<std::size_t>(comp)])
RwFrameForAllObjects(frame, (void*)ClearAtomicRenderFlagCB, nullptr);
}
}

static void __declspec(naked) HOOK_Vehicle_PreRender(void)
{
MTA_VERIFY_HOOK_LOCAL_SIZE;
Expand All @@ -51,6 +72,13 @@ static void __declspec(naked) HOOK_Vehicle_PreRender(void)
call eax

noglare:
// Re-hide Rhino middle wheels after PreRender's generic-car block re-shows them.
// esi still points to the CAutomobileSAInterface at this hook site.
pushad
mov ecx, esi
call RehideRhinoMiddleWheels
popad

mov [esp+0D4h], edi
push 6ABD04h
retn
Expand Down