summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2006-05-30 10:53:27 +0000
committerKUDr <kudr@openttd.org>2006-05-30 10:53:27 +0000
commitd72ebf6ca3299cb525e2ba48b34e64be262a5d7c (patch)
tree79602ee8d10bb3df5130a5bcc264510562f3bf6e /roadveh_cmd.c
parented48b38619492a4018ac014d203718db689f69b2 (diff)
downloadopenttd-d72ebf6ca3299cb525e2ba48b34e64be262a5d7c.tar.xz
(svn r5033) -CodeChange: [YAPF] RoadFindPathToStop() can now use YAPF for multistop handling.
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 1c58b4eb6..6a7a62c82 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1149,14 +1149,26 @@ found_best_track:;
static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
{
- NPFFindStationOrTileData fstd;
- byte trackdir = GetVehicleTrackdir(v);
- assert(trackdir != 0xFF);
+ 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;
+ assert(trackdir != 0xFF);
- fstd.dest_coords = tile;
- fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
+ fstd.dest_coords = tile;
+ fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
- return NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;
+ dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;
+ // change units from NPF_TILE_LENGTH to # of tiles
+ if (dist != UINT_MAX)
+ dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
+ }
+ return dist;
}
typedef struct RoadDriveEntry {
@@ -1652,7 +1664,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
DEBUG(ms, 4) (" ---- stop 0x%X is not reachable, not treating further", rs->xy);
continue;
}
- badness = (rs->num_vehicles + 1) * (rs->num_vehicles + 1) + dist / NPF_TILE_LENGTH;
+ badness = (rs->num_vehicles + 1) * (rs->num_vehicles + 1) + dist;
DEBUG(ms, 4) (" ---- stop 0x%X has %d vehicle%s waiting", rs->xy, rs->num_vehicles, rs->num_vehicles == 1 ? "":"s");
DEBUG(ms, 4) (" ---- Distance is %u", dist);