@@ -72,8 +72,8 @@ public class AITrain : Train
7272 public Service_Definition ServiceDefinition = null ; // train's service definition in .act file
7373 public bool UncondAttach = false ; // if false it states that train will unconditionally attach to a train on its path
7474
75- public float doorOpenDelay = - 1f ;
76- public float doorCloseAdvance = - 1f ;
75+ public float DoorOpenTimer = - 1f ;
76+ public float DoorCloseTimer = - 1f ;
7777 public AILevelCrossingHornPattern LevelCrossingHornPattern { get ; set ; }
7878
7979 public float PathLength ;
@@ -244,9 +244,9 @@ public AITrain(Simulator simulator, BinaryReader inf, AI airef)
244244 Efficiency = inf . ReadSingle ( ) ;
245245 MaxVelocityA = inf . ReadSingle ( ) ;
246246 UncondAttach = inf . ReadBoolean ( ) ;
247- doorCloseAdvance = inf . ReadSingle ( ) ;
248- doorOpenDelay = inf . ReadSingle ( ) ;
249- if ( ! Simulator . TimetableMode && doorOpenDelay <= 0 && doorCloseAdvance > 0 && Simulator . OpenDoorsInAITrains &&
247+ DoorCloseTimer = inf . ReadSingle ( ) ;
248+ DoorOpenTimer = inf . ReadSingle ( ) ;
249+ if ( ! Simulator . TimetableMode && DoorOpenTimer <= 0 && DoorCloseTimer > 0 && Simulator . OpenDoorsInAITrains &&
250250 MovementState == AI_MOVEMENT_STATE . STATION_STOP && StationStops . Count > 0 )
251251 {
252252 StationStop thisStation = StationStops [ 0 ] ;
@@ -337,8 +337,8 @@ public override void Save(BinaryWriter outf)
337337 outf . Write ( Efficiency ) ;
338338 outf . Write ( MaxVelocityA ) ;
339339 outf . Write ( UncondAttach ) ;
340- outf . Write ( doorCloseAdvance ) ;
341- outf . Write ( doorOpenDelay ) ;
340+ outf . Write ( DoorCloseTimer ) ;
341+ outf . Write ( DoorOpenTimer ) ;
342342 if ( LevelCrossingHornPattern != null )
343343 {
344344 outf . Write ( 0 ) ;
@@ -1851,13 +1851,12 @@ public virtual void UpdateStationState(float elapsedClockSeconds, int presentTim
18511851 thisStation . ActualArrival = presentTime ;
18521852 var stopTime = thisStation . CalculateDepartTime ( presentTime , this ) ;
18531853 actualdepart = thisStation . ActualDepart ;
1854- doorOpenDelay = 4.0f ;
1855- doorCloseAdvance = stopTime - 10.0f ;
1856- if ( PreUpdate ) doorCloseAdvance -= 10 ;
1857- if ( doorCloseAdvance - 6 < doorOpenDelay )
1854+ DoorOpenTimer = PreUpdate ? 0 : 4 ;
1855+ DoorCloseTimer = PreUpdate ? stopTime - 20 : stopTime - 10.0f ;
1856+ if ( DoorCloseTimer - 6 < DoorOpenTimer )
18581857 {
1859- doorOpenDelay = 0 ;
1860- doorCloseAdvance = stopTime - 3 ;
1858+ DoorOpenTimer = 0 ;
1859+ DoorCloseTimer = Math . Max ( stopTime - 3 , 0 ) ;
18611860 }
18621861
18631862#if DEBUG_REPORTS
@@ -1887,10 +1886,10 @@ public virtual void UpdateStationState(float elapsedClockSeconds, int presentTim
18871886 if ( ! IsFreight && Simulator . OpenDoorsInAITrains )
18881887 {
18891888 var frontIsFront = thisStation . PlatformReference == thisStation . PlatformItem . PlatformFrontUiD ;
1890- if ( doorOpenDelay > 0 )
1889+ if ( DoorOpenTimer >= 0 )
18911890 {
1892- doorOpenDelay -= elapsedClockSeconds ;
1893- if ( doorOpenDelay < 0 )
1891+ DoorOpenTimer -= elapsedClockSeconds ;
1892+ if ( DoorOpenTimer < 0 )
18941893 {
18951894 if ( thisStation . PlatformItem . PlatformSide [ 0 ] )
18961895 {
@@ -1904,19 +1903,19 @@ public virtual void UpdateStationState(float elapsedClockSeconds, int presentTim
19041903 }
19051904 }
19061905 }
1907- if ( doorCloseAdvance > 0 )
1906+ if ( DoorCloseTimer >= 0 )
19081907 {
1909- doorCloseAdvance -= elapsedClockSeconds ;
1910- if ( doorCloseAdvance < 0 )
1908+ DoorCloseTimer -= elapsedClockSeconds ;
1909+ if ( DoorCloseTimer < 0 )
19111910 {
19121911 if ( thisStation . PlatformItem . PlatformSide [ 0 ] )
19131912 {
1914- // Open left doors
1913+ // Close left doors
19151914 SetDoors ( frontIsFront ? DoorSide . Right : DoorSide . Left , false ) ;
19161915 }
19171916 if ( thisStation . PlatformItem . PlatformSide [ 1 ] )
19181917 {
1919- // Open right doors
1918+ // Close right doors
19201919 SetDoors ( frontIsFront ? DoorSide . Left : DoorSide . Right , false ) ;
19211920 }
19221921 }
0 commit comments