diff --git a/src/Devices/AtcBombardier.cs b/src/Devices/AtcBombardier.cs
index f988743..f399635 100644
--- a/src/Devices/AtcBombardier.cs
+++ b/src/Devices/AtcBombardier.cs
@@ -58,25 +58,25 @@ namespace OpenbveFcmbTrainPlugin
private TrackStates TrackState;
/// The time needed by the ATC device to initialize, in seconds.
- private double InitializationTime;
+ private readonly double InitializationTime;
/// A counter to keep track of initialization time, in seconds.
private double InitializationCounter;
/// The blinking time for lamps, in milliseconds.
- private double BlinkTime;
+ private readonly double BlinkTime;
/// A counter to keep track of blink time, in milliseconds.
private double BlinkCounter;
/// The time after which YARD mode enters idle state and engages the service brake, in seconds.
- private double YardIdleTime;
+ private readonly double YardIdleTime;
/// A counter to keep track of YARD mode idle time, in seconds.
private double YardIdleCounter;
/// The maximum speed in YARD mode, in km/h.
- private double YardMaximumSpeed;
+ private readonly double YardMaximumSpeed;
/// Represents an ATC movement permission order.
private class MovementPermission
diff --git a/src/Devices/AtcDimetronic.cs b/src/Devices/AtcDimetronic.cs
index 5d879af..0dd2068 100644
--- a/src/Devices/AtcDimetronic.cs
+++ b/src/Devices/AtcDimetronic.cs
@@ -55,6 +55,7 @@ namespace OpenbveFcmbTrainPlugin
/// Whether ATO is available or not on the train.
private readonly bool AtoAvailable;
+
/// Represents an ATC speed code.
private class SpeedCode
{
diff --git a/src/Devices/Deadman.cs b/src/Devices/Deadman.cs
index 13cb93a..5800cda 100644
--- a/src/Devices/Deadman.cs
+++ b/src/Devices/Deadman.cs
@@ -24,10 +24,10 @@ namespace OpenbveFcmbTrainPlugin
private double Counter;
/// The delay time until the service brake is applied, in seconds.
- private double BrakeDelay = 5.0;
+ private readonly double BrakeDelay = 5.0;
/// Whether the train must be completely stopped to release the brakes.
- private bool FullReset;
+ private readonly bool FullReset;
/// Creates an instance of the Deadman device.
/// The delay before the brakes are applied, in seconds.
diff --git a/src/Devices/DoorClosingSound.cs b/src/Devices/DoorClosingSound.cs
index e3b5527..eb13768 100644
--- a/src/Devices/DoorClosingSound.cs
+++ b/src/Devices/DoorClosingSound.cs
@@ -118,11 +118,18 @@ namespace OpenbveFcmbTrainPlugin
// Use departure time - door closing sound duration
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration;
}
- // TODO: AI gets stuck if doors open between stations, check distance to stop point
}
else
{
- AiTriggerDoorClosingSound = false;
+ // The doors have been opened between stations
+ if (route.CurrentStation.StopPosition - route.CurrentStation.BackwardTolerance > train.State.Location)
+ {
+ AiTriggerDoorClosingSound = true;
+ }
+ else
+ {
+ AiTriggerDoorClosingSound = false;
+ }
}
}
else
@@ -166,6 +173,10 @@ namespace OpenbveFcmbTrainPlugin
{
DoorOpenTime = CurrentTime;
}
+
+ // Set door closing counter to value higher than maximum where doors are allowed to close
+ // This effectively locks the doors when they open
+ DoorClosingSoundCounter = DoorClosingSoundDuration + DoorClosingSoundTimeout;
}
/// Is called when the device should perform the AI.