Skip to content

Commit f793f15

Browse files
authored
Merge pull request #393 from Csantucci/Fix-join-split
Bug fix for https://bugs.launchpad.net/or/+bug/1922480 Wrong subpath selected after join and split
2 parents 1b14563 + 0960503 commit f793f15

File tree

1 file changed

+19
-4
lines changed
  • Source/Orts.Simulation/Simulation/Physics

1 file changed

+19
-4
lines changed

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6791,14 +6791,12 @@ public virtual bool CheckRouteActions(float elapsedClockSeconds)
67916791
if (positionNowBack == PresentPosition[0].TCSectionIndex && directionNowBack != PresentPosition[0].TCDirection)
67926792
{
67936793
ReverseFormation(IsActualPlayerTrain);
6794-
// active subpath must be incremented in parallel in incorporated train if present
6795-
if (IncorporatedTrainNo >= 0) IncrementSubpath(Simulator.TrainDictionary[IncorporatedTrainNo]);
6794+
TryIncrementSubpath();
67966795
}
67976796
else if (positionNow == PresentPosition[1].TCSectionIndex && directionNow != PresentPosition[1].TCDirection)
67986797
{
67996798
ReverseFormation(IsActualPlayerTrain);
6800-
// active subpath must be incremented in parallel in incorporated train if present
6801-
if (IncorporatedTrainNo >= 0) IncrementSubpath(Simulator.TrainDictionary[IncorporatedTrainNo]);
6799+
TryIncrementSubpath();
68026800
}
68036801
}
68046802

@@ -11611,6 +11609,23 @@ public void TemporarilyRemoveFromTrack()
1161111609
activeActions.Clear();
1161211610
}
1161311611

11612+
//================================================================================================//
11613+
//
11614+
// Checks if it has to go to next active subpath
11615+
//
11616+
private void TryIncrementSubpath()
11617+
{
11618+
// active subpath must be incremented in parallel in incorporated train if present; not just after incorporation
11619+
if (IncorporatedTrainNo >= 0)
11620+
{
11621+
var incorporatedTrain = Simulator.TrainDictionary[IncorporatedTrainNo];
11622+
if (incorporatedTrain.PresentPosition[0].TCSectionIndex != PresentPosition[1].TCSectionIndex && incorporatedTrain.PresentPosition[1].TCSectionIndex != PresentPosition[1].TCSectionIndex)
11623+
IncrementSubpath(incorporatedTrain);
11624+
incorporatedTrain.PresentPosition[0].TCSectionIndex = -1;
11625+
incorporatedTrain.PresentPosition[1].TCSectionIndex = -1;
11626+
}
11627+
}
11628+
1161411629
//================================================================================================//
1161511630
//
1161611631
// Goes to next active subpath

0 commit comments

Comments
 (0)