specific group name patch

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
User avatar
RBC
Engineer
Engineer
Posts: 47
Joined: 19 Jun 2008 07:52
Location: Eibenstock (Germany)

specific group name patch

Post by RBC » 18 Mar 2013 18:23

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.
Attachments
specific_group_names_v1_r25108.patch
(11.92 KiB) Downloaded 84 times

User avatar
RBC
Engineer
Engineer
Posts: 47
Joined: 19 Jun 2008 07:52
Location: Eibenstock (Germany)

Re: specific group name patch

Post by RBC » 23 Mar 2013 16:31

new version

-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 127 times

beginner2
Engineer
Engineer
Posts: 17
Joined: 12 Mar 2008 21:16

Re: specific group name patch

Post by beginner2 » 13 Aug 2014 18:35

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.
Attachments
specific_group_names_v2_r26728.patch
(12.52 KiB) Downloaded 83 times

User avatar
FooBar
Tycoon
Tycoon
Posts: 6559
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: specific group name patch

Post by FooBar » 13 Aug 2014 19:24

beginner2 wrote:Apologies for reviving the dead topic.
You don't have to apologize if you actually add something useful! :wink:
This is actually one of the best occasions one could revive an old topic.

Patagonicus
Engineer
Engineer
Posts: 25
Joined: 24 Oct 2011 20:42

Re: specific group name patch

Post by Patagonicus » 07 Apr 2015 21:41

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 :wink:
Attachments
specific_group_names-r27220.diff
(15.5 KiB) Downloaded 56 times

Patagonicus
Engineer
Engineer
Posts: 25
Joined: 24 Oct 2011 20:42

Re: specific group name patch

Post by Patagonicus » 29 Aug 2016 20:02

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.
Attachments
specific_group_names-r27623.diff
(22.72 KiB) Downloaded 35 times

Patagonicus
Engineer
Engineer
Posts: 25
Joined: 24 Oct 2011 20:42

Re: specific group name patch

Post by Patagonicus » 17 Jan 2017 05:20

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 46 times

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Wuzzy and 7 guests