Skip to content

Commit b02a6e5

Browse files
authored
Merge pull request #909 from peternewell/control_car_bug
Correct Control Car crash bug
2 parents abb8eb9 + c3a572a commit b02a6e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSControlTrailerCar.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Orts.Simulation.RollingStocks
4141
{
4242
public class MSTSControlTrailerCar : MSTSLocomotive
4343
{
44-
public int ControllerNumberOfGears = 1;
44+
public int ControllerNumberOfGears = 0;
4545
bool HasGearController = false;
4646
bool ControlGearUp = false;
4747
bool ControlGearDown = false;
@@ -174,7 +174,7 @@ public override void Update(float elapsedClockSeconds)
174174
{
175175
var locog = car as MSTSDieselLocomotive;
176176

177-
if (locog != null && car != this && !locog.IsLeadLocomotive() && (ControlGearDown || ControlGearUp))
177+
if (locog != null && locog.DieselEngines[0].GearBox != null && locog.DieselEngines[0].GearBox != null && car != this && !locog.IsLeadLocomotive() && (ControlGearDown || ControlGearUp))
178178
{
179179
if (ControlGearUp)
180180
{
@@ -194,7 +194,7 @@ public override void Update(float elapsedClockSeconds)
194194
}
195195

196196
// Read values for the HuD and other requirements, will be based upon the last motorcar
197-
if (locog != null)
197+
if (locog != null && locog.DieselEngines[0].GearBox != null && locog.DieselEngines[0].GearBox != null)
198198
{
199199
ControlGearIndex = locog.DieselEngines[0].GearBox.CurrentGearIndex;
200200
ControlGearIndication = locog.DieselEngines[0].GearBox.GearIndication;

0 commit comments

Comments
 (0)