diff options
author | rubidium <rubidium@openttd.org> | 2008-08-17 11:04:37 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-17 11:04:37 +0000 |
commit | b6b9cd9d51de7213f3d8d6fa73f341cfc28a1424 (patch) | |
tree | e348c82b84d5ab7faa51f995eb0e590ba9ac6435 | |
parent | f7ce9339bacf23a0d1da125bfa290d744070c847 (diff) | |
download | openttd-b6b9cd9d51de7213f3d8d6fa73f341cfc28a1424.tar.xz |
(svn r14089) -Fix [FS#2219]: trains not being able to find a route to a depot when the front is already in the depot.
-rw-r--r-- | src/train_cmd.cpp | 9 | ||||
-rw-r--r-- | src/vehicle.cpp | 6 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 29b907654..c7423f3ee 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2128,9 +2128,14 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) TrainFindDepotData tfdd; tfdd.owner = v->owner; - tfdd.best_length = UINT_MAX; tfdd.reverse = false; + if (IsRailDepotTile(v->tile)) { + tfdd.tile = v->tile; + tfdd.best_length = 0; + return tfdd; + } + PBSTileInfo origin = FollowTrainReservation(v); if (IsRailDepotTile(origin.tile)) { tfdd.tile = origin.tile; @@ -2138,6 +2143,8 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) return tfdd; } + tfdd.best_length = UINT_MAX; + uint8 pathfinder = _settings_game.pf.pathfinder_for_trains; if ((_settings_game.pf.reserve_paths || HasReservedTracks(v->tile, v->u.rail.track)) && pathfinder == VPF_NTP) pathfinder = VPF_NPF; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index bd64a4d69..ce9d6caa6 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2496,7 +2496,7 @@ CommandCost Vehicle::SendToDepot(uint32 flags, DepotCommand command) { if (!CheckOwnership(this->owner)) return CMD_ERROR; if (this->vehstatus & VS_CRASHED) return CMD_ERROR; - if (this->IsInDepot()) return CMD_ERROR; + if (this->IsStoppedInDepot()) return CMD_ERROR; if (this->current_order.IsType(OT_GOTO_DEPOT)) { bool halt_in_depot = this->current_order.GetDepotActionType() & ODATFB_HALT; @@ -2524,10 +2524,6 @@ CommandCost Vehicle::SendToDepot(uint32 flags, DepotCommand command) return CommandCost(); } - /* check if at a standstill (not stopped only) in a depot - * the check is down here to make it possible to alter stop/service for trains entering the depot */ - if (this->type == VEH_TRAIN && IsRailDepotTile(this->tile) && this->cur_speed == 0) return CMD_ERROR; - TileIndex location; DestinationID destination; bool reverse; |