Skip to content

Commit a4f1820

Browse files
authored
Fix #4329: preserve plane rotor speed across vehicle recreation (#4860)
#### Summary Preserve plane rotor speed across vehicle recreation so that changing a plane's variant no longer causes a visible propeller stall. Save `m_fPlaneRotorSpeed` in `Destroy()` and restore it in `Create()`, matching the existing heli rotor speed path. #### Motivation Fixes #4329. After #3486, calling `setVehicleVariant` on a plane (e.g. cropduster) causes the propeller to stop for about one second before ramping back up. `Destroy()` saved `m_fHeliRotorSpeed` but never saved `m_fPlaneRotorSpeed`, and `Create()` only restored rotor speed for `CLIENTVEHICLE_HELI`. Planes went through the recreate cycle with prop speed reset to zero. #### Test plan 1. Spawn a cropduster with the engine on 2. Call `setVehicleVariant` repeatedly 3. Observe that the propeller maintains its speed with no interruption #### Checklist * [x] Your code should follow the [coding guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines). * [x] Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.
1 parent 6946e99 commit a4f1820

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Client/mods/deathmatch/logic/CClientVehicle.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,6 +2673,10 @@ void CClientVehicle::Create()
26732673
m_pVehicle->SetHeliRotorSpeed(m_fHeliRotorSpeed);
26742674
m_pVehicle->SetHeliSearchLightVisible(m_bHeliSearchLightVisible);
26752675
}
2676+
else if (m_eVehicleType == CLIENTVEHICLE_PLANE)
2677+
{
2678+
m_pVehicle->SetPlaneRotorSpeed(m_fPlaneRotorSpeed);
2679+
}
26762680

26772681
m_pVehicle->SetUnderwater(IsBelowWater());
26782682

@@ -2995,6 +2999,7 @@ void CClientVehicle::Destroy()
29952999
m_bEngineOn = m_pVehicle->IsEngineOn();
29963000
m_bIsOnGround = IsOnGround();
29973001
m_fHeliRotorSpeed = GetHeliRotorSpeed();
3002+
m_fPlaneRotorSpeed = GetPlaneRotorSpeed();
29983003
m_bHeliSearchLightVisible = IsHeliSearchLightVisible();
29993004
m_HandlingEntry->Assign(m_pVehicle->GetHandlingData());
30003005
m_FlyingHandlingEntry->Assign(m_pVehicle->GetFlyingHandlingData());

0 commit comments

Comments
 (0)