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.