Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Control Car crash bug #909

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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