Brakes no longer work for player trains in timetable mode

Bug #1322736 reported by r.roeterdink
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Rails
Fix Released
Undecided
Cédric GNIEWEK

Bug Description

Due to changes to brake control between versions 2221 and 2251, brakes for player trains in Timetable mode can no longer be operated.
Exactly which changes have lead to this situation is not clear.

See also Elvas Tower : http://www.elvastower.com/forums/index.php?/topic/24330-no-percentage-shown-for-locomotive-brake/page__view__findpost__p__151656

Applies to all stock on all routes.

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

Indeed, that's really really weird. It looks like the BrakeSystem and the BrakeController are not loaded...

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

I am currently installing the Surfliner line in order to help you debug it.

Revision history for this message
r.roeterdink (r-roeterdink) wrote :

Actually, the problem is not related to route or rolling stock, but starting a timetable rather than explorer or activity.

To help you in that, I have attached a very simply timetable template.
Just fill in a path and a consist (where it says <path> and <consist>), and save it as *.csv.
In the Activities directory, create a subdirectory OpenRails and copy the *.csv to that directory, and rename it as a *.timetable_or file.
You can now select this timetable in the main menu, select the train and start the timetable.

Train initialization in timetable mode is different from that in explorer or activity, as all trains are first created as AITrain, when that is done the selected player train is converted to Train and set as player train.
This worked well in version 2220, but the changes since then have somehow broken this line of work.

Thanks for your help.

Revision history for this message
r.roeterdink (r-roeterdink) wrote :

I think I traced the reason this problem now occurs.

The brake scripting is initialized in BrakeController.Initialize. This method is called from MSTSLocomotive.InitializeFromWagFile.
This method is called when an engine is loaded first time.
In activity and explorer mode, the player train engine is always loaded first - so the initiation of the engine, and the brake system, is always processed correctly.

But in timetable mode, the player train can be anywhere within that timetable and there is no certainty it is loaded as first engine. In that situation, the engine is created through MSTSLocomotive.InitializeFromCopy. This does not call BrakeController.Initialize, but instead calls
          TrainBrakeController = (ScriptedBrakeController)locoCopy.TrainBrakeController.Clone();

It seems that is where things go wrong - the Script variable in TrainBrakeController is not set and remains null.
It might even be that the Clone statement does not create a new Script, but only a copy of the Script of the loco from which the clone is taken. If this loco is removed before the player train starts (and that can well be the case), then the Script would be lost.

Revision history for this message
r.roeterdink (r-roeterdink) wrote :

Further update : just checked - the Clone does not create a Script in the cloned TrainBrakeController.

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

Yes, Initialize must be run after clone.

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :
Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

For now, I'll add an Initialize in the cloning constructor of ScriptedBrakeController.

Changed in or:
assignee: nobody → Cédric GNIEWEK (serana)
status: New → In Progress
Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

Fix committed in rev 2255

Revision history for this message
r.roeterdink (r-roeterdink) wrote :

Well - it's better, in that I have a percentage again.

BUT - I still don't have any actual brake values, and I have no control over the brakes whatsoever.
When I press ' (apply brakes), the text "applied" appears but percentage remains 0%.
When I press ; (release brakes), the text changes to "released" but still always percentage remains at 0%.

The are no values for brake cylinders and reservoirs etc.

So it seems there is still something missing from the initialization.

By the way, the timetable template I send earlier would not show the problem as it only contains 1 train.
To bring up the problem you would need to add a second train using the same consists, and run this second train as player train.

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

Another fix in rev 2256

Seems like the InitializeFromCopy function is more than incomplete.

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

This rev also fixed the absence of dynamic braking on the throttle controller.

Revision history for this message
disc (disc86543) wrote :

This problem is may be the same: https://bugs.launchpad.net/or/+bug/1367787

Revision history for this message
Carlo Santucci (carlosanit1) wrote :

Cédric, can this bug report be closed?

Revision history for this message
Cédric GNIEWEK (sharpeserana) wrote :

I just did a test in timetable mode. The bug is fixed.

Changed in or:
status: In Progress → Fix Committed
James Ross (twpol)
Changed in or:
milestone: none → 1.0
James Ross (twpol)
Changed in or:
status: Fix Committed → Fix Released
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.