Author
Topic: bidirectional and can_lead_from_rear (Read 7722 times)

I'm trying to put at least some experimental features to pak128.CS. I have a few questions about reversing trains.

1. Why the default is bidirectional=0. I think that most rail vehicles are bidirectional, except for non-tank steam engines (with tank and coal on a trailer), and front and back units of some EMU/DMU/pendolinos, etc.

2. how exactly works can_lead_from_rear ? I have an example - https://en.wikipedia.org/wiki/%C4%8CD_Class_810This is a sort of "railbus" which is by itself bidirectional. (reversing time in simuitrans-ex cca 1 minute). It can haul a few trailers, which look almost the same, just they are unpowered and have no drivers cab. So there is a need for shunting at terminus. (reversing 2 minutes). However if a longer train was formed (>3 vehicles), a second powered unit would be put at the end, and no shunting would be needed. So reversing should be 1 minute, but it is 2 minutes, just as if there would be only one engine. If I give it can_lead_from_rear, then all combinations rverse in 1 minute, and the convoy with only one engine and some trailers goes in reverse - engine pushes the trailers, but they have no drivers cab.

It is currently not possible to do that. You need to create a duplicate of the engine with a different name and with the string "can_lead_from_rear=1" in that one, as I have done with my Rc-locos: [urk]https://github.com/VictorErik/Pak128.Sweden-Ex/blob/half-height/Vehicles/Rail%20Vehicles/Locomotives/Rc.dat[/url]There is a duplicate of each engine at the bottom of the dat with the "_SMS" in the name (nickname in SJ for this type of consist building, the locos texting SMS to each other).

(nickname in SJ for this type of consist building, the locos texting SMS to each other).

I'm pretty sure SMS is for serial multiple unit control? (Seriell multipelstyrning). Using this requires wiring through the intermediate carriages, which is what differs it from conventional multiple control (conventional double- and triple heading, etc).

can_lead_from_rear works as follows: if the rearmost vehicle of a train has this flag set, the train will not turn around, but will just run backwards, and will use the faster turnaround time.

I think that the thing that is desired from both Vladki and also myself, is the ability to have a bidirectional loco at each end of a train.

I have made an example track at the swedish server to illustrate what is happening.The track is located between the towns of Dingtuna and Träslövsläge (approximate coordinates: 222,229) and there are four different trains running. They have a naming convention as follows:

NORMAL = is a normal locomotive, without "can_lead_from_rear=1" definedCLFR=1 = is a locomotive with "can_lead_from_rear=1" definedcars = are normal cars

So a train with two normal locos at each end will be named NORMAL - cars - NORMAL

The first train, "NORMAL - cars - NORMAL", will rearrange the locos at the terminus, so the order becomes: "LOCO - car - LOCO - rest of the cars".

The solution to that is to define "can_lead_from_rear=1" in the loco, and that actually works, as demonstrated by the second train, "CLFR=1 - cars - CLFR=1".

However, that will then not work when you want to use the loco alone. After a few runs, the loco will stay at its position in the train, PUSHING the cars in front of it, as demonstrated by te third train, "CLFR=1 - cars".

The ultimate bulletproof solution to the issue is then to create a duplicate of the loco and put "can_lead_from_rear=1" at the second loco. As proven by the fourth train, "NORMAL - cars - CLFR=1", that will work in every occasion, however, it has that major drawback of needing a duplicate of every loco you want to be able to do this with. Also it will clutter down the depot window.

So the ultimate whish would be that there where some intelligence in some way, either that a loco with "can_lead_from_rear=1" that runs alone would not try to push the cars upon reversing, alternative that a loco would be assigned a "virtual" can lead from rear flag when bidirectional and set at the end of a consist.If none of those are not possible, the "secondmost" ultimate whish I guess would be whats proposed in this thread: http://forum.simutrans.com/index.php?topic=11978.msg118208#msg118208

Briefly looking at this on the relevant saved game, it appears as though the vehicle with "can_lead_from_rear=1" is actually at the front and the one without is actually at the rear: the "can_lead_from_rear=1" only works when the vehicle that has this is in rear when the convoy is in a non-reversed formation (i.e., as it is straight out of the depot).

Yes I know that it should be setup like that. However, I have altered the setup on the server for you to test:

* Save a savegame of the server at its current state and open up the save in the newest build.* Open the depot, and there you should find a convoy called "NORMAL - cars - CLFR=1(car)". As the name suggest, the last vehicle in the convoy is a cab-car.* Press start and follow the convoy for some rounds.* Eventually, the cab-car will become the leading car in both directions.

This appears to be the bug I mentioned before. James, take a look at the swedish server, especially the emu's. They have coded in their datfile the primary car without and the rear car with can_lead_from_rear=1. This results in that when the trains are in the nonreversal direction, the leading car shifts position, rearranging the cars of the emu.

Also, this thread appears to become more like a bugreport than pakset specific, maybe move it to the development board?

It appears to have reverted to the original behavior: A locomotive with can_lead_from_rear=1 will start pushing the cars again. However, the case with a loco (without CLFR=1) and the last car/loco with CLFR=1 works again.

It immediatedly appears to work as intended now! Great work! Only, trains from older savegames with the bug appears to remain in their wrong orders and do strange stuff, however a trip to the depot to straighten them out makes the wonder.

I have 4 trains in that game. All vehicles are bidirectional. Railbus is powered some CLFR=1 some =0 see train names, trailer is unpowered and always CLFR=0

CSD_M152 - is in config railbus_red/trailer_red/trailer_blue/railbus_blue. Both railbuses have CLFR=1, and it works as expected - reversing in short time, keeping the order of vehicles

Viamont 810 - railbus_yellow, and 3 trailers of different colors, railbus is CLFR=1, also works OK, reversal is longer, railbus goes to the other end, trailers keep their original position.

ZSSK 811 - railbus_red and 2 trailers (one with mail, one without). CLFR=0, reversal OK, order of vehicles is kept.

And here comes the problem: ZSR_811: railbus_orange, trailer_orange, trailer_red, railbus_red, CLFR=0. When reversing it moves the orange trailer to the other end, plus it takes the orange trailer with it as well. So the reversed order is railbus_orange, trailer_orange, railbus_red, trailer_red.I would expect only the railbus should go to the other end, thus making this formation: railbus_orange, railbus_red, trailer_red, trailer_orange.

Is there any reason, while train with CLFR=0 behaves different when there is a powered vehicle at the end or not? Similar behavior can be seen on swedish servergame at traslovslage station - train named "normal - cars - normal"

BTW, the save game has probably some problem. If you quit simutrans and start again, it hangs at loading the temp-load.sve. Seems to be in some infinite loop with sleep (not using CPU), but hes to be killed forcefully. (kill -9). After that it starts with the mini default game, and lets you load my save without hassle. I tried with pak.sweden and it does the same thing, so it is not pakset or savegame specific. I shall report this as separate thread.

Yes, it is not specific to this trailer. I have tried with others (well they are mostly just different liveries, but as the pakset is not yet for experimental, they are coded as separate vehicles, not using the liveries feature of experimental)

I have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.

I have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.

I suppose that engines with tender, should be identified by constraints (next/prev) rather than by steam. There are tank steam engines, that are tender-less, and on the other hand there are articulated diesel or electric engines that behave similar to steam+tender in this regard.

Moreover - steam+tender are usually not bidirectional, while articulated diesel/electric are bidirectional.

I have not had a chance to test this, but I suspect that this behaviour is caused by the special code for detecting a steam locomotive with a tender. I have modified the code so that this now only works if both the locomotive and tender are explicitly encoded as having the steam engine type; otherwise, it should now behave as expected.

Bear in mind that there are some locomotives which are not steam but are also permanently coupled together. In Pak.sweden there is the Dm3, which is three engines coupled together, with a cab at each end. Currently, the cabs points "inwards" when the train is reversing. It is like the constraintNEXT becomes constraintPREV and vice versa when the train is reversing. There is a Dm3 on the swedish server (im about to clean it up, however, the server just crashed...) showing the behavior. Mind, that alot of trains are in strange order, but this is because I havent had time to clean it up yet (and the server just crashed, so it will be like that for a second)..

edit Just like Vladki was saying

Edit2 Incidentally, nice selection of signals you made Vladki! Looking really good

Perhaps making bidirectional powered vehicles to be automatically CLFR=1, would make sense. And also if they are constrained like DM3 or similar, to keep them together and put the whole unit on the other end of the train.In the czech pak you can find some railbuses and trailers that have a "mail hold". Those also behave funny when reversing.

Perhaps making bidirectional powered vehicles to be automatically CLFR=1, would make sense. And also if they are constrained like DM3 or similar, to keep them together and put the whole unit on the other end of the train.In the czech pak you can find some railbuses and trailers that have a "mail hold". Those also behave funny when reversing.

I dont think it would necessary make sence to have any bidirectional powered vehicle to automitacally have CLFR=1 as a powered bidirectional vehicle not principally do have a cab at each end, look at american trains like this one: http://www.katousa.com/N/SS-F7/.Upon reversal of a train, I think that the train should find the rearmost vehicle with CLFR=1 in the train and split it from there, threating the whole section between the front vehicle and the latest CLFR=1 as if it was a single loco doing a roundabout. Hopefully in such a case there is no need for any vehicle to turn around, as nondirectional vehicles usually tends to be steam engines and engines like the american linked above. However, for the failproofing, IF there are such a vehicle in the train, some logic must be applied:

If the player uses a steam engine (or other nonbidirectional vehicle) as the leading vehicle and wrongly uses a vehicle with CLFR=1 in the consist, the CLFR=1 from any vehicle should be ignored. The engine should do the roundabaout and turn around as normal, taking any constrained cars with it in the action.

If there is a vehicle in the middle of a train, I can see several scenarios:If the nonbi vehicle is constrained together with the leading vehicle (which is bidirectional), the section which is constrained together should do the roundabout, turn around, and remain their position in respect to constraint next/prev as described above.

If the nonbi vehicle is not constrained with the leading vehicle, it should just turn around, forcing any constrained vehicles to turn too.

But even with these rules, I don't think the constraints can be too complicated from a pakset creation pow.

Perhaps a little change in the logic of bidirectional and CLFR would be useful:

bidirectional = 0 would be only those vehicles, that cannot run in reverse at full speed: i.e. steam engines with tenderbidirectional = 1 would be all that can run in both directions at full speed even if they have only one cab, i.e almost everything.CLFR=0 would be set on vehicles that do NOT have a cab in rear: F7, front part of Dm3, front unit of pendolino/TGV and similar units.CLFR=1 would be set on vehicles that have a cab in rear: i.e. driving trailers, rear unit of pendolino/TGV, rear part of Dm3, reversed F7 (I suppose that they can be run back to back), and all modern diesel and electric engines that have cab on each end, or have a cab in the middle (shunters like this https://cs.wikipedia.org/wiki/Lokomotiva_210). Steam tank engines fall in this category too.

Reversing will be done like Ves suggested:If all cars are bidirectional, and there is a CLFR=1 at the end - just reverseIf all cars are bidirectional, and there is a CLFR=1 not at the end (perhaps even the first vehicle) - take the part from front to CLFR=1 and move it to the end of train.unidirectional vehicles should disable any CLFR=1 in train, and should turn around and take the same relative position in the train. (Example: 2 steam engines with tender in front, and one more in rear.

I would also propose that similarly to using ConstrantNext[0]=any on many wagons to force a brake (guard) van at the end of train, one could also use ConstranitPrev[0]=any to force an engine (or car) with cab on the head of the train.

Ves: the signals in pak128.CS were originally painted by Lubak91. I did the dat files, positioning, light combinations, etc.

I have prepared a savegame using pak128.CS (and a few addons). Notable trains are:- Train (18) lead by class 556 Stokr: this is usual steam engine with tender. Bidirectional=0 (both engine and tender), constraint[next/prev] between engine and tender. Turnaround time 6 minutes, reversal is OK. One of the cars (csd_aba) has two parts overlapping. It behaves a bit funny when reversed (see when it takes corners), but that is a minor problem- Train (19) lead by class TL 659 Turbinka: this is an experimental turbine loco, which due to high fuel consumption needed an extra tank waggon attached. So it is constrained in same way as steam tender engine 556, but is bidirectional (both engine and tender), turnaround 2 minutes, reversal OK. Although this engine does not need turning on turntable, it needs more complicated shunting, so a longer turnaround time might be reasonable. But this was just a prototype, and is not expected to be used too much so there's no need to make special exemption just for this one. (and may be fixed by setting it non bidirectional). However when I used this engine with British mk2 coaches, where rear and front brake cars are defined, it did some funny rearrangements of the train, like class 698 below.- Train (20) lead by class T 698 Kokakola: This engine consists of two parts. If set as non-bidirectional, the engine reverses nicely (although it takes long time), but also it takes the first waggon (csd_wlab blue) to the front of the train. If set as bidirectional, it reverses quickly, but the unit is spit and recombined with cabs facing each other. And the problem with front wagon remains.- Train ( railbus class CD_811. The engine and trailers have normal hook & screw coupling, but are constrained with similar vehicles due to remote control of doors and rear engine. The front 811-1 and rear 811-2 engine are in real world identical, but I had to code the rear one as can_lead_from_rear=1, to get the desired behavior. (no rearranging, 1 minute turnaround). Again the middle cars are pax+mail combo which looks funny when reversed)- Train (11) railbus class ZD_810. front engine coded as can lead from rear. Turnaround OK (2 minutes, as it has to shunt). Train arrangement OK. I think there used to be problem with such combination, but now it is OK. Thus the train 8 could be recoded to have CLFR on both ends - as does e.g train 13 and 14. - Train (10) regionova trio 814, this is a fixed DMU of three cars, but is capable of pulling normal trailers. It is bidirectional, with the last unit CLFR=1. If running alone, it works fine, but with a trailer it gets rearranged with cabs inside. This should behave the same way as swedish Dm3 (three-part electric loco for heavy freight).