This is the first part of the central while loop:
while (accumulatedDistance < maxDistance) { if (traveller.IsTrack) { var initialOffset = traveller.trackOffset; var radius = traveller.IsTrackCurved ? traveller.trackSection.SectionCurve.Radius : 1; if (traveller.TN == trackNode || trackNode == null) { var direction = traveller.Direction == TravellerDirection.Forward ? 1 : -1; if (InitTrackSectionSucceeded(traveller, targetLocation)) { // If the new offset is EARLIER, the target is behind us! if (traveller.trackOffset * direction < initialOffset * direction) break; // Otherwise, accumulate distance from offset change and we're done. accumulatedDistance += (traveller.trackOffset - initialOffset) * direction * radius; return accumulatedDistance; } }
So note that the check for accumulatedDistance < maxDistance is made within the while clause, but at the end of this excerpt there is this
accumulatedDistance += (traveller.trackOffset - initialOffset) * direction * radius; return accumulatedDistance;
which increases accumulated distance and returns it, without checking whether this increase causes leads to accumulatedDistance being bigger than maxDistance. So a check should be added in the return line: if accumulated distance is bigger than maxDistance, -1 must be returned.
Is the actual behaviour wanted? Because being a TrackNode also very long, the distance could be returned even if it is some Km higher than maxDistance.
I found it because this is the cause of some occasional flickering in camera position in the new Shift-4 camera, that locates it preferentially at platforms and level crossings.