Skip to content

Commit 7bce293

Browse files
committed
Force AI trains to turn on power supply
1 parent cf687d4 commit 7bce293

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Source/Orts.Simulation/Simulation/AIs/AI.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,11 +927,20 @@ public AITrain CreateAITrainDetail(Service_Definition sd, Traffic_Service_Defini
927927
}
928928

929929
if (train.InitialSpeed != 0)
930+
{
930931
car.SignalEvent(PowerSupplyEvent.RaisePantograph, 1);
932+
933+
if (car is MSTSLocomotive loco)
934+
loco.SetPower(true);
935+
}
931936
}
932937
else
933938
{
934939
car.SignalEvent(PowerSupplyEvent.RaisePantograph, 1);
940+
941+
if (car is MSTSLocomotive loco)
942+
loco.SetPower(true);
943+
935944
car.CarID = "AI" + train.Number.ToString() + " - " + (train.Cars.Count - 1).ToString();
936945
}
937946

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ public override void SwitchToPlayerControl()
13921392
public override void SwitchToAutopilotControl()
13931393
{
13941394
SetDirection(Direction.Forward);
1395-
if (!LocomotivePowerSupply.MainPowerSupplyOn)
1395+
if (!LocomotivePowerSupply.MainPowerSupplyOn || !LocomotivePowerSupply.BatteryOn || !LocomotivePowerSupply.MasterKey.On)
13961396
{
13971397
LocomotivePowerSupply.HandleEvent(PowerSupplyEvent.QuickPowerOn);
13981398
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,7 @@ public override void Update(float elapsedClockSeconds)
20472047

20482048
TrainControlSystem.Update(elapsedClockSeconds);
20492049

2050+
LocomotivePowerSupply?.Update(elapsedClockSeconds);
20502051
UpdateControllers(elapsedClockSeconds);
20512052

20522053
// Train Heading - only check the lead locomotive otherwise flipped locomotives further in consist will overwrite the train direction
@@ -2203,9 +2204,6 @@ public override void Update(float elapsedClockSeconds)
22032204

22042205
//Force to display
22052206
FilteredMotiveForceN = CurrentFilter.Filter(MotiveForceN, elapsedClockSeconds);
2206-
2207-
// Only update power supply for player driven locomotives
2208-
LocomotivePowerSupply?.Update(elapsedClockSeconds);
22092207
break;
22102208
default:
22112209
break;

0 commit comments

Comments
 (0)