diff options
author | bjarni <bjarni@openttd.org> | 2006-08-29 23:39:57 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-08-29 23:39:57 +0000 |
commit | 15f92083028b9d10b73739ce78be108c62a73759 (patch) | |
tree | d40d87b7909a66cde4dabc692991518710af28ed /train_cmd.c | |
parent | b85a5d8cc87187345707cbe3c47dbb5a4ef8de27 (diff) | |
download | openttd-15f92083028b9d10b73739ce78be108c62a73759.tar.xz |
(svn r6229) -Feature: Shared order lists now got a "goto depot" button
this will try to send all vehicles in the list to depots/hangars
currently if one fails to find a depot, it will not tell the player
Diffstat (limited to 'train_cmd.c')
-rw-r--r-- | train_cmd.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/train_cmd.c b/train_cmd.c index 021058ff6..9686595d8 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1924,23 +1924,29 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) /** Send a train to a depot * @param tile unused * @param p1 train to send to the depot - * @param p2 if bit 0 is set, then the train will only service at the depot. 0 Makes it stop inside + * @param p2 various bitmasked elements + * - p2 bit 0 - if bit 0 is set, then the train will only service at the depot. 0 Makes it stop inside + * - p2 bit 1 - send all of shared orders to depot */ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { Vehicle *v; TrainFindDepotData tfdd; + const int32 return_value = HASBIT(p2, 1) ? 0 : CMD_ERROR; - if (!IsValidVehicleID(p1)) return CMD_ERROR; + if (!IsValidVehicleID(p1)) return return_value; v = GetVehicle(p1); - if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; + if (v->type != VEH_Train || !CheckOwnership(v->owner)) return return_value; - if (v->vehstatus & VS_CRASHED) return CMD_ERROR; + if (HASBIT(p2, 1) && v->next_shared != NULL) CmdSendTrainToDepot(tile, flags, v->next_shared->index, p2); + + if (v->vehstatus & VS_CRASHED) return return_value; if (v->current_order.type == OT_GOTO_DEPOT) { if (flags & DC_EXEC) { + if (HASBIT(p2, 1)) return 0; // Mass ordering goto depot should not turn goto depot orders off if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) { v->u.rail.days_since_order_progr = 0; v->cur_order_index++; @@ -1954,8 +1960,10 @@ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } tfdd = FindClosestTrainDepot(v, 0); - if (tfdd.best_length == (uint)-1) + if (tfdd.best_length == (uint)-1) { + if (HASBIT(p2, 1)) return 0; // Mass ordering goto depot should not return error return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO); + } if (flags & DC_EXEC) { v->dest_tile = tfdd.tile; |