summaryrefslogtreecommitdiff
path: root/roadveh_cmd.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-09-01 10:24:15 +0000
committerbjarni <bjarni@openttd.org>2006-09-01 10:24:15 +0000
commitd7e1d08d53d7d9885c747d7e1095d607f8f5cebe (patch)
treee86a7aeb29a672f565ab4b7aa38c5cb4a0010e93 /roadveh_cmd.c
parent7d3685a8ad0661c43dda4deb8c2559226b3370fe (diff)
downloadopenttd-d7e1d08d53d7d9885c747d7e1095d607f8f5cebe.tar.xz
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
-Codechange: unified the code for mass goto depot to avoid duplicated code -Fix: Vehicles already on the way to depots will not be cancelled by mass goto depot (made it really hard to send all vehicles at once)
Diffstat (limited to 'roadveh_cmd.c')
-rw-r--r--roadveh_cmd.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index f4801c7c3..9d3488c77 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -358,33 +358,32 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v)
* @param tile unused
* @param p1 vehicle ID to send to the depot
* @param p2 various bitmasked elements
- * - p2 bit 0 - if bit 0 is set, then the road vehicle will only service at the depot. 0 Makes it stop inside
- * - p2 bit 1 - send all of shared orders to depot
+ * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
+ * - p2 bit 8-10 - VLW flag (for mass goto depot)
*/
int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
const Depot *dep;
- const int32 return_value = HASBIT(p2, 1) ? 0 : CMD_ERROR;
- if (HASBIT(p2, 1) && (p2 & VLW_FLAGS) == VLW_STANDARD) {
- return SendAllVehiclesToDepot(VEH_Road, flags, HASBIT(p2, 0), _current_player);
+ if (p2 & DEPOT_MASS_SEND) {
+ /* Mass goto depot requested */
+ if (!ValidVLWFlags(p2 & VLW_FLAGS)) return CMD_ERROR;
+ return SendAllVehiclesToDepot(VEH_Road, flags, p2 & DEPOT_SERVICE, _current_player, (p2 & VLW_FLAGS), p1);
}
- if (!IsValidVehicleID(p1)) return return_value;
+ if (!IsValidVehicleID(p1)) return CMD_ERROR;
v = GetVehicle(p1);
- if (v->type != VEH_Road || !CheckOwnership(v->owner)) return return_value;
-
- if (HASBIT(p2, 1) && v->next_shared != NULL) CmdSendRoadVehToDepot(tile, flags, v->next_shared->index, p2);
+ if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR;
- if (v->vehstatus & VS_CRASHED) return return_value;
+ if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
/* If the current orders are already goto-depot */
if (v->current_order.type == OT_GOTO_DEPOT) {
+ if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
if (flags & DC_EXEC) {
- if (HASBIT(p2, 1)) return 0; // Mass ordering goto depot should not turn goto depot orders off
/* If the orders to 'goto depot' are in the orders list (forced servicing),
* then skip to the next order; effectively cancelling this forced service */
if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
@@ -398,16 +397,13 @@ int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
dep = FindClosestRoadDepot(v);
- if (dep == NULL) {
- if (HASBIT(p2, 1)) return 0; // Mass ordering goto depot should not return error
- return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT);
- }
+ if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT);
if (flags & DC_EXEC) {
ClearSlot(v);
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
- if (!HASBIT(p2,0)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
+ if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
v->current_order.dest.depot = dep->index;
v->dest_tile = dep->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);