From ea4b40704b351de69cff4a6beaa4cf526f18bb9b Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 8 Sep 2010 21:02:12 +0000 Subject: (svn r20769) -Codechange: move some depot flags from p2 to p1 in CmdSendVehicleToDepot --- src/ai/api/ai_vehicle.cpp | 2 +- src/aircraft_cmd.cpp | 4 ++-- src/group_gui.cpp | 8 ++++---- src/vehicle_cmd.cpp | 14 ++++++++------ src/vehicle_gui.cpp | 10 +++++----- src/vehicle_type.h | 13 ++++++------- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index e62cb585b..bb4f756af 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -170,7 +170,7 @@ { EnforcePrecondition(false, IsValidVehicle(vehicle_id)); - return AIObject::DoCommand(0, vehicle_id, DEPOT_SERVICE, GetCmdSendToDepot(::Vehicle::Get(vehicle_id))); + return AIObject::DoCommand(0, vehicle_id | DEPOT_SERVICE, 0, GetCmdSendToDepot(::Vehicle::Get(vehicle_id))); } /* static */ bool AIVehicle::IsInDepot(VehicleID vehicle_id) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index f08b8cb14..907fedb58 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1374,7 +1374,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass /* Send the helicopter to a hangar if needed for replacement */ if (v->NeedsAutomaticServicing()) { Backup cur_company(_current_company, v->owner, FILE_LINE); - DoCommand(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT); + DoCommand(v->tile, v->index | DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT); cur_company.Restore(); } } @@ -1424,7 +1424,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *apc /* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */ if (v->NeedsAutomaticServicing()) { Backup cur_company(_current_company, v->owner, FILE_LINE); - DoCommand(v->tile, v->index, DEPOT_SERVICE, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT); + DoCommand(v->tile, v->index | DEPOT_SERVICE, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT); cur_company.Restore(); } } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 70c6e2122..b8cb5227d 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -573,12 +573,12 @@ public: ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type); break; case ADI_SERVICE: // Send for servicing - DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) | - this->vehicle_type << 11 | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type)); + DoCommandP(0, this->group_sel | DEPOT_MASS_SEND | DEPOT_SERVICE, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) | + this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type)); break; case ADI_DEPOT: // Send to Depots - DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) | - this->vehicle_type << 11 | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); + DoCommandP(0, this->group_sel | DEPOT_MASS_SEND, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) | + this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type)); break; case ADI_ADD_SHARED: // Add shared Vehicles assert(Group::IsValidID(this->group_sel)); diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 5670e2e71..b65be4c40 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -823,7 +823,7 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s bool had_success = false; for (uint i = 0; i < list.Length(); i++) { const Vehicle *v = list[i]; - CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type)); + CommandCost ret = DoCommand(v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0, flags, GetCmdSendToDepot(type)); if (ret.Succeeded()) { had_success = true; @@ -843,7 +843,9 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s * Send a vehicle to the depot. * @param tile unused * @param flags for command type - * @param p1 vehicle ID to send to the depot + * @param p1 bitmask + * - p1 0-20: bitvehicle ID to send to the depot + * - p1 bits 25-8 - DEPOT_ flags (see vehicle_type.h) * @param p2 various bitmasked elements * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h) * - p2 bit 8-10 - VLW flag (for mass goto depot) @@ -853,16 +855,16 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s */ CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - if (p2 & DEPOT_MASS_SEND) { + if (p1 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR; - return SendAllVehiclesToDepot((VehicleType)GB(p2, 11, 2), flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1); + return SendAllVehiclesToDepot((VehicleType)GB(p2, 11, 2), flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), GB(p1, 0, 20)); } - Vehicle *v = Vehicle::GetIfValid(p1); + Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20)); if (v == NULL) return CMD_ERROR; - return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK)); + return v->SendToDepot(flags, (DepotCommand)(p1 & DEPOT_COMMAND_MASK)); } /** diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 0312346dc..87123489f 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1306,12 +1306,12 @@ public: ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type); break; case ADI_SERVICE: // Send for servicing - DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, - (this->window_number & VLW_MASK) | this->vehicle_type << 11 | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type)); + DoCommandP(0, GB(this->window_number, 16, 16) | DEPOT_MASS_SEND | DEPOT_SERVICE /* StationID or OrderID (depending on VLW) */, + (this->window_number & VLW_MASK) | this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type)); break; case ADI_DEPOT: // Send to Depots - DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, - (this->window_number & VLW_MASK) | this->vehicle_type << 11 | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); + DoCommandP(0, GB(this->window_number, 16, 16) | DEPOT_MASS_SEND /* StationID or OrderID (depending on VLW) */, + (this->window_number & VLW_MASK) | this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type)); break; default: NOT_REACHED(); @@ -2262,7 +2262,7 @@ public: } case VVW_WIDGET_GOTO_DEPOT: // goto hangar - DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, GetCmdSendToDepot(v)); + DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0U, GetCmdSendToDepot(v)); break; case VVW_WIDGET_REFIT_VEH: // refit ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this); diff --git a/src/vehicle_type.h b/src/vehicle_type.h index dc283de16..57f55a2b7 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -54,14 +54,13 @@ enum VehiclePathFinders { VPF_YAPF = 2, ///< Yet Another PathFinder }; -/* Flags to add to p2 for goto depot commands - * Note: bits 8-10 are used for VLW flags */ +/** Flags to add to p1 for goto depot commands. */ enum DepotCommand { - DEPOT_SERVICE = (1 << 0), ///< The vehicle will leave the depot right after arrival (serivce only) - DEPOT_MASS_SEND = (1 << 1), ///< Tells that it's a mass send to depot command (type in VLW flag) - DEPOT_DONT_CANCEL = (1 << 2), ///< Don't cancel current goto depot command if any - DEPOT_LOCATE_HANGAR = (1 << 3), ///< Find another airport if the target one lacks a hangar - DEPOT_COMMAND_MASK = 0xF, + DEPOT_SERVICE = (1U << 28), ///< The vehicle will leave the depot right after arrival (serivce only) + DEPOT_MASS_SEND = (1U << 29), ///< Tells that it's a mass send to depot command (type in VLW flag) + DEPOT_DONT_CANCEL = (1U << 30), ///< Don't cancel current goto depot command if any + DEPOT_LOCATE_HANGAR = (1U << 31), ///< Find another airport if the target one lacks a hangar + DEPOT_COMMAND_MASK = 0xFU << 28, }; static const uint MAX_LENGTH_VEHICLE_NAME_BYTES = 31; ///< The maximum length of a vehicle name in bytes including '\0' -- cgit v1.2.3-70-g09d2