System.ArgumentOutOfRangeException at Orts.Simulation.Physics.Train.SetFormedOccupied (1.3.1.4328)

Bug #1892330 reported by Bela Tegi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Rails
New
Undecided
Unassigned

Bug Description

Hi!

Timetable, formed train from arrived train (#dispose - $forms=...), when starting this activity occured the exception.

I debugged code and found in Orts.Simulation/Simulation/Physics/Train.cs, SetFormedOccupied() method:
for (int iRouteIndex = rearIndex; iRouteIndex <= frontIndex; iRouteIndex++)
where rearIndex and frontIndex was -1, and later use iRouteIndex as array element indexer, which lead to exception.

(FYI: When I _NOT_ used forms in dispose row (not formed train), this exception not happen.)

Br.: abelino

Tags: crash physics
Revision history for this message
Bela Tegi (abelino) wrote :
James Ross (twpol)
summary: - Index was out of range exception when start activity.
+ System.ArgumentOutOfRangeException at
+ Orts.Simulation.Physics.Train.SetFormedOccupied (1.3.1.4328)
James Ross (twpol)
tags: added: crash physics
Revision history for this message
Bela Tegi (abelino) wrote :

Hi!

(I was a little free time, so I found one solution.)

Add few lines of code to Orts.Simulation/Simulation/Timetables/TTTrain.cs in "void FormTrainFromAI(int presentTime)" method:

if (validFormed)
{
+++ formedTrain.PresentPosition[0].RouteListIndex = PresentPosition[0].RouteListIndex;
+++ formedTrain.PresentPosition[0].TCOffset = PresentPosition[0].TCOffset;
+++ formedTrain.PresentPosition[0].TCSectionIndex = PresentPosition[0].TCSectionIndex;
+++ formedTrain.PresentPosition[1].RouteListIndex = PresentPosition[1].RouteListIndex;
+++ formedTrain.PresentPosition[1].TCOffset = PresentPosition[1].TCOffset;
+++ formedTrain.PresentPosition[1].TCSectionIndex = PresentPosition[1].TCSectionIndex;
// start new train
if (!autogenStart)
{
    AI.Simulator.StartReference.Remove(formedTrain.Number);
}

Important! This patch resolves this issue, but I don't know, what else breaks!

Br: abelino

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.