[v2.1.0] Template based train replacement [OpenTTD 1.9.3]

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.3] Template based train replacement r24056

Post by ffpp »

Hi,

I would like to ask for some opinions/ideas.
I am about to implement two points from the list and would like to know what could be a good way to do them, in principal.

First, making the refit of template-replaced trains optional.
While playing, I realized that I often have trains that look identical in terms of engines and wagons but have set a different refit-configuration. Also, I usually play very clean trains, carrying only one type of cargo, maximum two with passenger+mail trains.
So while playing I needed to have multiple templates that looked the same but had a different refit loadout. When replacing one train which carried lumber and one which carried coal I had two create two different templates which contained the same vehicles but had a different refit setting.
So I made it optional to use a template's refit setting and I can now just upgrade the wood train and the coal train from the same template as I can force both to use their original refit setting.
Only problem is, it is hard to find a procedure to 'restore the original refit setting'. Right now I'm using a simplistic approach in which I assume to the treated train to have only one type of cargo and refit all new vehicles in the chain accordingly (using the first wagon's refit setting, actually).
In a general way it seems hard to find a pattern of how you could keep a train's refit settings. Because the template and the incoming train can differ so wildly from another.

Second, 'replace all vehicles of type A in all templates by vehicles of type B'
This was from Eddi's suggestion and I think it might be useful to have. Only problem is that in contrast to the autoreplacement functions on trains, doing this on templates will have an immediate effect and could mess up all templates with one click.
What could be a reasonable way to prevent this ? Showing 3 confirmation dialogs 'are you sure?' ? Having a 'undo' button to restore all templates ?

Any ideas on these points are welcome, thanks ;)
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: [v0.3] Template based train replacement r24056

Post by Eddi »

maybe not "undo", but "apply changes" (like newgrf config. changes you make in the GUI won't have any effect until you press this button. "undo" will be to close the window without applying (needs confirmation window))
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [v0.3] Template based train replacement r24056

Post by Zuu »

I think it is a strength to have the refit target and not just wagon types coded into the template. That will make the template a clear and precise target for replacements.

(I have however not playtested your patch much more than just a quick test with 0.1b)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.3] Template based train replacement r24056

Post by ffpp »

Zuu wrote:I think it is a strength to have the refit target and not just wagon types coded into the template. That will make the template a clear and precise target for replacements.

(I have however not playtested your patch much more than just a quick test with 0.1b)
Hm, I'm not sure if we're talking about the same thing here :)
What is working is to specify the refit for a template just as well as for a real train. But as an additional option I'm also concernd with the case where I want a train to keep as much of its refit despite being template replaced. And the latter case is what my post was about, well the last one at least.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.4] Template based train replacement r24092

Post by ffpp »

There is a new version up, the first post has been updated.
patch, linux-build and screenshot for v0.4


The new features that came to my mind during testing it all. Most notably are the cargo transfer during replacement, so if the new train will receive as much cargo from the old as it can fit.
During template creation (which the screenshot cannot show) and in the main gui, there is now information about the refit settings of a template train.

I also implemented Eddi's idea of having a function to 'auto replace among templates', meaning that you can update all templates at once by replacing some particular vehicle types by others for all defined templates at once. The gui should be intuitive enough, it looks similar to the auto-replace gui, template will be changed only on pressing 'Apply'. Before the user applies the changes, he can do multiple such replacements successively.

As always, feedback is very welcome. Write what you wish for, what annoys you, what doesn't work or what crashes.

Regards
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [v0.4b] Template based train replacement r24093

Post by handrake »

Please create a patch against clean r24093 as it would otherwise fail to be imported.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: [v0.4b] Template based train replacement r24093

Post by Arie- »

I haven't tested it, nor have I taken a look at the change logs. But the first post mentions r24092, not r24093, perhaps that's why it fails? A second possibility is ffpp first applied cargodist and build his patch against that one.
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [v0.4b] Template based train replacement r24093

Post by handrake »

Arie- wrote:I haven't tested it, nor have I taken a look at the change logs. But the first post mentions r24092, not r24093, perhaps that's why it fails? A second possibility is ffpp first applied cargodist and build his patch against that one.
This patch is against his old one on r24056.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.4b] Template based train replacement r24093

Post by ffpp »

Hi,

the compatibility information in the first post is just additional.
The patch on the first post is meant to be used against the current trunk of the game.

Since v0.4 it is not fully compatible to cargodist anymore (cd changed something about cargo loading). But I made a slight change to get them work together again. I will append the patch to this post, the first one is not allowed to hold more than 3 attachments.
This patch is against r24093 trunk + CargoDist, so cd is fully included in it, makes it a bit larger :).

---------------------------------------------------------------------------------
EDIT: I replaced the patch with one that is compatible with trunk+cargodist, but doesn't include cargodist.
Now this version of my patch will compile against recent trunk + cd but not against trunk alone, for r24093 alone there is still the patch on the first post.
(what a mess)
Attachments
tbtr_v0.4c_forCargodist.patch
apply on top of cargodist
(189.5 KiB) Downloaded 233 times
Last edited by ffpp on 05 Apr 2012 16:40, edited 4 times in total.
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [v0.4b] Template based train replacement r24093

Post by handrake »

ffpp wrote:Hi,

the compatibility information in the first post is just additional.
The patch on the first post is meant to be used against the current trunk of the game.

Since v0.4 it is not fully compatible to cargodist anymore (cd changed something about cargo loading). But I made a slight change to get them work together again. I will append the patch to this post, the first one is not allowed to hold more than 3 attachments.
This patch is against r24093 trunk + CargoDist, so cd is fully included in it, makes it a bit larger :).
Oops. I'm sorry. It was a problem with my working copy. Thank you again for a great patch. Applying now...
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.4b] Template based train replacement r24093

Post by ffpp »

You can do so, I just changed the post above yours, but it wouldn't make any difference to your project, its just a cleaner way to do it ;)
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [v0.4c] Template based train replacement r24093

Post by AndiK »

I've got another feature request:

Template based building of new trains. :-) Do I have to say more? (Except that I'd be most thankful for it)
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp »

AndiK wrote:I've got another feature request:

Template based building of new trains. :-) Do I have to say more? (Except that I'd be most thankful for it)
Hm, what would be the benefit over just cloning trains in a depot ? The only difference would be that when a train is cloned from a template that th new train would probably be neutral ragarding its group and orders settings.
User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland

Re: [v0.4c] Template based train replacement r24093

Post by Core Xii »

ffpp wrote:Hm, what would be the benefit over just cloning trains in a depot ?.
The obvious one that occurs to me right away is not needing the train to clone in the depot. Frequently I want to clone a train that's already running on my network.
AndiK
Engineer
Engineer
Posts: 53
Joined: 07 Dec 2004 18:34
Location: Grafing bei München (Munich)
Contact:

Re: [v0.4c] Template based train replacement r24093

Post by AndiK »

CoreXii:
This is already possible. Open Depot, click "Clone Train", Ctrl+Click on train on the network - voila!


ffpp:
The benefit would be the neutral group and orders, as you already pointed out, as well as me, the lazy player, not having to find a train to clone from.

I'd use it to create the first train for a new line. The rest of them are just clones, of course. The feature would obviously only save a few seconds per new line, but these are the kind of seconds that get kind of annoying once you've played TTD for 17 years (gosh, I'm getting old...). :-D

I thought it was kind of an obvious idea, if the infrastructure was already there. Anyways. In the end it's your decision if it's worth the while and it's your spare time. *shrug*
handrake
Engineer
Engineer
Posts: 55
Joined: 26 Mar 2012 10:23

Re: [v0.4c] Template based train replacement r24093

Post by handrake »

AndiK wrote:CoreXii:
This is already possible. Open Depot, click "Clone Train", Ctrl+Click on train on the network - voila!


ffpp:
The benefit would be the neutral group and orders, as you already pointed out, as well as me, the lazy player, not having to find a train to clone from.

I'd use it to create the first train for a new line. The rest of them are just clones, of course. The feature would obviously only save a few seconds per new line, but these are the kind of seconds that get kind of annoying once you've played TTD for 17 years (gosh, I'm getting old...). :-D

I thought it was kind of an obvious idea, if the infrastructure was already there. Anyways. In the end it's your decision if it's worth the while and it's your spare time. *shrug*
Seconded. Also, I would like to suggest to let users set 'default' train length so that I don't have to double-click wagons 9 times for the train length of 5. However, for dual-head engines, care must be taken not to exceed that default. Of course, users will be able to override that default by some other method...
User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland

Re: [v0.4c] Template based train replacement r24093

Post by Core Xii »

AndiK wrote:This is already possible. Open Depot, click "Clone Train", Ctrl+Click on train on the network - voila!
God dammit, why isn't this stuff more discoverable!? Would have been handy to know earlier! :bow:
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [v0.4c] Template based train replacement r24093

Post by Zuu »

At least all/most "hidden features" are collected at a wiki page: http://wiki.openttd.org/Hidden_features
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Eisenbaehr
Engineer
Engineer
Posts: 62
Joined: 29 May 2006 06:59
Location: Germany

Re: [v0.4c] Template based train replacement r24093

Post by Eisenbaehr »

Hey :)

I've tested your patch. It is very nice and helpful. The patch came with handrakes HPPS r24122 (http://www.tt-forums.net/viewtopic.php? ... 4&start=40).

The first few hours I was afraid to use the function(s). It was a bit hard to understand, where to start. I have read your instructions. But something looked a little outdated? I also missed pictures (a tutorial would be great).

Otherwise, the creation of trains is very difficult. If an engine is added, it is very difficult to move them to the first position. I also miss a copy / clone function to copy existing templates.

Overall it's a really good nice to have. Thank you for your work!

Best regards,
Robert
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v0.4c] Template based train replacement r24093

Post by ffpp »

Thanks Eienbaehr, and yes I also think some of these issues you mentioned are worth of improving.
- The function to copy an existing template: I plan to use the already existing 'clone' button for this
- During the creation of a template, it is complicated to get an engine to be the first vehicle in the chain: this is also the same when dealing with a train in a depot, only that there you have multiple lines available to make things easier. Should be improved as well.
- Introduction: good idea actually, especially since I feel some of the additional functions like 'use template refit' are a bit fuzzy perhaps :)

Lately I was taking a brake from working on this patch due to important exams but will continue. There are also some stability issues which I noted during some longer playtesting, those should get priority, I guess.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests