specific group name patch
Moderator: OpenTTD Developers
specific group name patch
I recently played a TGV-style game (see http://wiki.openttdcoop.org/PAX) and after some 300 trains it got nasty creating new groups manually.
So I created a small patch. By dropping a vehicle on the "create new group" button in the vehicle list a new group is created. It is named with either the town names (default setting) or the station names from the first and last order of that vehicle (names sorted in alphabetical order). The vehicle is also added to this group. When town names are selected and both stations are in the same town the group will be named "Local {town name}".
Shared orders are supported.
Due to the group name length of 31 chars using station names might only be an option if you rename the stations. (for example a 3 char code for every station)
thanks to Zuu for help with OpenTTD strings.
So I created a small patch. By dropping a vehicle on the "create new group" button in the vehicle list a new group is created. It is named with either the town names (default setting) or the station names from the first and last order of that vehicle (names sorted in alphabetical order). The vehicle is also added to this group. When town names are selected and both stations are in the same town the group will be named "Local {town name}".
Shared orders are supported.
Due to the group name length of 31 chars using station names might only be an option if you rename the stations. (for example a 3 char code for every station)
thanks to Zuu for help with OpenTTD strings.
- Attachments
-
- specific_group_names_v1_r25108.patch
- (11.92 KiB) Downloaded 219 times
Re: specific group name patch
new version
-bugfix: game crashed when station sign was on a nonstation tile
-feature: skip waypoint and depot orders
-bugfix: game crashed when station sign was on a nonstation tile
-feature: skip waypoint and depot orders
- Attachments
-
- specific_group_names_v2_r25115.patch
- (12.5 KiB) Downloaded 264 times
Re: specific group name patch
Thanks for the awesome patch RBC!
I had some issues compiling using the current trunk release so I went and fixed the compilation errors I could find. This compiled and worked for me as of r26728. Apologies for reviving the dead topic.
I had some issues compiling using the current trunk release so I went and fixed the compilation errors I could find. This compiled and worked for me as of r26728. Apologies for reviving the dead topic.
- Attachments
-
- specific_group_names_v2_r26728.patch
- (12.52 KiB) Downloaded 239 times
Re: specific group name patch
You don't have to apologize if you actually add something useful!beginner2 wrote:Apologies for reviving the dead topic.

This is actually one of the best occasions one could revive an old topic.
-
- Engineer
- Posts: 26
- Joined: 24 Oct 2011 20:42
Re: specific group name patch
So true indeed, so let me continue...
I took the last patch, applied it to r27220, and took the liberty to make a few improvements (hopefully):
1) It now attempts to find the true first and last station of the order. For example, consider the order A -> B -> C -> B, the name of the group would now be "A - C" and not "A - B" as before. As routes can get quite complicated, this will probably only work in simpler cases - conditional jumps are not considered.
2) As station names are commonly too long to make it for group names, I added truncation to the code:
2a) Common prefixes are removed. E.g. "Town Station - Town Stop" will now get truncated to "Town Station - Stop".
2b) If group names are still too long, it will cut off an equal amount of both station names to make them fit.
Note on the code: For now I tried keeping my changes to the CmdCreateGroupSpecificName function. It probably need a clean up, but thought I'd share what I had so far with you.
It seems to work, but not thoroughly tested, so use on your own risk and don't blame me if your game crash
I took the last patch, applied it to r27220, and took the liberty to make a few improvements (hopefully):
1) It now attempts to find the true first and last station of the order. For example, consider the order A -> B -> C -> B, the name of the group would now be "A - C" and not "A - B" as before. As routes can get quite complicated, this will probably only work in simpler cases - conditional jumps are not considered.
2) As station names are commonly too long to make it for group names, I added truncation to the code:
2a) Common prefixes are removed. E.g. "Town Station - Town Stop" will now get truncated to "Town Station - Stop".
2b) If group names are still too long, it will cut off an equal amount of both station names to make them fit.
Note on the code: For now I tried keeping my changes to the CmdCreateGroupSpecificName function. It probably need a clean up, but thought I'd share what I had so far with you.
It seems to work, but not thoroughly tested, so use on your own risk and don't blame me if your game crash

- Attachments
-
- specific_group_names-r27220.diff
- (15.5 KiB) Downloaded 182 times
-
- Engineer
- Posts: 26
- Joined: 24 Oct 2011 20:42
Re: specific group name patch
Just thought I'd share a new feature for automatically creating groups for vehicles - saves a log of drag-drop on big maps with 1000+ vehicles 
Also bumped the SVN version to r27623, though that part was pretty trivial.

Also bumped the SVN version to r27623, though that part was pretty trivial.
- Attachments
-
- specific_group_names-r27623.diff
- (22.72 KiB) Downloaded 159 times
-
- Engineer
- Posts: 26
- Joined: 24 Oct 2011 20:42
Re: specific group name patch
Just a couple of bugfixes for my last reply. One allows auto grouping vehicles from the no-group group.
- Attachments
-
- specific_group_names-r27728.diff
- (52.84 KiB) Downloaded 174 times
Who is online
Users browsing this forum: No registered users and 16 guests