Skip to content

Commit

Permalink
Merge pull request #909 from peternewell/control_car_bug
Browse files Browse the repository at this point in the history
Correct Control Car crash bug
  • Loading branch information
cjakeman authored Jan 19, 2024
2 parents abb8eb9 + c3a572a commit b02a6e5
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Orts.Simulation.RollingStocks
{
public class MSTSControlTrailerCar : MSTSLocomotive
{
public int ControllerNumberOfGears = 1;
public int ControllerNumberOfGears = 0;
bool HasGearController = false;
bool ControlGearUp = false;
bool ControlGearDown = false;
Expand Down Expand Up @@ -174,7 +174,7 @@ public override void Update(float elapsedClockSeconds)
{
var locog = car as MSTSDieselLocomotive;

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

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

0 comments on commit b02a6e5

Please sign in to comment.