Skip to content

Commit 4f42995

Browse files
committed
Correct bug with steam locomotive chuffing sound
1 parent 5d23965 commit 4f42995

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

+17-4
Original file line numberDiff line numberDiff line change
@@ -3503,13 +3503,26 @@ private void UpdateFX(float elapsedClockSeconds)
35033503
// Variable is proportional to angular speed, value of 10 means 1 rotation/second.
35043504
// If wheel is not slipping then use normal wheel speed, this reduces oscillations in variable1 which causes issues with sounds.
35053505

3506-
if (SteamEngines[i].AttachedAxle.IsWheelSlip)
3506+
if (((Train.TrainType == Train.TRAINTYPE.PLAYER && !Train.Autopilot) || Train.TrainType == Train.TRAINTYPE.AI_PLAYERDRIVEN) && (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics))
35073507
{
3508-
variable[i] = Math.Abs(SteamEngines[i].AttachedAxle.SlipSpeedMpS / SteamEngines[i].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3508+
if (SteamEngines[i].AttachedAxle.IsWheelSlip)
3509+
{
3510+
variable[i] = Math.Abs(SteamEngines[i].AttachedAxle.SlipSpeedMpS / SteamEngines[i].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3511+
}
3512+
else
3513+
{
3514+
variable[i] = Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS / SteamEngines[i].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3515+
}
35093516
}
3510-
else
3517+
else
3518+
// Axle code is not executed if it is an AI train, on Autopilot, or Simple adhesion or simple physics is selected. Hence must use wheelspeed in these instances
35113519
{
3512-
variable[i] = Math.Abs((float)SteamEngines[i].AttachedAxle.AxleSpeedMpS / SteamEngines[i].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3520+
if (WheelSlip)
3521+
variable[i] = Math.Abs(WheelSpeedSlipMpS / SteamEngines[0].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3522+
else
3523+
{
3524+
variable[i] = Math.Abs(WheelSpeedMpS / SteamEngines[0].AttachedAxle.WheelRadiusM / MathHelper.Pi * 5);
3525+
}
35133526
}
35143527

35153528
variable[i] = ThrottlePercent == 0 ? 0 : variable[i];

0 commit comments

Comments
 (0)