NextMilepost script reports wrong milepost
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Open Rails |
New
|
Undecided
|
Unassigned |
Bug Description
In TrainControlSys
The code does not alway return the correct milepost. It appears that the list is ordered based on the order that the mileposts appear in the database, not in milepost order.
The list generated has an appropriate subset of the objects, just improperly ordered where list[0].ThisMile is not always the next milepost. This was observed in th NSF Scenic Route, but not the Zig Zag.
The unsorted list returned by the PlayerTrainMilepost with the Track Monitor showing the train within 1782 function was;
list[0].thisMile 1779
list[1].thisMile 1782
list[2].thisMile 1781
list[3].thisMile 1780
Existing code in the file;
Script.NextMilepost = (value) =>
{
};
Proposed adding an inplace sort to order by distance from train.
Script.NextMilepost = (value) =>
{
};
Don't hesitate to propose a pull request on Github with your change.