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

Multistop not working when using NPF #242

Closed
DorpsGek opened this issue Jul 14, 2006 · 1 comment
Closed

Multistop not working when using NPF #242

DorpsGek opened this issue Jul 14, 2006 · 1 comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

mart3p opened the ticket and wrote:

Multistop bus/truck stops are not working correctly when using NPF. Note, multistop always uses NPF (regardless of the NPF setting) if YAPF for road vehicles is off.

In the function RoadFindPathToStop in roadveh_cmd.c, the variable 'dist' is declared twice. Firstly (correctly) at the beginning of the function and secondly (incorrectly) in the body of the 'else' statement.

The else statement is used when finding a path using NPF. The return value for 'dist' is assigned in this 'else' block, but this 'dist' goes out of scope and the actual value returned is the 'dist' declared at the beginning of the function. As this is initialised as UINT_MAX, this is the value that is always returned by the function if using NPF, indicating "stop not reachable".

This is the code for the function from the trunk at r4593:

static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
{
uint dist = UINT_MAX;
if (_patches.yapf.road_use_yapf) {
// use YAPF
dist = YapfRoadVehDistanceToTile(v, tile);
} else {
// use NPF
NPFFindStationOrTileData fstd;
byte trackdir = GetVehicleTrackdir(v);
uint dist = UINT_MAX; //# # # THIS LINE SHOULD BE REMOVED! # # #
assert(trackdir != 0xFF);

  fstd.dest_coords = tile;
  fstd.station_index = INVALID_STATION

  dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd,
  	TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;

  if (dist != UINT_MAX)
  	dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;

}
return dist;
}

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/242
@DorpsGek
Copy link
Member Author

Darkvater closed the ticket.

Reason for closing: Fixed

Thank you mart3p for yet another clear bugreport exactly pinpointing the problem. Great work!


This comment was imported from FlySpray: https://bugs.openttd.org/task/242

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Vehicles labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant