mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20769) -Codechange: move some depot flags from p2 to p1 in CmdSendVehicleToDepot
This commit is contained in:
parent
9badab6454
commit
ea4b40704b
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue