Skip to content

Commit 6b9e971

Browse files
authored
Merge pull request #1084 from TheGwyd/Calculate-Delay-While-At-Stopped-Stations
Timetable: Calculate Delay While Stopped at a Station
2 parents dbddf26 + 70ab352 commit 6b9e971

File tree

1 file changed

+7
-0
lines changed
  • Source/Orts.Simulation/Simulation/Timetables

1 file changed

+7
-0
lines changed

Source/Orts.Simulation/Simulation/Timetables/TTTrain.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10390,6 +10390,12 @@ public override void CheckStationTask()
1039010390
// Get time
1039110391
int eightHundredHours = 8 * 3600;
1039210392
int sixteenHundredHours = 16 * 3600;
10393+
10394+
// Update delay if train might be running late, do not update if train is early and waiting at station
10395+
if (presentTime > StationStops[0].DepartTime)
10396+
{
10397+
Delay = TimeSpan.FromSeconds((presentTime - StationStops[0].DepartTime) % (24 * 3600));
10398+
}
1039310399

1039410400
// If moving, set departed
1039510401
if (Math.Abs(SpeedMpS) > 1.0f)
@@ -10399,6 +10405,7 @@ public override void CheckStationTask()
1039910405
AtStation = false;
1040010406
MayDepart = false;
1040110407
DisplayMessage = "";
10408+
// Update delay when departing, train may now be early
1040210409
if (StationStops[0].ArrivalTime >= 0)
1040310410
{
1040410411
Delay = TimeSpan.FromSeconds((presentTime - StationStops[0].DepartTime) % (24 * 3600));

0 commit comments

Comments
 (0)