[patch] Auto-groups

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
lemmy101
Engineer
Engineer
Posts: 15
Joined: 22 Apr 2021 02:20

[patch] Auto-groups

Post by lemmy101 »

A patch that adds an auto-group feature that automatically creates groups for all ungrouped vehicles categorized by city / routes.

Image

https://www.youtube.com/watch?v=iBOcQmQ_gZo
Attachments
auto_groups1_1.zip
(5.42 KiB) Downloaded 69 times
Last edited by lemmy101 on 24 Apr 2021 06:35, edited 1 time in total.
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 495
Joined: 11 Aug 2019 18:15
Contact:

Re: [patch] Auto-groups

Post by 2TallTyler »

I love this. I have not compiled the patch and tried it myself, just watched your video, but I have a few questions and suggestions:
  • Are groups named "<city> Local" when the first and last orders are in the same city?
  • Is there a way to convert/save an auto-group as a regular group, so it won't disappear when I delete auto-groups?
  • I suspect an intercity route starting at a depot would fail to be named properly, since it should unload at the initial station before going to the depot for servicing — the route would be Depot A > Town A > Town B > Town A.

    Perhaps it could look for a different city from the first city, with the same town both before and after it. This would handle common routes like a bus route:
    Depot A > Town A Station 1 > Town A Station 2 >
    Town B Station 1 > Town B Station 2 >
    Town C Station 1 > Town C Station 2 > Town C Station 3 >
    Town B Station 2 > Town B Station 1 >
    Town A Station 2 > Town A Station 1

    In this case, it would determine Town C is between two visits to Town B, and determine that the route runs Town A > Town C.
nihues
Engineer
Engineer
Posts: 85
Joined: 13 Jan 2015 10:26

Re: [patch] Auto-groups

Post by nihues »

That is my Wishlist for openttd / jgr hahaha

Really miss a lot of click reduction and time lost from managing groups.

Look at Joker Patch Pack it has this feature already with some options (I think citymania or some server client has it too).
lemmy101
Engineer
Engineer
Posts: 15
Joined: 22 Apr 2021 02:20

Re: [patch] Auto-groups

Post by lemmy101 »

2TallTyler wrote: 23 Apr 2021 16:07 I love this. I have not compiled the patch and tried it myself, just watched your video, but I have a few questions and suggestions:
  • Are groups named "<city> Local" when the first and last orders are in the same city?
  • Is there a way to convert/save an auto-group as a regular group, so it won't disappear when I delete auto-groups?
  • I suspect an intercity route starting at a depot would fail to be named properly, since it should unload at the initial station before going to the depot for servicing — the route would be Depot A > Town A > Town B > Town A.

    Perhaps it could look for a different city from the first city, with the same town both before and after it. This would handle common routes like a bus route:
    Depot A > Town A Station 1 > Town A Station 2 >
    Town B Station 1 > Town B Station 2 >
    Town C Station 1 > Town C Station 2 > Town C Station 3 >
    Town B Station 2 > Town B Station 1 >
    Town A Station 2 > Town A Station 1

    In this case, it would determine Town C is between two visits to Town B, and determine that the route runs Town A > Town C.
[*] Are groups named "<city> Local" when the first and last orders are in the same city?

This is correct :)

[*] Is there a way to convert/save an auto-group as a regular group, so it won't disappear when I delete auto-groups?

Just rename and remove the asterisk, that's the criteria it uses for deletion.

[*] I suspect an intercity route starting at a depot would fail to be named properly, since it should unload at the initial station before going to the depot for servicing — the route would be Depot A > Town A > Town B > Town A.

Yeah as I say there are numerous ways this can fail, I will have to more intelligently iterate the orders and make a more informed decision as you suggest.
Look at Joker Patch Pack it has this feature already with some options (I think citymania or some server client has it too).
Haha doesn't surprise me if what patches I do already end up being done by others. However it seems a lot of contemporary patch availability is on very old builds, or part of much bigger patch packs, so in earlier attempts I found merging old patches pretty difficult as I'm not familiar with the codebase so its harder to determine how to deal with merge conflicts, so figured doing them myself based on need without even looking for other older examples would be more educational and fun. No offense to anyone who's already done anything I do especially if they've done it better. :) Just sharing results in case they useful.
nihues
Engineer
Engineer
Posts: 85
Joined: 13 Jan 2015 10:26

Re: [patch] Auto-groups

Post by nihues »

lemmy101 wrote: 23 Apr 2021 20:29 Haha doesn't surprise me if what patches I do already end up being done by others. However it seems a lot of contemporary patch availability is on very old builds, or part of much bigger patch packs, so in earlier attempts I found merging old patches pretty difficult as I'm not familiar with the codebase so its harder to determine how to deal with merge conflicts, so figured doing them myself based on need without even looking for other older examples would be more educational and fun. No offense to anyone who's already done anything I do especially if they've done it better. :) Just sharing results in case they useful.
That's great because I was trying to do an update a couple years ago but failed miserably using joker's as base (and I'm no coder so I was doing some bad job anyway)... If this could be added to actual patchpacks or be polished to get upstream to vanilla openttd it will be great, it's one of my top missing patches from older patchpacks that got almost forgotten!
lemmy101
Engineer
Engineer
Posts: 15
Joined: 22 Apr 2021 02:20

Re: [patch] Auto-groups

Post by lemmy101 »

Made a 1.1 patch - it now:

1) Considers only unique towns in the route, so doing A->B->C->D->C->B->A will report A->D as the route.
2) Ignores depots, so depot locations will not factor into determining the route.
lemmy101
Engineer
Engineer
Posts: 15
Joined: 22 Apr 2021 02:20

Re: [patch] Auto-groups

Post by lemmy101 »

Just noticed a serious bug, until I can do a patch update:

GetAutoGroupMostRelevantTowns function in group_cmd needs:

if (order->GetType() == OT_GOTO_DEPOT)
continue;

adding to the for loop to avoid it using depot ids as station ids to erroneously report order positions. oops.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 18 guests