diff options
author | bjarni <bjarni@openttd.org> | 2006-09-03 11:49:38 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-09-03 11:49:38 +0000 |
commit | 6baf4888392407fdd8f08b948fd6a4087ebd107b (patch) | |
tree | cbbd6966c9d25e321e0ce148f06610e534e7422d | |
parent | 23168f630952490f6a548f1889e1a3b035b29f1d (diff) | |
download | openttd-6baf4888392407fdd8f08b948fd6a4087ebd107b.tar.xz |
(svn r6356) -Fix: FS#263 planes come out of hangar and drive back into hangar
Now all vehicles are serviced when it's time for service and they are in a depot
This will avoid the goto depot order from ever showing up when in a depot
-rw-r--r-- | aircraft_cmd.c | 5 | ||||
-rw-r--r-- | roadveh_cmd.c | 5 | ||||
-rw-r--r-- | ship_cmd.c | 5 | ||||
-rw-r--r-- | train_cmd.c | 21 |
4 files changed, 34 insertions, 2 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c index d87b931da..bb5985f92 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -667,6 +667,11 @@ static void CheckIfAircraftNeedsService(Vehicle *v) if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; + if (IsAircraftInHangar(v)) { + VehicleServiceInDepot(v); + return; + } + st = GetStation(v->current_order.dest); // only goto depot if the target airport has terminals (eg. it is airport) if (IsValidStation(st) && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) { diff --git a/roadveh_cmd.c b/roadveh_cmd.c index e35b6caad..e59d7c60c 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -1640,6 +1640,11 @@ static void CheckIfRoadVehNeedsService(Vehicle *v) // If we already got a slot at a stop, use that FIRST, and go to a depot later if (v->u.road.slot != NULL) return; + if (IsRoadVehInDepot(v)) { + VehicleServiceInDepot(v); + return; + } + // XXX If we already have a depot order, WHY do we search over and over? depot = FindClosestRoadDepot(v); diff --git a/ship_cmd.c b/ship_cmd.c index 16d3fa623..d014ba485 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -112,6 +112,11 @@ static void CheckIfShipNeedsService(Vehicle *v) if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; + if (IsShipInDepot(v)) { + VehicleServiceInDepot(v); + return; + } + depot = FindClosestShipDepot(v); if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) { diff --git a/train_cmd.c b/train_cmd.c index 8b033054d..a1fcf2938 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -829,7 +829,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) /* Check if all the wagons of the given train are in a depot, returns the * number of cars (including loco) then. If not it returns -1 */ -int CheckTrainStoppedInDepot(const Vehicle *v) +static int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped) { int count; TileIndex tile = v->tile; @@ -846,7 +846,7 @@ int CheckTrainStoppedInDepot(const Vehicle *v) * Also skip counting rear ends of multiheaded engines */ if (!IsArticulatedPart(v) && !(!IsTrainEngine(v) && IsMultiheaded(v))) count++; if (v->u.rail.track != 0x80 || v->tile != tile || - (IsFrontEngine(v) && !(v->vehstatus & VS_STOPPED))) { + (IsFrontEngine(v) && needs_to_be_stopped && !(v->vehstatus & VS_STOPPED))) { return -1; } } @@ -854,6 +854,18 @@ int CheckTrainStoppedInDepot(const Vehicle *v) return count; } +/* Used to check if the train is inside the depot and verifying that the VS_STOPPED flag is set */ +inline int CheckTrainStoppedInDepot(const Vehicle *v) +{ + return CheckTrainInDepot(v, true); +} + +/* Used to check if the train is inside the depot, but not checking the VS_STOPPED flag */ +inline bool CheckTrainIsInsideDepot(const Vehicle *v) +{ + return (CheckTrainInDepot(v, false) > 0); +} + /** * Unlink a rail wagon from the consist. * @param v Vehicle to remove. @@ -3511,6 +3523,11 @@ static void CheckIfTrainNeedsService(Vehicle *v) (v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0) return; + if (CheckTrainIsInsideDepot(v)) { + VehicleServiceInDepot(v); + return; + } + tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); /* Only go to the depot if it is not too far out of our way. */ if (tfdd.best_length == (uint)-1 || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) { |