mirror of https://github.com/OpenTTD/OpenTTD
(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 depotrelease/0.5
parent
23168f6309
commit
6baf488839
|
@ -667,6 +667,11 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
||||||
|
|
||||||
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
|
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
|
||||||
|
|
||||||
|
if (IsAircraftInHangar(v)) {
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
st = GetStation(v->current_order.dest);
|
st = GetStation(v->current_order.dest);
|
||||||
// only goto depot if the target airport has terminals (eg. it is airport)
|
// 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) {
|
if (IsValidStation(st) && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) {
|
||||||
|
|
|
@ -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 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 (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?
|
// XXX If we already have a depot order, WHY do we search over and over?
|
||||||
depot = FindClosestRoadDepot(v);
|
depot = FindClosestRoadDepot(v);
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,11 @@ static void CheckIfShipNeedsService(Vehicle *v)
|
||||||
|
|
||||||
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
|
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
|
||||||
|
|
||||||
|
if (IsShipInDepot(v)) {
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
depot = FindClosestShipDepot(v);
|
depot = FindClosestShipDepot(v);
|
||||||
|
|
||||||
if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
|
if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
|
||||||
|
|
21
train_cmd.c
21
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
|
/* 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 */
|
* 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;
|
int count;
|
||||||
TileIndex tile = v->tile;
|
TileIndex tile = v->tile;
|
||||||
|
@ -846,7 +846,7 @@ int CheckTrainStoppedInDepot(const Vehicle *v)
|
||||||
* Also skip counting rear ends of multiheaded engines */
|
* Also skip counting rear ends of multiheaded engines */
|
||||||
if (!IsArticulatedPart(v) && !(!IsTrainEngine(v) && IsMultiheaded(v))) count++;
|
if (!IsArticulatedPart(v) && !(!IsTrainEngine(v) && IsMultiheaded(v))) count++;
|
||||||
if (v->u.rail.track != 0x80 || v->tile != tile ||
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,6 +854,18 @@ int CheckTrainStoppedInDepot(const Vehicle *v)
|
||||||
return count;
|
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.
|
* Unlink a rail wagon from the consist.
|
||||||
* @param v Vehicle to remove.
|
* @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)
|
(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (CheckTrainIsInsideDepot(v)) {
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST);
|
tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST);
|
||||||
/* Only go to the depot if it is not too far out of our way. */
|
/* 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) {
|
if (tfdd.best_length == (uint)-1 || tfdd.best_length > MAX_ACCEPTABLE_DEPOT_DIST) {
|
||||||
|
|
Loading…
Reference in New Issue