diff --git a/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs b/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs index 6f1fe771e9..15d5d3e06d 100644 --- a/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs +++ b/Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs @@ -54,6 +54,7 @@ public class AirSinglePipe : MSTSBrakeSystem protected float MaxAuxilaryChargingRatePSIpS = 1.684f; protected float BrakeInsensitivityPSIpS = 0.07f; protected float EmergencyValveActuationRatePSIpS = 0; + protected bool LegacyEmergencyValve = false; protected float EmergencyDumpValveRatePSIpS = 0; protected float EmergencyDumpValveTimerS = 120; protected float? EmergencyDumpStartTime; @@ -174,6 +175,7 @@ public override void InitializeFromCopy(BrakeSystem copy) TripleValveSensitivityPSI = thiscopy.TripleValveSensitivityPSI; BrakeCylinderSpringPressurePSI = thiscopy.BrakeCylinderSpringPressurePSI; ServiceMaxCylPressurePSI = thiscopy.ServiceMaxCylPressurePSI; + LegacyEmergencyValve = thiscopy.LegacyEmergencyValve; } // Get the brake BC & BP for EOT conditions @@ -345,6 +347,7 @@ public override void Save(BinaryWriter outf) outf.Write((int)HoldingValve); outf.Write(UniformChargingActive); outf.Write(QuickServiceActive); + outf.Write(LegacyEmergencyValve); } public override void Restore(BinaryReader inf) @@ -371,6 +374,7 @@ public override void Restore(BinaryReader inf) HoldingValve = (ValveState)inf.ReadInt32(); UniformChargingActive = inf.ReadBoolean(); QuickServiceActive = inf.ReadBoolean(); + LegacyEmergencyValve = inf.ReadBoolean(); } public override void Initialize(bool handbrakeOn, float maxPressurePSI, float fullServPressurePSI, bool immediateRelease) @@ -427,7 +431,10 @@ public override void Initialize() if (EngineRelayValveRatio == 0) EngineRelayValveRatio = RelayValveRatio; if ((Car as MSTSWagon).EmergencyReservoirPresent && EmergencyValveActuationRatePSIpS == 0) + { EmergencyValveActuationRatePSIpS = 15; + LegacyEmergencyValve = true; + } if (InitialApplicationThresholdPSI == 0) { @@ -478,8 +485,8 @@ public void UpdateTripleValveState(float elapsedClockSeconds) var prevState = TripleValveState; var valveType = (Car as MSTSWagon).BrakeValve; bool disableGradient = !(Car.Train.LeadLocomotive is MSTSLocomotive) && Car.Train.TrainType != Orts.Simulation.Physics.Train.TRAINTYPE.STATIC; - // Small workaround to allow trains to more reliably go into emergency after uncoupling - bool emergencyTripped = (Car.Train.TrainType == Orts.Simulation.Physics.Train.TRAINTYPE.STATIC) ? + // Legacy cars and static cars use a simpler check for emergency applications to ensure emergency applications occur despite simplified physics + bool emergencyTripped = (Car.Train.TrainType == Orts.Simulation.Physics.Train.TRAINTYPE.STATIC || LegacyEmergencyValve) ? BrakeLine1PressurePSI <= 0.75f * EmergResPressurePSI * AuxCylVolumeRatio / (AuxCylVolumeRatio + 1) : Math.Max(-SmoothedBrakePipeChangePSIpS.SmoothedValue, 0) > EmergencyValveActuationRatePSIpS; if (valveType == MSTSWagon.BrakeValveType.Distributor)