@@ -3058,13 +3058,6 @@ public virtual bool PostInit()
30583058 if (IsActualPlayerTrain)
30593059 {
30603060 SetTrainSpeedLoggingFlag();
3061-
3062-
3063- // if debug, print out all passing paths
3064-
3065- #if DEBUG_DEADLOCK
3066- Printout_PassingPaths();
3067- #endif
30683061 }
30693062
30703063 return (validPosition);
@@ -13447,6 +13440,7 @@ public bool CreateStationStop(int platformStartID, int arrivalTime, int departTi
1344713440 false,
1344813441 false,
1344913442 false,
13443+ false,
1345013444 StationStop.STOPTYPE.STATION_STOP);
1345113445
1345213446 thisStation.arrivalDT = arrivalDT;
@@ -16332,6 +16326,7 @@ public StationStop CalculateStationStop(int platformStartID, int arrivalTime, in
1633216326 false,
1633316327 false,
1633416328 false,
16329+ false,
1633516330 StationStop.STOPTYPE.STATION_STOP);
1633616331
1633716332 thisStation.arrivalDT = arrivalDT;
@@ -20832,9 +20827,14 @@ public enum STOPTYPE
2083220827 public bool RestrictPlatformToSignal = false; // restrict end of platform to signal position
2083320828 public bool ExtendPlatformToSignal = false; // extend end of platform to next signal position
2083420829 public bool EndStop = false; // train terminates at station
20830+ public bool AllowDepartEarly = false; // train is allowed to depart early
2083520831 public List<int> ConnectionsWaiting = new List<int>(); // List of trains waiting
2083620832 public Dictionary<int, int> ConnectionsAwaited = new Dictionary<int, int>(); // List of awaited trains : key = trainno., value = arr time
2083720833 public Dictionary<int, WaitInfo> ConnectionDetails = new Dictionary<int, WaitInfo>(); // Details of connection : key = trainno., value = wait info
20834+ public RequestStop ReqStopDetails = null; // Request stop details
20835+ public int PassTime; // Passing time (int)
20836+ public DateTime passDT; // Passing time (DateTime)
20837+ public bool PassingOnly;
2083820838
2083920839 //================================================================================================//
2084020840 //
@@ -20843,9 +20843,9 @@ public enum STOPTYPE
2084320843
2084420844 public StationStop(int platformReference, PlatformDetails platformItem, int subrouteIndex, int routeIndex,
2084520845 int tcSectionIndex, int direction, int exitSignal, bool holdSignal, bool noWaitSignal, bool noClaimAllowed, float stopOffset,
20846- int arrivalTime, int departTime, bool terminal, int? actualMinStopTime, float? keepClearFront, float? keepClearRear,
20846+ int? arrivalTime, int? departTime, bool terminal, int? actualMinStopTime, float? keepClearFront, float? keepClearRear,
2084720847 bool forcePosition, bool closeupSignal, bool closeup,
20848- bool restrictPlatformToSignal, bool extendPlatformToSignal, bool endStop, STOPTYPE actualStopType)
20848+ bool restrictPlatformToSignal, bool extendPlatformToSignal, bool endStop, bool allowdepartearly, STOPTYPE actualStopType)
2084920849 {
2085020850 ActualStopType = actualStopType;
2085120851 PlatformReference = platformReference;
@@ -20861,14 +20861,21 @@ public StationStop(int platformReference, PlatformDetails platformItem, int subr
2086120861 StopOffset = stopOffset;
2086220862 if (actualStopType == STOPTYPE.STATION_STOP)
2086320863 {
20864- ArrivalTime = Math.Max(0, arrivalTime);
20865- DepartTime = Math.Max(0, departTime);
20864+ if (arrivalTime.HasValue)
20865+ {
20866+ ArrivalTime = Math.Max(0, arrivalTime.Value);
20867+ DepartTime = Math.Max(0, departTime.Value);
20868+ }
20869+ else
20870+ {
20871+ ArrivalTime = DepartTime = -1;
20872+ }
2086620873 }
2086720874 else
2086820875 // times may be <0 for waiting point
2086920876 {
20870- ArrivalTime = arrivalTime;
20871- DepartTime = departTime;
20877+ ArrivalTime = arrivalTime.Value ;
20878+ DepartTime = departTime.Value ;
2087220879 }
2087320880 ActualArrival = -1;
2087420881 ActualDepart = -1;
@@ -20885,8 +20892,10 @@ public StationStop(int platformReference, PlatformDetails platformItem, int subr
2088520892 RestrictPlatformToSignal = restrictPlatformToSignal;
2088620893 ExtendPlatformToSignal = extendPlatformToSignal;
2088720894 EndStop = endStop;
20895+ AllowDepartEarly = allowdepartearly;
2088820896
2088920897 CallOnAllowed = false;
20898+ PassingOnly = false;
2089020899 }
2089120900
2089220901 //================================================================================================//
@@ -20999,6 +21008,16 @@ public StationStop(BinaryReader inf, Signals signalRef)
2099921008 RestrictPlatformToSignal = inf.ReadBoolean();
2100021009 ExtendPlatformToSignal = inf.ReadBoolean();
2100121010 EndStop = inf.ReadBoolean();
21011+ AllowDepartEarly = inf.ReadBoolean();
21012+
21013+ if (inf.ReadBoolean())
21014+ {
21015+ ReqStopDetails = new RequestStop(inf, signalRef);
21016+ }
21017+
21018+ PassTime = inf.ReadInt32();
21019+ passDT = new DateTime(inf.ReadInt64());
21020+ PassingOnly = inf.ReadBoolean();
2100221021 }
2100321022
2100421023 //================================================================================================//
@@ -21122,6 +21141,21 @@ public void Save(BinaryWriter outf)
2112221141 outf.Write(RestrictPlatformToSignal);
2112321142 outf.Write(ExtendPlatformToSignal);
2112421143 outf.Write(EndStop);
21144+ outf.Write(AllowDepartEarly);
21145+
21146+ if (ReqStopDetails != null)
21147+ {
21148+ outf.Write(true);
21149+ ReqStopDetails.Save(outf);
21150+ }
21151+ else
21152+ {
21153+ outf.Write(false);
21154+ }
21155+
21156+ outf.Write(PassTime);
21157+ outf.Write((Int64)passDT.Ticks);
21158+ outf.Write(PassingOnly);
2112521159 }
2112621160
2112721161 /// <summary>
@@ -21144,6 +21178,21 @@ public int CalculateDepartTime(int presentTime, Train stoppedTrain)
2114421178 int eightHundredHours = 8 * 3600;
2114521179 int sixteenHundredHours = 16 * 3600;
2114621180
21181+ int stopTime = 0;
21182+
21183+ // allow to depart early if set (timetable mode only, so no need to check for valid schedule)
21184+ // also allow to depart after boarding time if arrival time is not set
21185+ if (AllowDepartEarly || ArrivalTime < 0)
21186+ {
21187+ stoppedTrain.ComputeTrainBoardingTime(this, ref stopTime);
21188+ ActualDepart = ActualArrival + stopTime;
21189+
21190+ // correct for times around midnight
21191+ if (ActualDepart > 24 * 3600) ActualDepart -= 24 * 3600;
21192+ if (DepartTime == 0) DepartTime = ActualDepart;
21193+ return stopTime;
21194+ }
21195+
2114721196 // preset depart to booked time
2114821197 ActualDepart = DepartTime;
2114921198
@@ -21158,7 +21207,7 @@ public int CalculateDepartTime(int presentTime, Train stoppedTrain)
2115821207 }
2115921208
2116021209 // correct stop time for stop around midnight
21161- int stopTime = DepartTime - ArrivalTime;
21210+ stopTime = DepartTime - ArrivalTime;
2116221211 if (DepartTime < eightHundredHours && ArrivalTime > sixteenHundredHours) // stop over midnight
2116321212 {
2116421213 stopTime += (24 * 3600);
0 commit comments