Skip to content

Commit

Permalink
Merge pull request #773 from Roeterdink/WatchdogPingTrainProcessing
Browse files Browse the repository at this point in the history
Add watchdog ping to Train Processing
  • Loading branch information
twpol committed Jan 28, 2023
2 parents 01607fd + 4543e4b commit 58e6767
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -148,7 +148,7 @@ public List<TTTrain> ProcessTimetable(string[] arguments, CancellationToken canc

// reduce trainlist using player train info and parameters
bool addPathNoLoadFailure;
trainList = BuildAITrains(trainInfoList, playerTrain, arguments, out addPathNoLoadFailure);
trainList = BuildAITrains(cancellation, trainInfoList, playerTrain, arguments, out addPathNoLoadFailure);
if (!addPathNoLoadFailure) loadPathNoFailure = false;

// set references (required to process commands)
Expand Down Expand Up @@ -752,13 +752,15 @@ private TTTrainInfo GetPlayerTrain(ref List<TTTrainInfo> allTrains, string[] arg
/// <param name="allTrains"></param>
/// <param name="playerTrain"></param>
/// <param name="arguments"></param>
private List<TTTrain> BuildAITrains(List<TTTrainInfo> allTrains, TTTrainInfo playerTrain, string[] arguments, out bool allPathsLoaded)
private List<TTTrain> BuildAITrains(CancellationToken cancellation, List<TTTrainInfo> allTrains, TTTrainInfo playerTrain, string[] arguments, out bool allPathsLoaded)
{
allPathsLoaded = true;
List<TTTrain> trainList = new List<TTTrain>();

foreach (TTTrainInfo reqTrain in allTrains)
{
if (cancellation.IsCancellationRequested) continue; // ping watchdog token

// create train route
if (TrainRouteXRef.ContainsKey(reqTrain.Index) && Paths.ContainsKey(TrainRouteXRef[reqTrain.Index]))
{
Expand Down

0 comments on commit 58e6767

Please sign in to comment.