Skip to content

Commit

Permalink
Significant code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Aug 12, 2023
1 parent fba461a commit 9b1987f
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions Client/mods/deathmatch/logic/CClientVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,31 +1463,18 @@ void CClientVehicle::SetWheelStatus(unsigned char ucWheel, unsigned char ucStatu
m_pVehicle->GetDamageManager()->SetWheelStatus((eWheelPosition)(ucWheel), ucGTAStatus);

// Update the wheel's visibility
m_pVehicle->SetWheelVisibility((eWheelPosition)ucWheel, (ucStatus != DT_WHEEL_MISSING));

// restart wheels component visibility (fix #1556)
static const SString strWheelPrefix = "wheel_";

for (const auto& [key, value] : m_ComponentData)
{
SString strComponentName = key;
if (strComponentName.BeginsWith(strWheelPrefix))
{
unsigned char ucComponentWheel;

if (strComponentName == "wheel_lf_dummy")
ucComponentWheel = FRONT_LEFT_WHEEL;
else if (strComponentName == "wheel_rf_dummy")
ucComponentWheel = FRONT_RIGHT_WHEEL;
else if (strComponentName == "wheel_lb_dummy")
ucComponentWheel = REAR_LEFT_WHEEL;
else if (strComponentName == "wheel_rb_dummy")
ucComponentWheel = REAR_RIGHT_WHEEL;

if (ucComponentWheel == ucWheel && m_ucWheelStates[ucWheel] != DT_WHEEL_MISSING && ucStatus != DT_WHEEL_MISSING)
SetComponentVisible(strComponentName, value.m_bVisible);
}
}
SString componentName;

if (ucWheel == FRONT_LEFT_WHEEL)
componentName = "wheel_lf_dummy";
else if (ucWheel == FRONT_RIGHT_WHEEL)
componentName = "wheel_rf_dummy";
else if (ucWheel == REAR_LEFT_WHEEL)
componentName = "wheel_lb_dummy";
else if (ucWheel == REAR_RIGHT_WHEEL)
componentName = "wheel_rb_dummy";

m_pVehicle->SetWheelVisibility((eWheelPosition)ucWheel, (ucStatus != DT_WHEEL_MISSING ? m_ComponentData[componentName].m_bVisible : false));
}
else if (m_eVehicleType == CLIENTVEHICLE_BIKE && ucWheel < 2)
m_pVehicle->SetBikeWheelStatus(ucWheel, ucGTAStatus);
Expand Down

0 comments on commit 9b1987f

Please sign in to comment.