[v2.0.0] Template based train replacement

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

HapticTactic
Engineer
Engineer
Posts: 23
Joined: 15 Mar 2019 19:56

Posibility to replace wagons only?

Post by HapticTactic » 15 Mar 2019 20:02

Hello, I am new here but I have been playing OTTD for quite some time now :-)

I love this feature!

I have a question:

Is it possible to create a template that would replace only wagons for all trains in a given group? Let's say I have a train that has an obsolete engine which is not available anymore and I want to keep that engine and just remove or add wagons according to the template. Is it possible to do that somehow?

Thank you!

Best regards

McZapkie
Tycoon
Tycoon
Posts: 1175
Joined: 18 Jan 2014 18:10

Re: [v2.0.0] Template based train replacement

Post by McZapkie » 15 Mar 2019 21:23

Generally good idea, to have possibility of cloning consist regardless of any vehicles accessibility.
Sometimes I need to make action similar to HapticTactic, or opposite (keep wagons, change locomotive, or just add/rearrange wagons), but it is not possible to create new template.
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

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

Re: Posibility to replace wagons only?

Post by ffpp » 16 Mar 2019 12:18

HapticTactic wrote:Hello, I am new here but I have been playing OTTD for quite some time now :-)

I love this feature!

I have a question:

Is it possible to create a template that would replace only wagons for all trains in a given group? Let's say I have a train that has an obsolete engine which is not available anymore and I want to keep that engine and just remove or add wagons according to the template. Is it possible to do that somehow?

Thank you!

Best regards
Hi!

that is possible, but you need to have an existing template which contains this obsolete engine.
You can always create a new template from an existing train by cloning it, so if you have some train with the old engine, you should be able to create a template containing the old engine.
You can then modify it to contain the new model wagons. Just select the template from the list and click "Delete last engine" to remove the old wagons from the template, select a new type of wagon from the engines list on the left and click "Add engine" to add it to the selected template.
With that template you can keep the old loco around.

I just tried to test it but couldn't because the old engines wouldn't expire when I cheated the date from 1900 to 2050... I tried with the default engine set and with the UKRS 2.0 train set. Do you have an example of a newgrf where the engines are set to expire?

McZapkie
Tycoon
Tycoon
Posts: 1175
Joined: 18 Jan 2014 18:10

Re: Posibility to replace wagons only?

Post by McZapkie » 16 Mar 2019 18:31

ffpp wrote: You can always create a new template from an existing train by cloning it, so if you have some train with the old engine, you should be able to create a template containing the old engine.
Actually it is not possible (at least for patch version implemented in JGRPP) to make new template by cloning existing train with expired vehicles.
The question is, if it is possible to fix it, or maybe such assertion is deeply build into copy function?
My experimental openTTD server: 149.156.194.203:3979 non-standard client, now testing: JGRPP http://tiny.pl/ggnch
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, preindustrial houses, wired, ECS industry extension, V4 CEE train set.
Addicted to freeciv longturn.

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

Re: Posibility to replace wagons only?

Post by ffpp » 17 Mar 2019 07:27

McZapkie wrote:
ffpp wrote: You can always create a new template from an existing train by cloning it, so if you have some train with the old engine, you should be able to create a template containing the old engine.
Actually it is not possible (at least for patch version implemented in JGRPP) to make new template by cloning existing train with expired vehicles.
The question is, if it is possible to fix it, or maybe such assertion is deeply build into copy function?
Ah I see, JGRPP is using an older version of the patch. I reworked a lot of things for version 2.0.0. In that version what you described works just fine.
For 2.0.0 I had made a pull request into the openttd's master branch. I am working on this integration at the moment. But I can also try to see with JGR whether an update of tbtr in his PP would be an option as well.

Anyways, thanks for pointing this out.

HapticTactic
Engineer
Engineer
Posts: 23
Joined: 15 Mar 2019 19:56

Re: Posibility to replace wagons only?

Post by HapticTactic » 17 Mar 2019 15:26

ffpp wrote:
McZapkie wrote:
ffpp wrote: You can always create a new template from an existing train by cloning it, so if you have some train with the old engine, you should be able to create a template containing the old engine.
Actually it is not possible (at least for patch version implemented in JGRPP) to make new template by cloning existing train with expired vehicles.
The question is, if it is possible to fix it, or maybe such assertion is deeply build into copy function?
Ah I see, JGRPP is using an older version of the patch. I reworked a lot of things for version 2.0.0. In that version what you described works just fine.
For 2.0.0 I had made a pull request into the openttd's master branch. I am working on this integration at the moment. But I can also try to see with JGR whether an update of tbtr in his PP would be an option as well.

Anyways, thanks for pointing this out.
Excellent. Thank you for your time. I will try my lobbying skills with JGR to include the latest version of your patch in his pack! :-)))))

HapticTactic
Engineer
Engineer
Posts: 23
Joined: 15 Mar 2019 19:56

Re: [v2.0.0] Template based train replacement

Post by HapticTactic » 27 Mar 2019 18:59

ffpp, I have asked JGR about updating the template feature. I was under the impression that he uses directly your code but it seems to be more complicated. See our conversation about it:
HapticTactic wrote:Hi guys, hi JGR!

...

I have a question about ffpp's "Template based train replacement" patch you are using in your pack. Would it be possible for you to update it to the latest version with your next or future JGRPP updates? There is at least one crucial feature in the latest version of "ffpp's TBTR" that I would, personally, love to see in the game. It allows for creating template clones from trains that contain obsolete vehicles. The version you are using currently in JGRPP does not allow this. It would be an extremely useful feature for us who love to play with the templates feature.

...
JGR wrote: The implementation of TBTR which I have is loosely based on https://github.com/flitzpiepe/OpenTTD_T ... d82a6a59aa partly updated to match KeldorKatarn's fork (JokerPP) (971ba4928a5c7c7916fea55d91a3b6dd5bba140c), with a few dozen changes/fixes on top.
The commit in KeldorKatarn's branch is now gone as he periodically rebased it.
I don't know what version this may correspond to in terms of the forum thread.
Enabling creating templates with obsolete vehicles seems doesn't seem like a big change. If there is a commit where it's implemented and it is compatible I could cherry pick it, otherwise I can look into the possibility of implementing it directly in due course.
I am a bit lost at the moment in who did what etc and what would be the easiest way for JGR to update the feature.

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests