Skip to content

Commit 6ef2a67

Browse files
authored
Merge pull request #933 from peternewell/diesel-mechanic-bug
Fix AI DM crashing
2 parents 90dc329 + a3f56f4 commit 6ef2a67

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,9 +2015,6 @@ public override void Update(float elapsedClockSeconds)
20152015

20162016
// Pass Gearbox commands
20172017

2018-
2019-
2020-
20212018
// Note - at the moment there is only one GearBox Controller created, but a gearbox for each diesel engine is created.
20222019
// This code keeps all gearboxes in the locomotive aligned with the first engine and gearbox.
20232020
if (gearloco != null && gearloco.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic && GearBoxController.CurrentNotch != previousChangedGearBoxNotch)
@@ -2156,8 +2153,13 @@ public override void Update(float elapsedClockSeconds)
21562153
if (de.State != DieselEngineState.Running)
21572154
de.Initialize();
21582155
}
2156+
2157+
// if train is a geared locomotive then set it to automatic operation as AI driver can't operate manual gearboxes
21592158
if (de.GearBox != null)
21602159
de.GearBox.GearBoxOperation = GearBoxOperation.Automatic;
2160+
2161+
// Set gear to "low gear" at start.
2162+
de.GearBox.currentGearIndex = de.GearBox.NumOfGears - 1;
21612163
}
21622164
}
21632165
}

0 commit comments

Comments
 (0)