Skip to content

Commit 491bddb

Browse files
authored
Fix client spoiler upgrade placement on unsupported vehicle models (#4824)
Prevent slot-2 spoiler upgrades from being applied when the vehicle model lacks ug_spoiler support. This avoids SA fallback frame substitution that places spoilers inside the cabin or at incorrect offsets. Applied the check in ForceAddUpgrade before calling AddVehicleUpgrade. Tested with a resource: supported models still get spoilers (e.g via autopimp in race); unsupported models no longer get mispositioned spoilers.
1 parent 076b44d commit 491bddb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Client/mods/deathmatch/logic/CVehicleUpgrades.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,20 @@ void CVehicleUpgrades::ForceAddUpgrade(unsigned short usUpgrade)
610610
CVehicle* pVehicle = m_pVehicle->GetGameVehicle();
611611
if (pVehicle)
612612
{
613+
// Spoiler upgrades (slot 2) must not be applied if the vehicle model
614+
// doesn't have the "ug_spoiler" frame. Otherwise, SA's AddUpgrade will
615+
// call GetFrameFromId and get NULL, triggering the crash-fix fallback
616+
// that attaches the spoiler to the wrong frame.
617+
if (ucSlot == 2)
618+
{
619+
CModelInfo* pVehicleModelInfo = g_pGame->GetModelInfo(m_pVehicle->GetModel());
620+
if (!pVehicleModelInfo || !pVehicleModelInfo->GetVehicleSupportedUpgrades().m_bSpoiler)
621+
{
622+
// Vehicle doesn't support this spoiler upgrade - skip it
623+
return;
624+
}
625+
}
626+
613627
// Grab the upgrade model
614628
CModelInfo* pModelInfo = g_pGame->GetModelInfo(usUpgrade);
615629
if (pModelInfo)

0 commit comments

Comments
 (0)