summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-09-08 21:02:12 +0000
committerrubidium <rubidium@openttd.org>2010-09-08 21:02:12 +0000
commitea4b40704b351de69cff4a6beaa4cf526f18bb9b (patch)
tree1e52f45f4b9c8eb28e73a845946519c5074e0571 /src
parent9badab6454d18378fc81962c8883e9594b968276 (diff)
downloadopenttd-ea4b40704b351de69cff4a6beaa4cf526f18bb9b.tar.xz
(svn r20769) -Codechange: move some depot flags from p2 to p1 in CmdSendVehicleToDepot
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_vehicle.cpp2
-rw-r--r--src/aircraft_cmd.cpp4
-rw-r--r--src/group_gui.cpp8
-rw-r--r--src/vehicle_cmd.cpp14
-rw-r--r--src/vehicle_gui.cpp10
-rw-r--r--src/vehicle_type.h13
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<CompanyByte> 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<CompanyByte> 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'