onCloneVehicle increment vehicle number
Posted: 05 Jun 2006 08:03
Okay here's the rationale. I built a fairly large railway network and using the golden new clone vehicle feature, I set up a bunch of identical routes, each route serviced by several trains. I just create one train and set the orders, then clone into x more units et voila. The clone feature is a big step toward manageability when there are lots of vehicles. But one thing that I still found to be missing was a way to keep track of which trains belonged to which route. So the simplest way would be to maintain a naming convention, I name all trains from one route a certain way, let's say North-Route 1, the second becomes North-Route 2 and so on.
Now, when cloning *those* trains, I had to rename each unit by hand, which got old quick. So I thought why not increment that counter automatically.
So.. when holding Ctrl (ie. when orders are shared) and cloning a train, IF the train label is of the form "<name of train> <number>", the clone will be assigned the same name with the number incremented. This patch is very primitive, though, so if you have a train "North 2" and you want to clone "North 1" into "North 3", the new name will be "North 2" and seeing that it already exists, openttd will reject the rename and just call it the usual "Train X".
I only hacked it up because I could use it myself, but I do think potentially it could be a useful feature (done in a smarter way). It's no logical grouping, but at least it makes keeping track of them a bit easier.
Ps. the patch is quite ugly, don't stare right at it :/ (yes, it's the first time I'm trying c lol)
EDIT: patch applies cleanly against r5114 and mini_in_r4917
Now, when cloning *those* trains, I had to rename each unit by hand, which got old quick. So I thought why not increment that counter automatically.
So.. when holding Ctrl (ie. when orders are shared) and cloning a train, IF the train label is of the form "<name of train> <number>", the clone will be assigned the same name with the number incremented. This patch is very primitive, though, so if you have a train "North 2" and you want to clone "North 1" into "North 3", the new name will be "North 2" and seeing that it already exists, openttd will reject the rename and just call it the usual "Train X".
I only hacked it up because I could use it myself, but I do think potentially it could be a useful feature (done in a smarter way). It's no logical grouping, but at least it makes keeping track of them a bit easier.
Ps. the patch is quite ugly, don't stare right at it :/ (yes, it's the first time I'm trying c lol)
EDIT: patch applies cleanly against r5114 and mini_in_r4917