@@ -684,7 +684,7 @@ public void AIUpdate(float elapsedClockSeconds, double clockTime, bool preUpdate
684684
685685 if ( MovementState == AI_MOVEMENT_STATE . AI_STATIC )
686686 {
687- physicsUpdate ( 0 ) ; //required to make train visible ; set elapsed time to zero to avoid actual movement
687+ CalculatePositionOfCars ( 0 , 0 ) ; //required to make train visible ; set elapsed time to zero to avoid actual movement
688688 }
689689 else
690690 {
@@ -5100,6 +5100,32 @@ public void CreateTrainAction(float presentSpeedMpS, float reqSpeedMpS, float di
51005100 // correct trigger for approach distance but not backward beyond present position
51015101 triggerDistanceM = Math . Max ( PresentPosition [ 0 ] . DistanceTravelledM , triggerDistanceM - ( 3.0f * signalApproachDistanceM ) ) ;
51025102
5103+ // for signal stop item : check if action allready in list, if so, remove (can be result of restore action)
5104+ LinkedListNode < DistanceTravelledItem > thisItemLink = requiredActions . First ;
5105+ bool itemFound = false ;
5106+
5107+ while ( thisItemLink != null && ! itemFound )
5108+ {
5109+ DistanceTravelledItem thisDTItem = thisItemLink . Value ;
5110+ if ( thisDTItem is AIActionItem )
5111+ {
5112+ AIActionItem thisActionItem = thisDTItem as AIActionItem ;
5113+ if ( thisActionItem . ActiveItem != null && thisActionItem . NextAction == thisAction )
5114+ {
5115+ if ( thisActionItem . ActiveItem . ObjectDetails . thisRef == thisItem . ObjectDetails . thisRef )
5116+ {
5117+ // equal item, so remove it
5118+ requiredActions . Remove ( thisDTItem ) ;
5119+ itemFound = true ;
5120+ }
5121+ }
5122+ }
5123+ if ( ! itemFound )
5124+ {
5125+ thisItemLink = thisItemLink . Next ;
5126+ }
5127+ }
5128+
51035129 // create and insert action
51045130
51055131 AIActionItem newAction = new AIActionItem ( thisItem , thisAction ) ;
@@ -5298,7 +5324,7 @@ public override void PerformActions(List<DistanceTravelledItem> nowActions)
52985324 }
52995325 else if ( thisAction is ClearMovingTableAction )
53005326 {
5301- ClearMovingTable ( ) ;
5327+ ClearMovingTable ( thisAction ) ;
53025328 }
53035329 else if ( thisAction is AIActionItem && ! ( thisAction is AuxActionItem ) )
53045330 {
@@ -5345,7 +5371,7 @@ public void SetAIPendingSpeedLimit(ActivateSpeedLimit speedInfo)
53455371 else
53465372 AllowedMaxSpeedMpS = Math . Min ( speedInfo . MaxSpeedMpSLimit , Math . Min ( allowedMaxSpeedSignalMpS , allowedMaxTempSpeedLimitMpS ) ) ;
53475373 }
5348- if ( speedInfo . MaxTempSpeedMpSLimit > 0 && ! Simulator . TimetableMode )
5374+ if ( speedInfo . MaxTempSpeedMpSLimit > 0 )
53495375 {
53505376 allowedMaxTempSpeedLimitMpS = allowedAbsoluteMaxTempSpeedLimitMpS ;
53515377 AllowedMaxSpeedMpS = Math . Min ( speedInfo . MaxTempSpeedMpSLimit , Math . Min ( allowedMaxSpeedSignalMpS , allowedMaxSpeedLimitMpS ) ) ;
@@ -5453,22 +5479,41 @@ public void ProcessActionItem(AIActionItem thisItem)
54535479 if ( thisItem . ActiveItem . signal_state == MstsSignalAspect . STOP &&
54545480 thisItem . ActiveItem . ObjectDetails . holdState == HoldState . StationStop )
54555481 {
5456- actionValid = false ;
5482+ // check if train is approaching or standing at station and has not yet departed
5483+ if ( StationStops != null && StationStops . Count >= 1 && AtStation && StationStops [ 0 ] . ExitSignal == thisItem . ActiveItem . ObjectDetails . thisRef )
5484+ {
5485+ actionValid = false ;
54575486
54585487#if DEBUG_REPORTS
54595488 File . AppendAllText ( @"C:\temp\printproc.txt" , "Train " +
54605489 Number . ToString ( ) + " : signal " +
54615490 thisItem . ActiveItem . ObjectDetails . thisRef . ToString ( ) + " at " +
54625491 thisItem . ActivateDistanceM . ToString ( ) + " is held for station stop\n " ) ;
54635492#endif
5464- if ( CheckTrain )
5493+ if ( CheckTrain )
5494+ {
5495+ File . AppendAllText ( @"C:\temp\checktrain.txt" , "Train " +
5496+ Number . ToString ( ) + " : signal " +
5497+ thisItem . ActiveItem . ObjectDetails . thisRef . ToString ( ) + " at " +
5498+ thisItem . ActivateDistanceM . ToString ( ) + " is held for station stop\n " ) ;
5499+ }
5500+ }
5501+ else
54655502 {
5466- File . AppendAllText ( @"C:\temp\checktrain.txt" , "Train " +
5467- Number . ToString ( ) + " : signal " +
5468- thisItem . ActiveItem . ObjectDetails . thisRef . ToString ( ) + " at " +
5469- thisItem . ActivateDistanceM . ToString ( ) + " is held for station stop\n " ) ;
5503+ #if DEBUG_REPORTS
5504+ File . AppendAllText ( @"C:\temp\printproc.txt" , "Train " +
5505+ Number . ToString ( ) + " : signal " +
5506+ thisItem . ActiveItem . ObjectDetails . thisRef . ToString ( ) + " at " +
5507+ thisItem . ActivateDistanceM . ToString ( ) + " is held for station stop but train is no longer stopped in station\n " ) ;
5508+ #endif
5509+ if ( CheckTrain )
5510+ {
5511+ File . AppendAllText ( @"C:\temp\checktrain.txt" , "Train " +
5512+ Number . ToString ( ) + " : signal " +
5513+ thisItem . ActiveItem . ObjectDetails . thisRef . ToString ( ) + " at " +
5514+ thisItem . ActivateDistanceM . ToString ( ) + " is held for station stop but train is no longer stopped in station\n " ) ;
5515+ }
54705516 }
5471-
54725517 }
54735518
54745519 // check if cleared
0 commit comments