You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to document the cargodest destination selection algorithm as this is the last item missing in the Wiki. When reading the code, I stumbled across the following code in RoutingSystem::GetDestination() in routing.cpp:
00604 uint dist = DistanceManhattan(GetStation(from)->xy, GetStation(target)->xy);
00605 uint maxdist = MapSize();
00606 uint sector = dist * 5 / maxdist;
00607
00608 /* Station is too far away */
00609 if (RandomRange(4) < sector) continue;
From my understanding, sector is intended to be the distance between source and destination normalized to 0..4. However, according to the above code it will always be 0, as MapSize() is the number of tiles in the map, i.e. MapSizeX() * MapSizeY(). So, a destination will never be rejected due to being too far away and the destination selection is not dependent on distance at all.
Line 605 should probably read as follows:
00605 uint maxdist = MapSizeX() + MapSizeY();
This way it is really the maximum achievable Manhattan distance on the map.
Applied the patch on my personal build. I'll let you know if things seem better as the game progresses(new game with all the fancy new patches I've found)
PhilSophus opened the ticket and wrote:
Reported version: Cargodest
Operating system: All
This issue was imported from FlySpray: https://bugs.openttd.org/task/2481
The text was updated successfully, but these errors were encountered: