Skip to content

Commit 9d5fb93

Browse files
committed
Correct two issues with engines not restoring and efficiency HuD values not displaying correctly.
1 parent e7564c0 commit 9d5fb93

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ public override void Save(BinaryWriter outf)
12661266
outf.Write(GenericItem2);
12671267
outf.Write(RemoteControlGroup);
12681268
outf.Write(DPUnitID);
1269+
outf.Write(PreviousGearBoxNotch);
12691270

12701271
base.Save(outf);
12711272

@@ -1319,6 +1320,7 @@ public override void Restore(BinaryReader inf)
13191320
GenericItem2 = inf.ReadBoolean();
13201321
RemoteControlGroup = inf.ReadInt32();
13211322
DPUnitID = inf.ReadInt32();
1323+
PreviousGearBoxNotch = inf.ReadInt32();
13221324

13231325
base.Restore(inf);
13241326

@@ -1821,24 +1823,29 @@ public override void Update(float elapsedClockSeconds)
18211823
}
18221824
}
18231825

1824-
18251826
var gearloco = this as MSTSDieselLocomotive;
18261827

1827-
// pass gearbox command key to other gearboxes in the same locomotive
1828+
// Pass Gearbox commands
18281829
// Note - at the moment there is only one GearBox Controller created, but a gearbox for each diesel engine is created.
18291830
// This code keeps all gearboxes in the locomotive aligned with the first engine and gearbox.
18301831
if (gearloco != null && gearloco.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic && GearBoxController.CurrentNotch != previousChangedGearBoxNotch)
18311832
{
1832-
int ii = 0;
1833-
foreach (var eng in gearloco.DieselEngines.DEList)
1833+
// pass gearbox command key to other gearboxes in the same locomotive, only do the current locomotive
1834+
1835+
if (gearloco == this)
18341836
{
1835-
// don't change the first engine as this is the reference for all the others
1836-
if (ii != 0)
1837+
1838+
int ii = 0;
1839+
foreach (var eng in gearloco.DieselEngines.DEList)
18371840
{
1838-
gearloco.DieselEngines[ii].GearBox.currentGearIndex = gearloco.DieselEngines[0].GearBox.CurrentGearIndex;
1839-
}
1841+
// don't change the first engine as this is the reference for all the others
1842+
if (ii != 0)
1843+
{
1844+
gearloco.DieselEngines[ii].GearBox.currentGearIndex = gearloco.DieselEngines[0].GearBox.CurrentGearIndex;
1845+
}
18401846

1841-
ii = ii + 1;
1847+
ii = ii + 1;
1848+
}
18421849
}
18431850

18441851
// pass gearbox command key to other locomotives in train, don't treat the player locomotive in this fashion.
@@ -1851,6 +1858,7 @@ public override void Update(float elapsedClockSeconds)
18511858
{
18521859

18531860
locog.DieselEngines[0].GearBox.currentGearIndex = dieselloco.DieselEngines[0].GearBox.CurrentGearIndex;
1861+
18541862
locog.GearBoxController.CurrentNotch = dieselloco.DieselEngines[0].GearBox.CurrentGearIndex + 1;
18551863
locog.GearboxGearIndex = dieselloco.DieselEngines[0].GearBox.CurrentGearIndex + 1;
18561864
locog.GearBoxController.SetValue((float)dieselloco.GearBoxController.CurrentNotch);
@@ -2050,7 +2058,6 @@ public override void Update(float elapsedClockSeconds)
20502058
UpdateHornAndBell(elapsedClockSeconds);
20512059

20522060
UpdateSoundVariables(elapsedClockSeconds);
2053-
20542061
PrevMotiveForceN = MotiveForceN;
20552062
base.Update(elapsedClockSeconds);
20562063

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/DieselEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ public void Update(float elapsedClockSeconds)
10841084
Locomotive.PrevMotiveForceN *= -1f;
10851085

10861086
if ((State == DieselEngineState.Running) && (Locomotive.ThrottlePercent > 0))
1087-
{
1087+
{
10881088
OutputPowerW = (Locomotive.PrevMotiveForceN > 0 ? Locomotive.PrevMotiveForceN * Locomotive.AbsSpeedMpS : 0) / Locomotive.DieselEngines.NumOfActiveEngines;
10891089
}
10901090
else

0 commit comments

Comments
 (0)