@@ -427,8 +427,6 @@ public float OdometerM
427427 public float CombinedControlSplitPosition ;
428428 public bool HasSmoothStruc ;
429429
430- bool controlTrailerBrakeSystemSet = false ;
431-
432430 public float MaxContinuousForceN ;
433431 public float SpeedOfMaxContinuousForceMpS ; // Speed where maximum tractive effort occurs
434432 public float MSTSSpeedOfMaxContinuousForceMpS ; // Speed where maximum tractive effort occurs - MSTS parameter if used
@@ -2018,32 +2016,6 @@ public void DynamicBrakeBlending(float elapsedClockSeconds)
20182016 /// </summary>
20192017 public override void Update ( float elapsedClockSeconds )
20202018 {
2021- // A control car typically doesn't have its own compressor and relies on the attached power car. However OR uses the lead locomotive as the reference car for compressor calculations.
2022- // Hence whilst users are encouraged to leave these parameters out of the ENG file, they need to be setup for OR to work correctly.
2023- // Some parameters need to be split across the unpowered and powered car for correct timing and volume calculations.
2024- // This setup loop is only processed the first time that update is run.
2025- if ( EngineType == EngineTypes . Control && ! controlTrailerBrakeSystemSet )
2026- {
2027- FindControlActiveLocomotive ( ) ;
2028-
2029- if ( ControlActiveLocomotive != null )
2030- {
2031- // Split reservoir volume across the power car and the active locomotive
2032- MainResVolumeM3 = ControlActiveLocomotive . MainResVolumeM3 / 2 ;
2033- ControlActiveLocomotive . MainResVolumeM3 = MainResVolumeM3 ;
2034-
2035- MaxMainResPressurePSI = ControlActiveLocomotive . MaxMainResPressurePSI ;
2036- MainResPressurePSI = MaxMainResPressurePSI ;
2037- ControlActiveLocomotive . MainResPressurePSI = MainResPressurePSI ;
2038- controlTrailerBrakeSystemSet = true ; // Ensure this loop is only processes the first time update routine run
2039- MaximumMainReservoirPipePressurePSI = ControlActiveLocomotive . MaximumMainReservoirPipePressurePSI ;
2040- CompressorRestartPressurePSI = ControlActiveLocomotive . CompressorRestartPressurePSI ;
2041- MainResChargingRatePSIpS = ControlActiveLocomotive . MainResChargingRatePSIpS ;
2042- BrakePipeChargingRatePSIorInHgpS = ControlActiveLocomotive . BrakePipeChargingRatePSIorInHgpS ;
2043- TrainBrakePipeLeakPSIorInHgpS = ControlActiveLocomotive . TrainBrakePipeLeakPSIorInHgpS ;
2044- }
2045- }
2046-
20472019 var gearloco = this as MSTSDieselLocomotive ;
20482020
20492021 // Pass Gearbox commands
@@ -5559,97 +5531,35 @@ public virtual float GetDataOf(CabViewControl cvc)
55595531
55605532 case CABViewControlTypes . RPM :
55615533 {
5562-
5563- if ( EngineType == EngineTypes . Control )
5564- {
5565- FindControlActiveLocomotive ( ) ;
5566-
5567- if ( ControlActiveLocomotive != null )
5568- {
5569- var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
5570- if ( activeloco . DieselEngines [ 0 ] != null )
5571- data = activeloco . DieselEngines [ 0 ] . RealRPM ;
5572- }
5573-
5574- }
5575- else
5576- {
5577- var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5578- if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5579- data = mstsDieselLocomotive . DieselEngines [ 0 ] . RealRPM ;
5580- }
5534+ var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5535+ if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5536+ data = mstsDieselLocomotive . DieselEngines [ 0 ] . RealRPM ;
55815537 break ;
55825538 }
55835539
55845540 case CABViewControlTypes . RPM_2 :
55855541 {
5586-
5587- FindControlActiveLocomotive ( ) ;
5588-
5589- if ( ControlActiveLocomotive != null )
5590- {
5591- var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
5592- var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5593-
5594- if ( EngineType == EngineTypes . Control && activeloco . DieselEngines . NumOfActiveEngines > 1 )
5595- {
5596-
5597- if ( activeloco . DieselEngines [ 1 ] != null )
5598- data = activeloco . DieselEngines [ 1 ] . RealRPM ;
5599- }
5600- else if ( EngineType == EngineTypes . Diesel && mstsDieselLocomotive . DieselEngines . NumOfActiveEngines > 1 )
5601- {
5602- if ( mstsDieselLocomotive . DieselEngines [ 1 ] != null )
5603- data = mstsDieselLocomotive . DieselEngines [ 1 ] . RealRPM ;
5604- }
5542+ if ( this is MSTSDieselLocomotive mstsDieselLocomotive && mstsDieselLocomotive . DieselEngines . NumOfActiveEngines > 1 )
5543+ {
5544+ if ( mstsDieselLocomotive . DieselEngines [ 1 ] != null )
5545+ data = mstsDieselLocomotive . DieselEngines [ 1 ] . RealRPM ;
56055546 }
5606- break ;
56075547 }
5548+ break ;
56085549
56095550 case CABViewControlTypes . ORTS_DIESEL_TEMPERATURE :
56105551 {
5611-
5612- if ( EngineType == EngineTypes . Control )
5613- {
5614- FindControlActiveLocomotive ( ) ;
5615-
5616- if ( ControlActiveLocomotive != null )
5617- {
5618- var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
5619- if ( activeloco . DieselEngines [ 0 ] != null )
5620- data = activeloco . DieselEngines [ 0 ] . DieselTemperatureDeg ;
5621- }
5622-
5623- }
5624- else
5625- {
5626- var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5627- if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5628- data = mstsDieselLocomotive . DieselEngines [ 0 ] . DieselTemperatureDeg ;
5629- }
5552+ var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5553+ if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5554+ data = mstsDieselLocomotive . DieselEngines [ 0 ] . DieselTemperatureDeg ;
56305555 break ;
56315556 }
56325557
56335558 case CABViewControlTypes . ORTS_OIL_PRESSURE :
56345559 {
5635- if ( EngineType == EngineTypes . Control )
5636- {
5637- FindControlActiveLocomotive ( ) ;
5638-
5639- if ( ControlActiveLocomotive != null )
5640- {
5641- var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
5642- if ( activeloco . DieselEngines [ 0 ] != null )
5643- data = activeloco . DieselEngines [ 0 ] . DieselOilPressurePSI ;
5644- }
5645-
5646- }
5647- else
5648- {
5649- var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5650- if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5651- data = mstsDieselLocomotive . DieselEngines [ 0 ] . DieselOilPressurePSI ;
5652- }
5560+ var mstsDieselLocomotive = this as MSTSDieselLocomotive ;
5561+ if ( mstsDieselLocomotive . DieselEngines [ 0 ] != null )
5562+ data = mstsDieselLocomotive . DieselEngines [ 0 ] . DieselOilPressurePSI ;
56535563 break ;
56545564 }
56555565
@@ -5852,30 +5762,10 @@ public virtual float GetDataOf(CabViewControl cvc)
58525762 }
58535763 case CABViewControlTypes . WHEELSLIP :
58545764 {
5855- if ( EngineType == EngineTypes . Control )
5856- {
5857- FindControlActiveLocomotive ( ) ;
5858-
5859- if ( ControlActiveLocomotive != null )
5860- {
5861- var activeloco = ControlActiveLocomotive as MSTSDieselLocomotive ;
5862- if ( activeloco . DieselEngines [ 0 ] != null )
5863- {
5864- if ( activeloco . AdvancedAdhesionModel && Train . TrainType != Train . TRAINTYPE . AI_PLAYERHOSTING && ! Train . Autopilot )
5865- data = activeloco . HuDIsWheelSlipWarninq ? 1 : 0 ;
5866- else
5867- data = activeloco . HuDIsWheelSlip ? 1 : 0 ;
5868-
5869- }
5870- }
5871- }
5765+ if ( AdvancedAdhesionModel && Train . TrainType != Train . TRAINTYPE . AI_PLAYERHOSTING && ! Train . Autopilot )
5766+ data = HuDIsWheelSlipWarninq ? 1 : 0 ;
58725767 else
5873- {
5874- if ( AdvancedAdhesionModel && Train . TrainType != Train . TRAINTYPE . AI_PLAYERHOSTING && ! Train . Autopilot )
5875- data = HuDIsWheelSlipWarninq ? 1 : 0 ;
5876- else
5877- data = HuDIsWheelSlip ? 1 : 0 ;
5878- }
5768+ data = HuDIsWheelSlip ? 1 : 0 ;
58795769 break ;
58805770 }
58815771
0 commit comments