Door closing sound: fix AI stuck between stations and lock doors when opening

This commit is contained in:
Marc Riera 2024-12-13 00:17:13 +01:00
parent 0d696fb381
commit 261c1fa9c1

View file

@ -118,11 +118,18 @@ namespace OpenbveFcmbTrainPlugin
// Use departure time - door closing sound duration // Use departure time - door closing sound duration
AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration; AiTriggerDoorClosingSound |= CurrentTime.Seconds >= route.CurrentStation.DepartureTime - DoorClosingSoundDuration;
} }
// TODO: AI gets stuck if doors open between stations, check distance to stop point
} }
else 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 else
@ -166,6 +173,10 @@ namespace OpenbveFcmbTrainPlugin
{ {
DoorOpenTime = CurrentTime; 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;
} }
/// <summary>Is called when the device should perform the AI.</summary> /// <summary>Is called when the device should perform the AI.</summary>