Skip to content

Commit

Permalink
Correct a bug in Control Car
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewell committed Jan 6, 2024
1 parent ffaeec0 commit c3a572a
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 c3a572a

Please sign in to comment.