diff options
author | matthijs <matthijs@openttd.org> | 2005-05-02 23:59:11 +0000 |
---|---|---|
committer | matthijs <matthijs@openttd.org> | 2005-05-02 23:59:11 +0000 |
commit | f8302a137a2cf1d91fa4e8ece35289ef4108499b (patch) | |
tree | cad8daa1ee5542d4e8fefcbf2e2825e3f35fdb47 /ship_cmd.c | |
parent | ba733c005dbe8edf23a3f1cb05dd892df5be11a9 (diff) | |
download | openttd-f8302a137a2cf1d91fa4e8ece35289ef4108499b.tar.xz |
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
- Add: GetVehicleTrackdir() helper function.
- Codechange: Moved SortStruct from vehicle_gui.h to ttd.h, so the dependency from vehicle.h on vehicle_gui.h could be removed.
- Codechange: Typedeffed the VehicleTypes struct so it can be used as the type for Vehicle.type instead of "byte".
- Codechange: Removed prototype for VehicleSorter(), which had no implementation anymore and was never called.
Diffstat (limited to 'ship_cmd.c')
-rw-r--r-- | ship_cmd.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/ship_cmd.c b/ship_cmd.c index 5e5c5c022..75ef25736 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -73,7 +73,7 @@ static Depot *FindClosestShipDepot(Vehicle *v) if (_patches.new_pathfinding_all) { NPFFoundTargetData ftd; - byte trackdir = _track_direction_to_trackdir[FIND_FIRST_BIT(v->u.ship.state)][v->direction]; + byte trackdir = GetVehicleTrackdir(v); ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner); if (ftd.best_bird_dist == 0) best_depot = GetDepotByTile(ftd.node.tile); /* Found target */ @@ -567,14 +567,12 @@ static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks) NPFFindStationOrTileData fstd; NPFFoundTargetData ftd; uint src_tile = TILE_ADD(tile, TileOffsByDir(_reverse_dir[enterdir])); - byte track = FIND_FIRST_BIT(v->u.ship.state); - assert (KILL_FIRST_BIT(v->u.ship.state) == 0); /* Check that only one bit is set in state */ - assert (v->u.ship.state != 0x80); /* Check that we are not in a depot */ - assert (track < 6); + byte trackdir = GetVehicleTrackdir(v); + assert (trackdir != 0xFF); /* Check that we are not in a depot */ NPFFillWithOrderData(&fstd, v); - ftd = NPFRouteToStationOrTile(src_tile, _track_direction_to_trackdir[track][v->direction], &fstd, TRANSPORT_WATER, v->owner); + ftd = NPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner); if (ftd.best_trackdir != 0xff) /* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains |