Skip to content

Commit 58e6767

Browse files
authored
Merge pull request #773 from Roeterdink/WatchdogPingTrainProcessing
Add watchdog ping to Train Processing
2 parents 01607fd + 4543e4b commit 58e6767

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Source/Orts.Simulation/Simulation/Timetables/ProcessTimetable.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public List<TTTrain> ProcessTimetable(string[] arguments, CancellationToken canc
148148

149149
// reduce trainlist using player train info and parameters
150150
bool addPathNoLoadFailure;
151-
trainList = BuildAITrains(trainInfoList, playerTrain, arguments, out addPathNoLoadFailure);
151+
trainList = BuildAITrains(cancellation, trainInfoList, playerTrain, arguments, out addPathNoLoadFailure);
152152
if (!addPathNoLoadFailure) loadPathNoFailure = false;
153153

154154
// set references (required to process commands)
@@ -752,13 +752,15 @@ private TTTrainInfo GetPlayerTrain(ref List<TTTrainInfo> allTrains, string[] arg
752752
/// <param name="allTrains"></param>
753753
/// <param name="playerTrain"></param>
754754
/// <param name="arguments"></param>
755-
private List<TTTrain> BuildAITrains(List<TTTrainInfo> allTrains, TTTrainInfo playerTrain, string[] arguments, out bool allPathsLoaded)
755+
private List<TTTrain> BuildAITrains(CancellationToken cancellation, List<TTTrainInfo> allTrains, TTTrainInfo playerTrain, string[] arguments, out bool allPathsLoaded)
756756
{
757757
allPathsLoaded = true;
758758
List<TTTrain> trainList = new List<TTTrain>();
759759

760760
foreach (TTTrainInfo reqTrain in allTrains)
761761
{
762+
if (cancellation.IsCancellationRequested) continue; // ping watchdog token
763+
762764
// create train route
763765
if (TrainRouteXRef.ContainsKey(reqTrain.Index) && Paths.ContainsKey(TrainRouteXRef[reqTrain.Index]))
764766
{

0 commit comments

Comments
 (0)