[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

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

Posibility to replace wagons only?

Post by HapticTactic »

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
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: [v2.0.0] Template based train replacement

Post by Wahazar »

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.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Posibility to replace wagons only?

Post by ffpp »

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?
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Posibility to replace wagons only?

Post by Wahazar »

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?
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Posibility to replace wagons only?

Post by ffpp »

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 »

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 »

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.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: [v2.0.0] Template based train replacement

Post by ffpp »

At the moment I am ironing out some issues with the current version and I would like to add 2 small features than I will have another go at having the patch merged into the trunk of openttd. Then it could just be removed JGR's patch.
But of course it would be better to have the newer version of TBTR used by other people to spot possible bugs before requesting the trunk merge.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

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

Post by ffpp »

New version 2.1.0 released.

New features:
- templates can be refitted (whole chain or just single vehicles)
- can select individual template vehicles for easier modification of templates
- can double click on an engine to create new template or add it to the currently selected one
- small fixes here+there
- merged against the latest stable version of openttd, 1.9.3

Linux binaries + screenshot in the OP

Feedback would be great, btw :]
gGeorg
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2019 01:17

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

Post by gGeorg »

Hello,

I was needing this functionality for years, well decades :D.
However, I dont know how-where to activate this patch.
Didnt find it on the online content feature, on the GIT page I am lost. Is there some easy way to use it?
Win7 user

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

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

Post by ffpp »

kamnet wrote: 25 Oct 2019 04:01
gGeorg wrote: 24 Oct 2019 20:12 Hello,

I was needing this functionality for years, well decades :D.
However, I dont know how-where to activate this patch.
Didnt find it on the online content feature, on the GIT page I am lost. Is there some easy way to use it?
Win7 user

Thx
https://wiki.openttd.org/Patches
Hi,

to enable the feature in the game:


from the train groups gui, under "Manage List" and select "Template Replacement".

use the key combination [ctrl] + [e].

Did you get it to work?
gGeorg
Engineer
Engineer
Posts: 6
Joined: 02 Apr 2019 01:17

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

Post by gGeorg »

ffpp wrote: 25 Oct 2019 16:48
kamnet wrote: 25 Oct 2019 04:01
gGeorg wrote: 24 Oct 2019 20:12 Hello,

I was needing this functionality for years, well decades :D.
However, I dont know how-where to activate this patch.
Didnt find it on the online content feature, on the GIT page I am lost. Is there some easy way to use it?
Win7 user

Thx
https://wiki.openttd.org/Patches
Hi,

to enable the feature in the game:


from the train groups gui, under "Manage List" and select "Template Replacement".

use the key combination [ctrl] + [e].

Did you get it to work?
The main problem is, how to install the patch, not how to find it in the UI.
I founded there is an JGRs multipatch whiich combines some other patches. Unfortunately, this also changes lot other things.
But yes, thanks to JGR I finaly make it work, and your tool does exactly what I wanted.
It iis a shame that this part of UI isnt included int the main game build.
It would be greate if you could add latest OTTD version + your_patch = compiled.exe for windows.
Its beond most people skill to prepare this before gameplay.
User avatar
jez
Traffic Manager
Traffic Manager
Posts: 158
Joined: 23 Aug 2003 21:24

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

Post by jez »

...
=== Jez ===
walter81
Engineer
Engineer
Posts: 1
Joined: 23 Jun 2022 10:55

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

Post by walter81 »

Hi

I've setup a template replacement for a group. The replacement works fine but now every single time one of these trains go to a depot for maintenance it destroys all cargo... They go in fully loaded and leave empty... Not only the 1st time when they're being replaced with the new vehicles but every next time as well.... When I stop the replacing this behavior stops too. Is this a bug or did I miss a setting?

(note also posted on /r/openttd)
mallardtheduck
Engineer
Engineer
Posts: 29
Joined: 26 Jul 2010 16:41

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

Post by mallardtheduck »

In my personal OpenTTD playstyle, I like to re-use vehicles quite a bit and therefore would like an option to only use existing vehicles in the depot when using template replacement.

I've mostly implemented this on my personal fork of JGR's patchpack, but the behaviour when a depot doesn't have a sufficient quantity of vehicles to satisfy a template isn't quite right (the trains end up "short" when it really should just fail the replacement). There are possibly other bugs too, my testing has been pretty much limited to single-player games with the particular NewGRF sets that I use (it's also now a little out-of-date since I haven't re-synced with JGR's repo recently). Since this is based on the "JGR" version of the patch, I'm not sure how applicable this is to the "mainline" version, but the code is available here: https://github.com/mallardtheduck/OpenTTD-JGR
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests