Skip to content

Commit a1a7210

Browse files
committed
2024-12-30 A
1 parent ce50a58 commit a1a7210

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Source/Orts.Simulation/Simulation/Signalling/SignalObject.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,30 @@ public void RestoreTrains(List<Train> trains)
368368
{
369369
enabledTrain = thisSection.CircuitState.TrainReserved;
370370
}
371+
else if (thisSection.CircuitState.HasTrainsOccupying())
372+
{
373+
List<Train.TrainRouted> trainList = thisSection.CircuitState.TrainsOccupying();
374+
float? offsetInSection = null;
375+
376+
foreach (var thisRouted in trainList)
377+
{
378+
var thisTrain = thisRouted.Train;
379+
var thisOffset = thisTrain.PresentPosition[0].TCOffset;
380+
if (!offsetInSection.HasValue || thisOffset > offsetInSection)
381+
{
382+
offsetInSection = thisOffset;
383+
if (thisTrain.Number == number)
384+
{
385+
enabledTrain = thisRouted;
386+
thisTrain.NextSignalObject[0] = this;
387+
}
388+
else
389+
{
390+
enabledTrain = null;
391+
}
392+
}
393+
}
394+
}
371395
else
372396
{
373397
enabledTrain = null; // reset - train not found

0 commit comments

Comments
 (0)