mirror of https://github.com/OpenTTD/OpenTTD
(svn r20768) -Codechange: unify send-to-depot commands
parent
835d63a8d7
commit
9badab6454
|
@ -357,32 +357,6 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send an aircraft to the hangar.
|
|
||||||
* @param tile unused
|
|
||||||
* @param flags for command type
|
|
||||||
* @param p1 vehicle ID to send to the hangar
|
|
||||||
* @param p2 various bitmasked elements
|
|
||||||
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
|
||||||
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
|
||||||
* @param text unused
|
|
||||||
* @return the cost of this operation or an error
|
|
||||||
*/
|
|
||||||
CommandCost CmdSendAircraftToHangar(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
||||||
{
|
|
||||||
if (p2 & DEPOT_MASS_SEND) {
|
|
||||||
/* Mass goto depot requested */
|
|
||||||
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
|
|
||||||
return SendAllVehiclesToDepot(VEH_AIRCRAFT, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Aircraft *v = Aircraft::GetIfValid(p1);
|
|
||||||
if (v == NULL) return CMD_ERROR;
|
|
||||||
|
|
||||||
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void CheckIfAircraftNeedsService(Aircraft *v)
|
static void CheckIfAircraftNeedsService(Aircraft *v)
|
||||||
{
|
{
|
||||||
if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
|
if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
|
||||||
|
@ -1093,7 +1067,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
||||||
const Station *st = GetTargetAirportIfValid(v);
|
const Station *st = GetTargetAirportIfValid(v);
|
||||||
if (st == NULL) {
|
if (st == NULL) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
|
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
|
|
||||||
if (ret.Failed()) CrashAirplane(v);
|
if (ret.Failed()) CrashAirplane(v);
|
||||||
|
@ -1400,7 +1374,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
|
||||||
/* Send the helicopter to a hangar if needed for replacement */
|
/* Send the helicopter to a hangar if needed for replacement */
|
||||||
if (v->NeedsAutomaticServicing()) {
|
if (v->NeedsAutomaticServicing()) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
DoCommand(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
|
DoCommand(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1450,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 */
|
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
||||||
if (v->NeedsAutomaticServicing()) {
|
if (v->NeedsAutomaticServicing()) {
|
||||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
||||||
DoCommand(v->tile, v->index, DEPOT_SERVICE, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
|
DoCommand(v->tile, v->index, DEPOT_SERVICE, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,8 @@ CommandProc CmdMoveRailVehicle;
|
||||||
CommandProc CmdBuildVehicle;
|
CommandProc CmdBuildVehicle;
|
||||||
CommandProc CmdSellVehicle;
|
CommandProc CmdSellVehicle;
|
||||||
CommandProc CmdRefitVehicle;
|
CommandProc CmdRefitVehicle;
|
||||||
|
CommandProc CmdSendVehicleToDepot;
|
||||||
|
|
||||||
CommandProc CmdSendTrainToDepot;
|
|
||||||
CommandProc CmdForceTrainProceed;
|
CommandProc CmdForceTrainProceed;
|
||||||
CommandProc CmdReverseTrainDirection;
|
CommandProc CmdReverseTrainDirection;
|
||||||
|
|
||||||
|
@ -114,12 +114,9 @@ CommandProc CmdRenamePresident;
|
||||||
CommandProc CmdRenameStation;
|
CommandProc CmdRenameStation;
|
||||||
CommandProc CmdRenameDepot;
|
CommandProc CmdRenameDepot;
|
||||||
|
|
||||||
CommandProc CmdSendAircraftToHangar;
|
|
||||||
|
|
||||||
CommandProc CmdPlaceSign;
|
CommandProc CmdPlaceSign;
|
||||||
CommandProc CmdRenameSign;
|
CommandProc CmdRenameSign;
|
||||||
|
|
||||||
CommandProc CmdSendRoadVehToDepot;
|
|
||||||
CommandProc CmdTurnRoadVeh;
|
CommandProc CmdTurnRoadVeh;
|
||||||
|
|
||||||
CommandProc CmdPause;
|
CommandProc CmdPause;
|
||||||
|
@ -137,8 +134,6 @@ CommandProc CmdDeleteTown;
|
||||||
CommandProc CmdChangeSetting;
|
CommandProc CmdChangeSetting;
|
||||||
CommandProc CmdChangeCompanySetting;
|
CommandProc CmdChangeCompanySetting;
|
||||||
|
|
||||||
CommandProc CmdSendShipToDepot;
|
|
||||||
|
|
||||||
CommandProc CmdOrderRefit;
|
CommandProc CmdOrderRefit;
|
||||||
CommandProc CmdCloneOrder;
|
CommandProc CmdCloneOrder;
|
||||||
|
|
||||||
|
@ -224,9 +219,9 @@ static const Command _command_proc_table[] = {
|
||||||
DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID), // CMD_BUILD_VEHICLE
|
DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID), // CMD_BUILD_VEHICLE
|
||||||
DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID), // CMD_SELL_VEHICLE
|
DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID), // CMD_SELL_VEHICLE
|
||||||
DEF_CMD(CmdRefitVehicle, 0), // CMD_REFIT_VEHICLE
|
DEF_CMD(CmdRefitVehicle, 0), // CMD_REFIT_VEHICLE
|
||||||
|
DEF_CMD(CmdSendVehicleToDepot, 0), // CMD_SEND_VEHICLE_TO_DEPOT
|
||||||
|
|
||||||
DEF_CMD(CmdMoveRailVehicle, 0), // CMD_MOVE_RAIL_VEHICLE
|
DEF_CMD(CmdMoveRailVehicle, 0), // CMD_MOVE_RAIL_VEHICLE
|
||||||
DEF_CMD(CmdSendTrainToDepot, 0), // CMD_SEND_TRAIN_TO_DEPOT
|
|
||||||
DEF_CMD(CmdForceTrainProceed, 0), // CMD_FORCE_TRAIN_PROCEED
|
DEF_CMD(CmdForceTrainProceed, 0), // CMD_FORCE_TRAIN_PROCEED
|
||||||
DEF_CMD(CmdReverseTrainDirection, 0), // CMD_REVERSE_TRAIN_DIRECTION
|
DEF_CMD(CmdReverseTrainDirection, 0), // CMD_REVERSE_TRAIN_DIRECTION
|
||||||
|
|
||||||
|
@ -256,12 +251,9 @@ static const Command _command_proc_table[] = {
|
||||||
DEF_CMD(CmdRenameStation, 0), // CMD_RENAME_STATION
|
DEF_CMD(CmdRenameStation, 0), // CMD_RENAME_STATION
|
||||||
DEF_CMD(CmdRenameDepot, 0), // CMD_RENAME_DEPOT
|
DEF_CMD(CmdRenameDepot, 0), // CMD_RENAME_DEPOT
|
||||||
|
|
||||||
DEF_CMD(CmdSendAircraftToHangar, 0), // CMD_SEND_AIRCRAFT_TO_HANGAR
|
|
||||||
|
|
||||||
DEF_CMD(CmdPlaceSign, 0), // CMD_PLACE_SIGN
|
DEF_CMD(CmdPlaceSign, 0), // CMD_PLACE_SIGN
|
||||||
DEF_CMD(CmdRenameSign, 0), // CMD_RENAME_SIGN
|
DEF_CMD(CmdRenameSign, 0), // CMD_RENAME_SIGN
|
||||||
|
|
||||||
DEF_CMD(CmdSendRoadVehToDepot, 0), // CMD_SEND_ROADVEH_TO_DEPOT
|
|
||||||
DEF_CMD(CmdTurnRoadVeh, 0), // CMD_TURN_ROADVEH
|
DEF_CMD(CmdTurnRoadVeh, 0), // CMD_TURN_ROADVEH
|
||||||
|
|
||||||
DEF_CMD(CmdPause, CMD_SERVER), // CMD_PAUSE
|
DEF_CMD(CmdPause, CMD_SERVER), // CMD_PAUSE
|
||||||
|
@ -276,8 +268,6 @@ static const Command _command_proc_table[] = {
|
||||||
DEF_CMD(CmdExpandTown, CMD_OFFLINE), // CMD_EXPAND_TOWN
|
DEF_CMD(CmdExpandTown, CMD_OFFLINE), // CMD_EXPAND_TOWN
|
||||||
DEF_CMD(CmdDeleteTown, CMD_OFFLINE), // CMD_DELETE_TOWN
|
DEF_CMD(CmdDeleteTown, CMD_OFFLINE), // CMD_DELETE_TOWN
|
||||||
|
|
||||||
DEF_CMD(CmdSendShipToDepot, 0), // CMD_SEND_SHIP_TO_DEPOT
|
|
||||||
|
|
||||||
DEF_CMD(CmdOrderRefit, 0), // CMD_ORDER_REFIT
|
DEF_CMD(CmdOrderRefit, 0), // CMD_ORDER_REFIT
|
||||||
DEF_CMD(CmdCloneOrder, 0), // CMD_CLONE_ORDER
|
DEF_CMD(CmdCloneOrder, 0), // CMD_CLONE_ORDER
|
||||||
|
|
||||||
|
|
|
@ -180,9 +180,9 @@ enum Commands {
|
||||||
CMD_BUILD_VEHICLE, ///< build a vehicle
|
CMD_BUILD_VEHICLE, ///< build a vehicle
|
||||||
CMD_SELL_VEHICLE, ///< sell a vehicle
|
CMD_SELL_VEHICLE, ///< sell a vehicle
|
||||||
CMD_REFIT_VEHICLE, ///< refit the cargo space of a vehicle
|
CMD_REFIT_VEHICLE, ///< refit the cargo space of a vehicle
|
||||||
|
CMD_SEND_VEHICLE_TO_DEPOT, ///< send a vehicle to a depot
|
||||||
|
|
||||||
CMD_MOVE_RAIL_VEHICLE, ///< move a rail vehicle (in the depot)
|
CMD_MOVE_RAIL_VEHICLE, ///< move a rail vehicle (in the depot)
|
||||||
CMD_SEND_TRAIN_TO_DEPOT, ///< send a train to a depot
|
|
||||||
CMD_FORCE_TRAIN_PROCEED, ///< proceed a train to pass a red signal
|
CMD_FORCE_TRAIN_PROCEED, ///< proceed a train to pass a red signal
|
||||||
CMD_REVERSE_TRAIN_DIRECTION, ///< turn a train around
|
CMD_REVERSE_TRAIN_DIRECTION, ///< turn a train around
|
||||||
|
|
||||||
|
@ -211,12 +211,9 @@ enum Commands {
|
||||||
CMD_RENAME_STATION, ///< rename a station
|
CMD_RENAME_STATION, ///< rename a station
|
||||||
CMD_RENAME_DEPOT, ///< rename a depot
|
CMD_RENAME_DEPOT, ///< rename a depot
|
||||||
|
|
||||||
CMD_SEND_AIRCRAFT_TO_HANGAR, ///< send an aircraft to a hanger
|
|
||||||
|
|
||||||
CMD_PLACE_SIGN, ///< place a sign
|
CMD_PLACE_SIGN, ///< place a sign
|
||||||
CMD_RENAME_SIGN, ///< rename a sign
|
CMD_RENAME_SIGN, ///< rename a sign
|
||||||
|
|
||||||
CMD_SEND_ROADVEH_TO_DEPOT, ///< send a road vehicle to the depot
|
|
||||||
CMD_TURN_ROADVEH, ///< turn a road vehicle around
|
CMD_TURN_ROADVEH, ///< turn a road vehicle around
|
||||||
|
|
||||||
CMD_PAUSE, ///< pause the game
|
CMD_PAUSE, ///< pause the game
|
||||||
|
@ -231,8 +228,6 @@ enum Commands {
|
||||||
CMD_EXPAND_TOWN, ///< expand a town
|
CMD_EXPAND_TOWN, ///< expand a town
|
||||||
CMD_DELETE_TOWN, ///< delete a town
|
CMD_DELETE_TOWN, ///< delete a town
|
||||||
|
|
||||||
CMD_SEND_SHIP_TO_DEPOT, ///< send a ship to a depot
|
|
||||||
|
|
||||||
CMD_ORDER_REFIT, ///< change the refit informaction of an order (for "goto depot" )
|
CMD_ORDER_REFIT, ///< change the refit informaction of an order (for "goto depot" )
|
||||||
CMD_CLONE_ORDER, ///< clone (and share) an order
|
CMD_CLONE_ORDER, ///< clone (and share) an order
|
||||||
CMD_CLEAR_AREA, ///< clear an area
|
CMD_CLEAR_AREA, ///< clear an area
|
||||||
|
|
|
@ -573,13 +573,12 @@ public:
|
||||||
ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
|
ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
|
||||||
break;
|
break;
|
||||||
case ADI_SERVICE: // Send for servicing
|
case ADI_SERVICE: // Send for servicing
|
||||||
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
|
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) |
|
||||||
| DEPOT_MASS_SEND
|
this->vehicle_type << 11 | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
|
||||||
| DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
|
|
||||||
break;
|
break;
|
||||||
case ADI_DEPOT: // Send to Depots
|
case ADI_DEPOT: // Send to Depots
|
||||||
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
|
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) |
|
||||||
| DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
|
this->vehicle_type << 11 | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
|
||||||
break;
|
break;
|
||||||
case ADI_ADD_SHARED: // Add shared Vehicles
|
case ADI_ADD_SHARED: // Add shared Vehicles
|
||||||
assert(Group::IsValidID(this->group_sel));
|
assert(Group::IsValidID(this->group_sel));
|
||||||
|
|
|
@ -310,31 +310,6 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a road vehicle to the depot.
|
|
||||||
* @param tile unused
|
|
||||||
* @param flags operation to perform
|
|
||||||
* @param p1 vehicle ID to send to the depot
|
|
||||||
* @param p2 various bitmasked elements
|
|
||||||
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
|
||||||
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
|
||||||
* @param text unused
|
|
||||||
* @return the cost of this operation or an error
|
|
||||||
*/
|
|
||||||
CommandCost CmdSendRoadVehToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
||||||
{
|
|
||||||
if (p2 & DEPOT_MASS_SEND) {
|
|
||||||
/* Mass goto depot requested */
|
|
||||||
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
|
|
||||||
return SendAllVehiclesToDepot(VEH_ROAD, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
|
||||||
if (v == NULL) return CMD_ERROR;
|
|
||||||
|
|
||||||
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a roadvehicle around.
|
* Turn a roadvehicle around.
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
|
|
|
@ -635,28 +635,3 @@ bool Ship::FindClosestDepot(TileIndex *location, DestinationID *destination, boo
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a ship to the depot.
|
|
||||||
* @param tile unused
|
|
||||||
* @param flags type of operation
|
|
||||||
* @param p1 vehicle ID to send to the depot
|
|
||||||
* @param p2 various bitmasked elements
|
|
||||||
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
|
||||||
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
|
||||||
* @param text unused
|
|
||||||
* @return the cost of this operation or an error
|
|
||||||
*/
|
|
||||||
CommandCost CmdSendShipToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
||||||
{
|
|
||||||
if (p2 & DEPOT_MASS_SEND) {
|
|
||||||
/* Mass goto depot requested */
|
|
||||||
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
|
|
||||||
return SendAllVehiclesToDepot(VEH_SHIP, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ship *v = Ship::GetIfValid(p1);
|
|
||||||
if (v == NULL) return CMD_ERROR;
|
|
||||||
|
|
||||||
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
|
||||||
}
|
|
||||||
|
|
|
@ -1919,31 +1919,6 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bo
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a train to a depot
|
|
||||||
* @param tile unused
|
|
||||||
* @param flags type of operation
|
|
||||||
* @param p1 train to send to the depot
|
|
||||||
* @param p2 various bitmasked elements
|
|
||||||
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
|
||||||
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
|
||||||
* @param text unused
|
|
||||||
* @return the cost of this operation or an error
|
|
||||||
*/
|
|
||||||
CommandCost CmdSendTrainToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
||||||
{
|
|
||||||
if (p2 & DEPOT_MASS_SEND) {
|
|
||||||
/* Mass goto depot requested */
|
|
||||||
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
|
|
||||||
return SendAllVehiclesToDepot(VEH_TRAIN, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Train *v = Train::GetIfValid(p1);
|
|
||||||
if (v == NULL) return CMD_ERROR;
|
|
||||||
|
|
||||||
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int8 _vehicle_smoke_pos[8] = {
|
static const int8 _vehicle_smoke_pos[8] = {
|
||||||
1, 1, 1, 0, -1, -1, -1, 0
|
1, 1, 1, 0, -1, -1, -1, 0
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,10 +58,10 @@ const uint32 _veh_refit_proc_table[] = {
|
||||||
|
|
||||||
const uint32 _send_to_depot_proc_table[] = {
|
const uint32 _send_to_depot_proc_table[] = {
|
||||||
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
|
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
|
||||||
CMD_SEND_TRAIN_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT) | CMD_NO_TEST_IF_IN_NETWORK,
|
CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT) | CMD_NO_TEST_IF_IN_NETWORK,
|
||||||
CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT),
|
CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT),
|
||||||
CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT),
|
CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT),
|
||||||
CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR),
|
CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -839,6 +839,32 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s
|
||||||
return had_success ? CommandCost() : CMD_ERROR;
|
return had_success ? CommandCost() : CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a vehicle to the depot.
|
||||||
|
* @param tile unused
|
||||||
|
* @param flags for command type
|
||||||
|
* @param p1 vehicle ID to send to the depot
|
||||||
|
* @param p2 various bitmasked elements
|
||||||
|
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
||||||
|
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
||||||
|
* - p2 bit 10-11 - Vehicle type
|
||||||
|
* @param text unused
|
||||||
|
* @return the cost of this operation or an error
|
||||||
|
*/
|
||||||
|
CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||||
|
{
|
||||||
|
if (p2 & 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||||
|
if (v == NULL) return CMD_ERROR;
|
||||||
|
|
||||||
|
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give a custom name to your vehicle
|
* Give a custom name to your vehicle
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
|
|
|
@ -59,7 +59,6 @@ void MarkSingleVehicleDirty(const Vehicle *v);
|
||||||
|
|
||||||
UnitID GetFreeUnitNumber(VehicleType type);
|
UnitID GetFreeUnitNumber(VehicleType type);
|
||||||
|
|
||||||
CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id);
|
|
||||||
void VehicleEnterDepot(Vehicle *v);
|
void VehicleEnterDepot(Vehicle *v);
|
||||||
|
|
||||||
bool CanBuildVehicleInfrastructure(VehicleType type);
|
bool CanBuildVehicleInfrastructure(VehicleType type);
|
||||||
|
|
|
@ -1307,11 +1307,11 @@ public:
|
||||||
break;
|
break;
|
||||||
case ADI_SERVICE: // Send for servicing
|
case ADI_SERVICE: // Send for servicing
|
||||||
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
|
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
|
||||||
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
|
(this->window_number & VLW_MASK) | this->vehicle_type << 11 | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
|
||||||
break;
|
break;
|
||||||
case ADI_DEPOT: // Send to Depots
|
case ADI_DEPOT: // Send to Depots
|
||||||
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
|
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
|
||||||
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
|
(this->window_number & VLW_MASK) | this->vehicle_type << 11 | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
Loading…
Reference in New Issue