__Intro__
This patch was created to minimize the amount of micromanagement for keeping your trains in order.
I felt that the existing vehicle Autoreplacement meachnism was lacking for trains in some use cases. For
example when the new vehicles you want to use are longer than the ones already used the trains would become
longer than before, possibly not fitting into the same platforms as before anymore.
Similarly, if new vehicles have a larger cargo capacity than the old ones you might want to use less of them
than before to save money but just replacing existing train cars 1:1 would not allow you to do that.
With this patch you can now predefine templates for your trains and let your trains be fitted to match those
templates upon the next depot visit. The template assignment is based on vehicle groups. It works only for
trains since other vehicle types consist of single vehicles only anyways and the Autoreplacement feature is
fully sufficient there.
A short overview of the feature's usage:
* create template
* assign to a group (of trains)
* when any train from that group enters a depot, it will be changed to match the template
__How to use it__
Open the UI
- from the train groups gui, under "Manage List" and select "Template Replacement".
- use the key combination [ctrl] + [e].
Each group can have one template assigned and if that is the case, this template will be applied to all trains
in the group.
Create a new template
- Clone from an existing train by using the Clone button and selecting any train from the game window.
- Create a new custom template: select an engine from the top-right list make sure that no template is
selected from the bottom list and click "Add Engine". This will create a new template and select it. While a
template is selected you can append a new engine with "Add Engine" or remove the last engine from it with
"Delete Engine".
Adding a new engine can also be done by double clicking on an engine in the upper right list.
train will also store the refit for all parts of that train so that this always remains a fallback option.
This means that you could simply create the first train for each group manually and set it as the template for
the rest.
At this moment no additional checks are done whether this template composition is actually valid, this is your
job. BUT, when a template is later applied to an existing train and it turns out that it is not valid after
all, no changes will occur, so no harm should be done to your existing trains if you create an invalid
template

Use the additional options
All three available options are applied on a per-group basis. This makes sense since 2 groups might want to
use the same template but they might want to use a different set of options.
The options can be triggered simply by clicking on one of the strings in the groups list "use depot", "keep
rem" and "use refit". Highlighted in blue means that the option is ON, in gray it means that it is OFF.
Use Depot
When this is ON the template replacement will reuse vehicles from the depot as needed to create the new
chain. But it will only consider vehicles which are stopped and idle in the depot and which don't belong to
any specific group.
Keep Remainders
When this is ON the parts of a train which are not needed anymore after template replacement will be set
to a stopped and idle state in the depot so that they might be used for later replacements. If it is OFF all
remainders from the train will be sold immediately.
Use Refit
When this is ON each train part will use the same refit settings as the one in the template.
This can be useful when 2 groups share the same template but will use it only to shuffle the vehicles around
while the other will use it also to apply the refit.
Toggle Refit Window
This feature is new in 2.1.0. It allows to specify the cargotype to be changed for a template vehicle or the
whole chain. When the refit window is opened, it will affect the currently selected template.
Selecting a single Template Vehicle
Since 2.1.0 it is possible to select a single vehicle from a template. This can be used to:
- Change the cargotype for only a single part of a template
- Add a new engine in the middle of an existing template. The new engine will be added after the currently
selected vehicle - Delete a single vehicle from the template
- Filter by Railtype
- Template Length displayed as 0.0
This is not the case for templates that were cloned from a train

Patch available at github:
git@github.com:flitzpiepe/OpenTTD.git
Binaries:
Linux: Windows: upcoming