@@ -53,6 +53,7 @@ public class AirSinglePipe : MSTSBrakeSystem
5353 protected float MaxAuxilaryChargingRatePSIpS = 1.684f ;
5454 protected float BrakeInsensitivityPSIpS = 0.07f ;
5555 protected float EmergencyValveActuationRatePSIpS = 0 ;
56+ protected bool LegacyEmergencyValve = false ;
5657 protected float EmergencyDumpValveRatePSIpS = 0 ;
5758 protected float EmergencyDumpValveTimerS = 120 ;
5859 protected float ? EmergencyDumpStartTime ;
@@ -173,6 +174,7 @@ public override void InitializeFromCopy(BrakeSystem copy)
173174 TripleValveSensitivityPSI = thiscopy . TripleValveSensitivityPSI ;
174175 BrakeCylinderSpringPressurePSI = thiscopy . BrakeCylinderSpringPressurePSI ;
175176 ServiceMaxCylPressurePSI = thiscopy . ServiceMaxCylPressurePSI ;
177+ LegacyEmergencyValve = thiscopy . LegacyEmergencyValve ;
176178 }
177179
178180 // Get the brake BC & BP for EOT conditions
@@ -341,6 +343,7 @@ public override void Save(BinaryWriter outf)
341343 outf . Write ( ( int ) HoldingValve ) ;
342344 outf . Write ( UniformChargingActive ) ;
343345 outf . Write ( QuickServiceActive ) ;
346+ outf . Write ( LegacyEmergencyValve ) ;
344347 }
345348
346349 public override void Restore ( BinaryReader inf )
@@ -366,6 +369,7 @@ public override void Restore(BinaryReader inf)
366369 HoldingValve = ( ValveState ) inf . ReadInt32 ( ) ;
367370 UniformChargingActive = inf . ReadBoolean ( ) ;
368371 QuickServiceActive = inf . ReadBoolean ( ) ;
372+ LegacyEmergencyValve = inf . ReadBoolean ( ) ;
369373 }
370374
371375 public override void Initialize ( bool handbrakeOn , float maxPressurePSI , float fullServPressurePSI , bool immediateRelease )
@@ -422,7 +426,10 @@ public override void Initialize()
422426 if ( EngineRelayValveRatio == 0 ) EngineRelayValveRatio = RelayValveRatio ;
423427
424428 if ( ( Car as MSTSWagon ) . EmergencyReservoirPresent && EmergencyValveActuationRatePSIpS == 0 )
429+ {
425430 EmergencyValveActuationRatePSIpS = 15 ;
431+ LegacyEmergencyValve = true ;
432+ }
426433
427434 if ( InitialApplicationThresholdPSI == 0 )
428435 {
@@ -473,8 +480,8 @@ public void UpdateTripleValveState(float elapsedClockSeconds)
473480 var prevState = TripleValveState ;
474481 var valveType = ( Car as MSTSWagon ) . BrakeValve ;
475482 bool disableGradient = ! ( Car . Train . LeadLocomotive is MSTSLocomotive ) && Car . Train . TrainType != Orts . Simulation . Physics . Train . TRAINTYPE . STATIC ;
476- // Small workaround to allow trains to more reliably go into emergency after uncoupling
477- bool emergencyTripped = ( Car . Train . TrainType == Orts . Simulation . Physics . Train . TRAINTYPE . STATIC ) ?
483+ // Legacy cars and static cars use a simpler check for emergency applications to ensure emergency applications occur despite simplified physics
484+ bool emergencyTripped = ( Car . Train . TrainType == Orts . Simulation . Physics . Train . TRAINTYPE . STATIC || LegacyEmergencyValve ) ?
478485 BrakeLine1PressurePSI <= 0.75f * EmergResPressurePSI * AuxCylVolumeRatio / ( AuxCylVolumeRatio + 1 ) : Math . Max ( - SmoothedBrakePipeChangePSIpS . SmoothedValue , 0 ) > EmergencyValveActuationRatePSIpS ;
479486
480487 if ( valveType == MSTSWagon . BrakeValveType . Distributor )
0 commit comments