@@ -1828,42 +1828,47 @@ public override void Update(float elapsedClockSeconds)
18281828 var gearloco = this as MSTSDieselLocomotive ;
18291829
18301830 // Pass Gearbox commands
1831+
1832+
1833+
1834+
18311835 // Note - at the moment there is only one GearBox Controller created, but a gearbox for each diesel engine is created.
18321836 // This code keeps all gearboxes in the locomotive aligned with the first engine and gearbox.
1833- if ( gearloco != null && gearloco . DieselTransmissionType == MSTSDieselLocomotive . DieselTransmissionTypes . Mechanic && GearBoxController . CurrentNotch != previousChangedGearBoxNotch && IsLeadLocomotive ( ) )
1837+ if ( gearloco != null && gearloco . DieselTransmissionType == MSTSDieselLocomotive . DieselTransmissionTypes . Mechanic && GearBoxController . CurrentNotch != previousChangedGearBoxNotch )
18341838 {
1835- // pass gearbox command key to other gearboxes in the same locomotive, only do the current locomotive
1839+ // pass gearbox command key to other gearboxes in the same locomotive, only do the current locomotive
18361840
1837- if ( gearloco == this )
1841+ int ii = 0 ;
1842+ foreach ( var eng in gearloco . DieselEngines . DEList )
18381843 {
1839-
1840- int ii = 0 ;
1841- foreach ( var eng in gearloco . DieselEngines . DEList )
1844+ // don't change the first engine as this is the reference for all the others
1845+ if ( ii != 0 )
18421846 {
1843- // don't change the first engine as this is the reference for all the others
1844- if ( ii != 0 )
1845- {
1846- gearloco . DieselEngines [ ii ] . GearBox . currentGearIndex = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
1847- }
1848-
1849- ii = ii + 1 ;
1847+ gearloco . DieselEngines [ ii ] . GearBox . currentGearIndex = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
18501848 }
1849+
1850+ ii = ii + 1 ;
18511851 }
18521852
1853- // pass gearbox command key to other locomotives in train, don't treat the player locomotive in this fashion.
1853+ }
1854+
1855+ // The lead locomotive passes gearbox commands position to other locomotives in train, don't treat the player locomotive in this fashion.
1856+
1857+ if ( gearloco != null && gearloco . DieselTransmissionType == MSTSDieselLocomotive . DieselTransmissionTypes . Mechanic && GearBoxController . CurrentNotch != previousChangedGearBoxNotch && IsLeadLocomotive ( ) )
1858+ {
1859+
18541860 foreach ( TrainCar car in Train . Cars )
18551861 {
1856- var dieselloco = this as MSTSDieselLocomotive ;
18571862 var locog = car as MSTSDieselLocomotive ;
18581863
1859- if ( locog != null && dieselloco != null && car != this && ! locog . IsLeadLocomotive ( ) )
1864+ if ( locog != null && gearloco != null && car != this && ! locog . IsLeadLocomotive ( ) )
18601865 {
18611866
1862- locog . DieselEngines [ 0 ] . GearBox . currentGearIndex = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
1867+ locog . DieselEngines [ 0 ] . GearBox . currentGearIndex = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex ;
18631868
1864- locog . GearBoxController . CurrentNotch = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1865- locog . GearboxGearIndex = dieselloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1866- locog . GearBoxController . SetValue ( ( float ) dieselloco . GearBoxController . CurrentNotch ) ;
1869+ locog . GearBoxController . CurrentNotch = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1870+ locog . GearboxGearIndex = gearloco . DieselEngines [ 0 ] . GearBox . CurrentGearIndex + 1 ;
1871+ locog . GearBoxController . SetValue ( ( float ) gearloco . GearBoxController . CurrentNotch ) ;
18671872
18681873 locog . Simulator . Confirmer . ConfirmWithPerCent ( CabControl . GearBox , CabSetting . Increase , locog . GearBoxController . CurrentNotch ) ;
18691874 locog . AlerterReset ( TCSEvent . GearBoxChanged ) ;
0 commit comments