onCloneVehicle increment vehicle number

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

Post Reply
numerodix
Engineer
Engineer
Posts: 13
Joined: 16 May 2004 12:46

onCloneVehicle increment vehicle number

Post by numerodix »

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
Attachments
clone_and_increment_r5114.diff
Increment vehicle number when cloning
(2.01 KiB) Downloaded 189 times
numerodix
Engineer
Engineer
Posts: 13
Joined: 16 May 2004 12:46

Post by numerodix »

Right, so I decided it was no good to leave it like it was and now it picks a correct number no matter which vehicle is being cloned. I also cleaned up the code and moved it to a separate function.

It seems to work fine alongside the latest trunk.
Attachments
clone_and_increment_r5125.diff
(3.59 KiB) Downloaded 203 times
Klanticus
Engineer
Engineer
Posts: 1
Joined: 13 Mar 2005 20:38
Location: São Carlos - Brasil
Contact:

Post by Klanticus »

Maybe it'd be better to display the number of vehicles that actually share the same route at some other place like the 'end of orders' string.
numerodix
Engineer
Engineer
Posts: 13
Joined: 16 May 2004 12:46

Post by numerodix »

Do you mean the number of vehicles or the list of vehicles? My idea was to use vehicle names, which I think aren't used much by openttd gamers to actually serve some purpose. It's pretty much the simplest way to keep track of vehicles that share orders.

Aside from vehicle names, the way to make this usable imo would have to be some kind of marking of the vehicles (eg. an icon on the vehicle screen).
Bjarni
Tycoon
Tycoon
Posts: 2088
Joined: 08 Mar 2004 13:10

Post by Bjarni »

I don't think naming is the ideal solution for this because you will run out of space to store the names before all vehicles are named (that is if nobody changed the naming code. At least it used to have a max amount of names).

I think we need some other way of making this. The question is how it would be best. We can add a new window if needed for this if we decide that we will benefit from it and not make the interface more confusing.
numerodix
Engineer
Engineer
Posts: 13
Joined: 16 May 2004 12:46

Post by numerodix »

Bjarni wrote:I don't think naming is the ideal solution for this because you will run out of space to store the names before all vehicles are named (that is if nobody changed the naming code. At least it used to have a max amount of names).
Yeah, that's true, I forgot about the limit. I do think that long term it should be done in a more structured way, this is just a first quick and easy approach.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 56 guests