From e7564c0d0f001ba9d5d608e52ff86dff28c6902b Mon Sep 17 00:00:00 2001 From: peternewell Date: Thu, 25 Aug 2022 19:10:12 +1000 Subject: [PATCH] Correct an issue with gearbox not changing on multiple engines --- .../Simulation/RollingStocks/MSTSLocomotive.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs b/Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs index fbffa4e2e7..ae79811ea9 100644 --- a/Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs +++ b/Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs @@ -1821,7 +1821,7 @@ public override void Update(float elapsedClockSeconds) } } - + var gearloco = this as MSTSDieselLocomotive; // pass gearbox command key to other gearboxes in the same locomotive @@ -1832,7 +1832,8 @@ public override void Update(float elapsedClockSeconds) int ii = 0; foreach (var eng in gearloco.DieselEngines.DEList) { - if (gearloco.DieselEngines.Count != 0) + // don't change the first engine as this is the reference for all the others + if (ii != 0) { gearloco.DieselEngines[ii].GearBox.currentGearIndex = gearloco.DieselEngines[0].GearBox.CurrentGearIndex; } @@ -1840,13 +1841,13 @@ public override void Update(float elapsedClockSeconds) ii = ii + 1; } - // pass gearbox command key to other locomotives in train + // pass gearbox command key to other locomotives in train, don't treat the player locomotive in this fashion. foreach (TrainCar car in Train.Cars) { var dieselloco = this as MSTSDieselLocomotive; var locog = car as MSTSDieselLocomotive; - if (locog != null && dieselloco != null && car != this) + if (locog != null && dieselloco != null && car != this && !locog.IsLeadLocomotive()) { locog.DieselEngines[0].GearBox.currentGearIndex = dieselloco.DieselEngines[0].GearBox.CurrentGearIndex; @@ -1857,12 +1858,10 @@ public override void Update(float elapsedClockSeconds) locog.Simulator.Confirmer.ConfirmWithPerCent(CabControl.GearBox, CabSetting.Increase, locog.GearBoxController.CurrentNotch); locog.AlerterReset(TCSEvent.GearBoxChanged); locog.SignalGearBoxChangeEvents(); - - previousChangedGearBoxNotch = GearBoxController.CurrentNotch; // reset loop until next gear change - - } } + + previousChangedGearBoxNotch = GearBoxController.CurrentNotch; // reset loop until next gear change } TrainControlSystem.Update(elapsedClockSeconds);