News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Convoy driving in reverse

Started by TrainMith, June 25, 2009, 08:01:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TrainMith

Slightly annoyed with the way convoys suddenly flip direction after reaching a stop where their next waypoint is behind them, I began to wonder how difficult would it be to make convoys drive in reverse. 

After looking at simconvoy.cc, I realized it might be easier to first allow a single vehicle to be reversible.  Which brought me to the vehicle/simvehikel.cc file.  The first thought was a single boolean value that indicates whether the vehicle actually can be driven in reverse or not (such as an aircraft).  The second thought was another boolean value indicating that it currently is being driven in reverse.  Toss in the get/set function calls for appropriate information pathways. 
I'm thinking that the vehikel_basis_t should have the non-pure virtual functions just returning false, and the waggon_t having data members and functions that check those data members. 
Would anyone disagree to the placement of these, and why another place in the code would be better (by way of a simutrans specific topic, not a general programming topic discussion)?

Alas, I do not know the German language enough to understand the comments and sometimes intent within the code.  I am not sure at all where the graphics drawing code is, nor where to place the checks for the above suggestion.  I'm hesitant to openly admit that I'm a programmer (and know my way around the C++ language), for fear of finding myself kidnapped by members of simutrans and forced to code more.  ;)  Seriously though, I don't have enough time for another major project.

I'd love to see trains running backwards soon, but need a little help in getting it to do so.

Dwachs

I think this feature is already present in simutrans-experimental.
Parsley, sage, rosemary, and maggikraut.

jamespetts

TrainMith,

Dwachs is correct - an equivalent feature is indeed in Simutrans-Experimental, but there are currently no paksets that take advantage of it. However, Pak128.Britain-Experimental is currently in progress, and will support that feature.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

TrainMith

jamespetts, Dwachs: 
I am aware of the existence of the Simutrans-Experimental forum but, as that I am currently using only the general 102.0 version, I thought that the request should be made within the request forum of the general version.  Personally, I'll review the experimental version whenever the appropriate pak set becomes fairly balanced. 

jamespetts:

Also, I am perplexed as to why this feature would require extensions to the pak sets, other to express certain vehicles capability of being run in reverse.  The length of each vehicle does not change.  My thoughts upon the modifications to the code is that only a couple of flags to specify vehicles running in reverse, and the graphics drawing routines specify the vehicle drawn in the exact opposite orientation (which is already provided from the pak sets).  Other than a minor modification to the smoke system, then the final modification of moving into the convoy code for reversing the direction (and possibly having to specify the correct order of vehicles while in reverse, for loading purposes).  I believe no other change would be necessary. 
I also wouldn't mind seeing the general 102.0 version having this feature as soon as possible.

anyone else (even prissi):
Any comments concerning the locality of modifications to the code?  Where would I find the code for the displaying the graphics of the vehicles, so I can have it facing the opposite direction?

The Hood

The paksets do not take advantage of it because the dat files for the paks need extra lines for this feature in experimental.  Some paks are open source, so you can get the dat files and graphics for yourself and then build them into a pakset with makeobj, e.g. pak64 and pak128.Britain are both on sourceforge.

Dwachs

Quote from: TrainMith on July 01, 2009, 07:21:19 AM
anyone else (even prissi):
Any comments concerning the locality of modifications to the code?  Where would I find the code for the displaying the graphics of the vehicles, so I can have it facing the opposite direction?
I think, James can tell you, where the modifications are made. I bet, you have to look in simconvoi.cc, in the routine that handles the convois in station (maybe convoi_t::vorfahren). There one has to flip the whole convoi (first vehicle becomes last etc).
Parsley, sage, rosemary, and maggikraut.

jamespetts

The reason that there need to be compatible paksets is because not all convoys reverse in the same way. The feature is mostly relevant for trains. Some trains have a cab at each end (multiple units, for example), and can just go backwards without changing the order of vehicles at all. Some trains have a locomotive at one end, which itself can go either way, but needs to be at the front of the train. Other trains (typically those hauled by steam locomotives with tenders) have a locomotive at one end that needs to face a particular way. All these various possibilities are accounted for in Simutrans-Experimental, but they need to be expressed precisely in the paksets.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.