Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRT - Pathfinder doesn't consider speed limits when calculating a route #8594

LC-Zorg opened this issue Jan 19, 2021 · 2 comments


Copy link

LC-Zorg commented Jan 19, 2021

Version of OpenTTD


Expected result

Pathfinder, as in the case of railways, takes into account the speed limits of roads and the vehicle itself when calculating the route - road vehicles will choose the faster route, not just the shortest.

Actual result

Pathfinder doesn't take into account speed limits at all, so it can and often steer vehicles over dirt roads or small villages when there are empty highways nearby.
In the case of railway vehicles, pathfinder calculates the routes correctly (it doesn't take into account the speed limit in the orders).
Road speed limits 1 2
Road speed limits 2 2


It would be good if the creators of add-ons could additionally assign traffic penalties to certain roads. Thanks to this, it will be possible to create roads with the same speed limit but different meaning or quality.

Copy link

LordAro commented Feb 13, 2021

I think I've fixed this, but to save some time, can you provide a savegame to test with? Ideally making sure the GRFs used are available via BaNaNaS

LordAro added a commit to LordAro/OpenTTD that referenced this issue Feb 13, 2021
Copy link

LC-Zorg commented Feb 16, 2021

Sorry to just now, but I didn't notice you wrote.
I didn't have any save that would show this problem very clearly, so I made one.
TEST - Roads with speed

I used the popular U&Ratt and UReRMM tracks for comparison with train behavior.

There is one main road on which vehicles with different speed limits travel. The road has different surfaces with different restrictions and forks to give a choice.
There is also a section with bridges - here pathfinder also doesn't take into account speed limits.

Besides, there are several bus routes on the map, where pathfinder chooses the wrong routes - there is a description of how long each variant takes time.

I'm not sure if I included all possible problems, but it seems to me that if the vehicles on this map run as expected, it should be very good. :) It's missing a lot and it would be really cool if you could fix / improve this.

I don't know what path you took to solve the problem, maybe what I will write is yet another issue, but maybe it is related to your method and is relevant at the moment.
Speed limits and road types

The combination of roads in the photo above shows a problem with the fact that the pathfinder, apart from the speed limit, should also take into account another limit, which should also be different depending on the type of vehicle.

As a result, typically road vehicles (buses, post truck etc.) should avoid dirt and industrial roads, while heavy goods vehicles would have less restrictions for dirt roads and no restrictions for industrial roads.

I have two concepts here.
1. Simplified
Roads and vehicles may be marked ROAD, OFFR, HAUL, INDU
-If the vehicle does not have any of the markings (e.g. OFFR), when searching for a route, the speed limits for roads that have these markings would be lowered an additional 20 km/h
-If the vehicle has an assigned mark (e.g. OFFR), roads that do not have this mark would read 5 km/h lower when searching for a route.

Examples of markings:
Highway - ROAD
Intercity road - ROAD, OFFR
City road - ROAD
Dirt road - OFFR, HAUL, INDU
Industrial road - OFFR, HAUL, INDU
City promenade - no signs

Examples of vehicle markings:
(unless the author of the add-on assigns otherwise, by default the markings would depend on the transported cargo)
Bus, Post truck (pass, post, valu) - ROAD
Freight truck (good, food, ...) - ROAD, INDU
Light truck (lvst, ensp, ...) - ROAD, OFFR, INDU
Heavy truck (coal, iron, grain, oil, ...) - OFFR, INDU
Slow-moving truck (speed below 40 km/h) - OFFR, INDU, HAUL

2. Developed
Each road, for each mark has a value assigned to it, which is read by the pathfinder as a speed limit modification.

Examples of markings:
Highway - ROAD +10, OFFR -5, INDU -5, HAUL -100
Intercity road - ROAD 0, OFFR -5, INDU -5, HAUL -30
City road - ROAD 0, OFFR -5, INDU -10, HAUL -30
Dirt road - ROAD -30, OFFR 0, INDU 0, HAUL +10
Industrial road - ROAD -15, OFFR 0, INDU +5, HAUL 0
City promenade - ROAD -100, OFFR -100, INDU -100, HAUL -100
(If the road does not have an assigned speed limit, a base value of 150 is assigned)

The vehicle markings would be the same as above, but here the limitations would add up.
For example, a light truck (marked with ROAD, OFFR, INDU) would have limitations:

  • for the highway: ROAD +10, OFFR -5, INDU -5 = 0
  • for an urban road: ROAD 0, OFFR -5, INDU -10 = -15
  • for a dirt road: ROAD -30, OFFR 0, INDU 0 = -30
  • for the city promenade: ROAD -100, OFFR -100, INDU -100 = -300
    (The sum of the limits could not reduce the speed limit read by the pathfinder below 10 km/h)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants