Skip to content

Commit ff5688f

Browse files
committed
fix: Correctly handle water trough split over multiple track circuit sections
1 parent 7e949c3 commit ff5688f

File tree

1 file changed

+4
-1
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks

1 file changed

+4
-1
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3131,7 +3131,10 @@ void UpdatePositionFlags()
31313131
foreach (var troughs in section.TroughInfo)
31323132
{
31333133
var trough = troughs[currentPin.Direction];
3134-
if (checkedM + trough.TroughStart <= frontOffsetM && rearOffsetM <= checkedM + trough.TroughEnd) isOverTrough = true;
3134+
// Start and end are -1 if the trough extends beyond this section
3135+
var troughStart = trough.TroughStart < 0 ? 0 : trough.TroughStart;
3136+
var troughEnd = trough.TroughEnd < 0 ? section.Length : trough.TroughEnd;
3137+
if (checkedM + troughStart <= frontOffsetM && rearOffsetM <= checkedM + troughEnd) isOverTrough = true;
31353138
}
31363139
}
31373140
}

0 commit comments

Comments
 (0)