Skip to content

Commit fc73ac8

Browse files
committed
Prevent train from going to manual mode from an explorer activity
1 parent 3023eb3 commit fc73ac8

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Source/Orts.Simulation/Common/Scripting/TrainControlSystem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ public abstract class TrainControlSystem : AbstractTrainScriptClass
487487
/// </summary>
488488
public Action RequestToggleManualMode;
489489
/// <summary>
490+
/// Requests reset of Out of Control Mode.
491+
/// </summary>
492+
public Action ResetOutOfControlMode;
493+
/// <summary>
490494
/// Get bool parameter in the INI file.
491495
/// </summary>
492496
public Func<string, string, bool, bool> GetBoolParameter;

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10193,16 +10193,14 @@ public void RequestToggleManualMode()
1019310193
}
1019410194
else if (ControlMode == TRAIN_CONTROL.EXPLORER)
1019510195
{
10196-
if (LeadLocomotive is MSTSLocomotive locomotive &&
10197-
(locomotive.TrainBrakeController.TCSEmergencyBraking || locomotive.TrainBrakeController.TCSFullServiceBraking))
10198-
{
10199-
locomotive.TrainControlSystem.HandleEvent(TCSEvent.EmergencyBrakingReleasedBySimulator);
10200-
ResetExplorerMode();
10201-
return;
10202-
}
10203-
else if (Simulator.Confirmer != null) // As Confirmer may not be created until after a restore.
10196+
if (Simulator.Confirmer != null) // As Confirmer may not be created until after a restore.
1020410197
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Cannot change to Manual Mode while in Explorer Mode"));
1020510198
}
10199+
else if (ControlMode == TRAIN_CONTROL.OUT_OF_CONTROL && ControlModeBeforeOutOfControl == TRAIN_CONTROL.EXPLORER)
10200+
{
10201+
if (Simulator.Confirmer != null) // As Confirmer may not be created until after a restore.
10202+
Simulator.Confirmer.Message(ConfirmLevel.Warning, Simulator.Catalog.GetString("Cannot change to Manual Mode. Use the Reset Out Of Control Mode command to release brakes"));
10203+
}
1020610204
else
1020710205
{
1020810206
ToggleToManualMode();

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/TrainControlSystem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ public void Initialize()
540540
}
541541
};
542542
Script.RequestToggleManualMode = () => Locomotive.Train.RequestToggleManualMode();
543+
Script.ResetOutOfControlMode = () => Locomotive.Train.ManualResetOutOfControlMode();
543544

544545
// TrainControlSystem INI configuration file
545546
Script.GetBoolParameter = (arg1, arg2, arg3) => LoadParameter<bool>(arg1, arg2, arg3);

0 commit comments

Comments
 (0)