Page 1 of 1

Replacing whole trains

Posted: 27 Nov 2010 22:59
by mates
What about replacing whole train units instead of replacing each wagon type separately.
You would be able to change train length and cargo type structure more easily.

Or easier variant: Just switching between already existing train units. (no need of "template creator")

Re: Replacing whole trains

Posted: 27 Nov 2010 23:38
by lawton27
That would undoubtedly be a nice feature to add. But dare I say tricky to implement, and if it is implemented I think the UI would be hard to follow, I took a good long time trying to work out your example, possibly that's just me though :D

Yeh nice idea, it would be nice to hear from a dev or experienced coder of OTTD about this.

Re: Replacing whole trains

Posted: 28 Nov 2010 01:10
by mates
I made new example picture/screen. Hope it is more understandable.
Image

Re: Replacing whole trains

Posted: 28 Nov 2010 10:21
by Alberth
Nice start, but you have to think bigger imho.

- There is no reason to limit it to trains only.

- You need to include some form of groups. Like now, people want to replace consists only at routes/lines/groups X, Y, and Z.

- How does the current game play and group-based play work together? In my view, the current game play is easy to explain and to do for younger children. Doing everything based on groups/templates (like eg Simutrans does) would exclude that target audience.

I have no clue at all how that would work. There are a few proposals, but they are all incomplete.



Literally yesterday, I found the first hurdle of your proposal.
Currently OpenTTD does not understand templates at all, it only knows actual consists (= trains in current use). In other words, to get templates in the game, you need to introduce templates, and then re-think and re-implement the entire vehicle command system in terms of templates, from buying vehicles, to giving orders, replacing, and selling.

Re: Replacing whole trains

Posted: 28 Nov 2010 11:10
by mates
OK it is quite hard to understand and implement. So, would be possible just switching between two already existing train units? Like this: very similar to replace vehicles window. Image
Just bit tricky when there are two same looking differently refitted trains.

Re: Replacing whole trains

Posted: 28 Nov 2010 12:14
by broodje
I'm not to fond of a template library myself, but that might be because I play with grouped trains. Wouldn't it be possible to ad an option 'replace with consist' in the drop down box 'Replacing' in the replace train window?

Then you click the consist you want to replace in the group, and build your new train there. If you have more consists in one group you can select them from the list on the left (see image). I guess the selected consist should have a white outline around it.

I guess code-wise it would still need a template library, but you won't see it as user, and I think it is fairly in line with the normal engine/wagon replacement menu. The only new think would be the 'new consist' row.

Re: Replacing whole trains

Posted: 28 Nov 2010 16:01
by mates
I think it's good idea. I made variant without the new consist row. It could be done in any depot, than would train appear in currently used trains. I think this is easier to implement.
Image

Re: Replacing whole trains

Posted: 10 Dec 2010 09:41
by Emperor Jake
This is a great idea :D For me it would be most useful in adding two or more carriages to trains, after I extend my stations as demand increases. It would also be useful for replacing MUs that require a different configuration to work or look good. Or to replace a large steamer or articulated locomotives with a pair of newer locomotives while keeping your consist. Or even if you want to replace some of the carriages in your consists, like an extra mail car. Or rearrange them. Or keep the train lengths correct if you upgrade from 5/8 length wagons to full length.

There are so many possibilities here, I really think this should be implemented. :wink:

Re: Replacing whole trains

Posted: 27 Jun 2011 08:13
by chickenbc
I`m studying source codes in order to implement these features, especially 'autoreplace_gui.cpp' and 'autoreplace_cmd.cpp'.

These codes are totally only dealing with replacing engine or wagon, not both. Each replacing gui and command are work with 'EngineID', but if we want to replace whole trains, we need some other stuffs. Trains are essentially 'chains of' each vehicle. So, IMO we need to change codes quite a lot.

Also, We need to think about it : Where we save the "templates"? I think there are 3 choices.

1) Save it to settings. ( I think 'openttd.cfg' is good.)
-> Similar to copy&paste patch, I think. But it is much complex than it. Since we have so many NewGRFs. Not only each NewGRF, but also a set of NewGRFs. (For example, 'templates using 2cc Trainset' and 'templates using 2cc Trainset and NuTracks' are totally different, since the latter makes incompatible trainsets with former one.)

2) Save it to each save-files.
-> Quite reasonable... but we need to think about savefile compatibility, moreover, If we made a trainset from one game, we can`t use it for other games.

3) Do not save: Each template is generated based on the what we have in each game.
-> If we do, we don`t need to think about savefile compatibility, and so DIRTY NewGRFs... yes it is good. But We have to make at least one trainset in the game, which may be frustrating sometimes.


Give another opinions, i`ll read it, and try to make this kind of patches.... If Something goes well, I`ll post later.

Re: Replacing whole trains

Posted: 27 Jun 2011 10:50
by broodje
I'd go for 3. In fact in my opinion the consist only has to be saved as long as you are replacing it. In other words, as soon as you press 'stop replacing' the whole template isn't needed anymore. Just the way it works for replacing vehicles or wagons.

I'm not to fond of saving the consist as a template, it has way to many way's it can break. (keep it simple!)

Re: Replacing whole trains

Posted: 27 Jun 2011 11:44
by FooBar
I would avoid the template thing completely and limit the choice of consists to already existing trains. If you want to replace with something completely different, buy one of those in a depot first (or overhaul an existing train first, since you're replacing it anyway).

The list of available options should be filtered for duplicates and vehicles that are unavailable. The property section in the lower part should display the properties of the full consist with e.g. total power and total capacity (per cargo type).

That way I think the implementation can remain just as effective, yet simple enough to be acceptable in OpenTTD. It also can co-exist with the existing group options (also limiting consist replace to a group) and the current replace vehicle feature (with the addition of a precedence order).

While replacing trains, the easiest way is just to delete the old one, clone a new one and put the orders of the old into the new (all functions available to OpenTTD). Better would be to take existing wagons and engines into account to avoid high costs: if a certain vehicle is used in both consists, it will not be sold and re-purchased.

Re: Replacing whole trains

Posted: 29 Jun 2011 03:30
by chickenbc
Oh, I forgot about something.... We have save states about each trainset is in replacing or not... There is no effort not to modify savefiles, since it is impossibe.

One another choice is, mix 2 and 3 : We can replace whole train from existing trainset OR artifical trainset, which can be made in replacing window and will be saved in the savefiles.

Re: Replacing whole trains

Posted: 19 Mar 2012 12:54
by ffpp
*bump*

without ever seeing this thread, I had a similar idea while playing.
Trying to implement this idea it slowly grew more sophisticated until it looked like the first picture in this post.

a few days after uploading the patch, I found this post and was astounded that this had been in the planning before and how similar the suggestion looked to what I did myself.

I thought this deserved a bump as notification on the topic ;)
Here's the patch:
http://www.tt-forums.net/viewtopic.php?f=33&t=58904

I actually cross-linked the two threads now

Re: Replacing whole trains

Posted: 19 Mar 2012 14:11
by J0anJosep
ffpp wrote:*bump*
I thought this deserved a bump as notification on the topic ;)
Here's the patch:
http://www.tt-forums.net/viewtopic.php?f=33&t=58904
I actually cross-linked the two threads now
I really like that patch. Templates are really helpful here. They aren't really difficult and can be defined for each group.

Easier ideas as consists and others may work, but will face problems as:
- Two groups of trains with identical engines: I expand the stations for the first group of trains. I want to make trains for the first group but not for the second. So "replacing whole trains" should work for groups of vehicles (or shared orders vehicles).

To avoid templates and replacing whole trains, work with groups. For each group of vehicles (on its group statistics), define a vehicle of this group as "the template". Then, if we want the group of vehicles to be changed, we should send "the template" to depot and make the desired changes. Then, when the others vehicles of the group are on a depot, replace the whole train as a copy of "the template".

The only changes needed are:
- Save/Load: on save/load of a group, save/load "the template" vehicle of the group (or NULL if not defined). (easy)
- On autoreplace functions (probably I'm missing something):
1) when "the template of a group" changes and is send out of depot, send the rest of vehicles of the group to service and autoreplace them;
2) when "the template" reaches depot, apply global and local autoreplace (if it changes, apply 1) );
3) when autoreplace (global/local) is changed send a) only template vehicle to depot if a template is defined or b) all group vehicles if no template is defined (medium)
- GUI: define/remove template for each group, icon showing that a template is defined for a group... (easy)

I think it is an easy workaround, but to do so, you should work with groups of vehicles...

Re: Replacing whole trains

Posted: 19 Mar 2012 14:20
by ffpp
A little problem with that suggestion might be that you might have a case where many groups should contain the same kind of trains, for instance imagine a typical PAX game with many passenger lines and vehicles are grouped by line.

Then, for each single group you would need to send one train to the depot, modify it and set it as master.
With generic template trains, you can easily have multiple groups use the same kind of trains and control this from within a single gui with very few clicks.

Re: Replacing whole trains

Posted: 19 Mar 2012 18:08
by J0anJosep
ffpp wrote:A little problem with that suggestion might be that you might have a case where many groups should contain the same kind of trains, for instance imagine a typical PAX game with many passenger lines and vehicles are grouped by line.

Then, for each single group you would need to send one train to the depot, modify it and set it as master.
With generic template trains, you can easily have multiple groups use the same kind of trains and control this from within a single gui with very few clicks.
You can (temporarily) put all those vehicles into the same group.

Although I like both ideas: defining virtual templates or defining a vehicle inside a group as master.

Re: Replacing whole trains

Posted: 19 Mar 2012 19:23
by ffpp
In principal you could even combine both ideas.
Like, if a group has no template defined, use its master for replacement.

Re: Replacing whole trains

Posted: 20 Mar 2012 08:44
by FLHerne
Obvious answer would be a tree of/nested groups. :wink: