diff options
author | rubidium <rubidium@openttd.org> | 2010-09-08 18:55:58 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-09-08 18:55:58 +0000 |
commit | 9badab6454d18378fc81962c8883e9594b968276 (patch) | |
tree | 64f9b2aa92db6fbea21d89ad7ff17d50aed687e1 /src | |
parent | 835d63a8d7cfaaedca9358e1ba051bf87428e98a (diff) | |
download | openttd-9badab6454d18378fc81962c8883e9594b968276.tar.xz |
(svn r20768) -Codechange: unify send-to-depot commands
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft_cmd.cpp | 32 | ||||
-rw-r--r-- | src/command.cpp | 14 | ||||
-rw-r--r-- | src/command_type.h | 7 | ||||
-rw-r--r-- | src/group_gui.cpp | 9 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 25 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 25 | ||||
-rw-r--r-- | src/train_cmd.cpp | 25 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 34 | ||||
-rw-r--r-- | src/vehicle_func.h | 1 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 4 |
10 files changed, 42 insertions, 134 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 1a7710f53..f08b8cb14 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -357,32 +357,6 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination, 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) { 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); if (st == NULL) { 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(); 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 */ 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_AIRCRAFT_TO_HANGAR); + DoCommand(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT); 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 */ if (v->NeedsAutomaticServicing()) { 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(); } } diff --git a/src/command.cpp b/src/command.cpp index d862991ca..8078e9a9e 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -83,8 +83,8 @@ CommandProc CmdMoveRailVehicle; CommandProc CmdBuildVehicle; CommandProc CmdSellVehicle; CommandProc CmdRefitVehicle; +CommandProc CmdSendVehicleToDepot; -CommandProc CmdSendTrainToDepot; CommandProc CmdForceTrainProceed; CommandProc CmdReverseTrainDirection; @@ -114,12 +114,9 @@ CommandProc CmdRenamePresident; CommandProc CmdRenameStation; CommandProc CmdRenameDepot; -CommandProc CmdSendAircraftToHangar; - CommandProc CmdPlaceSign; CommandProc CmdRenameSign; -CommandProc CmdSendRoadVehToDepot; CommandProc CmdTurnRoadVeh; CommandProc CmdPause; @@ -137,8 +134,6 @@ CommandProc CmdDeleteTown; CommandProc CmdChangeSetting; CommandProc CmdChangeCompanySetting; -CommandProc CmdSendShipToDepot; - CommandProc CmdOrderRefit; CommandProc CmdCloneOrder; @@ -224,9 +219,9 @@ static const Command _command_proc_table[] = { DEF_CMD(CmdBuildVehicle, CMD_CLIENT_ID), // CMD_BUILD_VEHICLE DEF_CMD(CmdSellVehicle, CMD_CLIENT_ID), // CMD_SELL_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(CmdSendTrainToDepot, 0), // CMD_SEND_TRAIN_TO_DEPOT DEF_CMD(CmdForceTrainProceed, 0), // CMD_FORCE_TRAIN_PROCEED 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(CmdRenameDepot, 0), // CMD_RENAME_DEPOT - DEF_CMD(CmdSendAircraftToHangar, 0), // CMD_SEND_AIRCRAFT_TO_HANGAR - DEF_CMD(CmdPlaceSign, 0), // CMD_PLACE_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(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(CmdDeleteTown, CMD_OFFLINE), // CMD_DELETE_TOWN - DEF_CMD(CmdSendShipToDepot, 0), // CMD_SEND_SHIP_TO_DEPOT - DEF_CMD(CmdOrderRefit, 0), // CMD_ORDER_REFIT DEF_CMD(CmdCloneOrder, 0), // CMD_CLONE_ORDER diff --git a/src/command_type.h b/src/command_type.h index 41e6cf970..f9e890c70 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -180,9 +180,9 @@ enum Commands { CMD_BUILD_VEHICLE, ///< build a vehicle CMD_SELL_VEHICLE, ///< sell 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_SEND_TRAIN_TO_DEPOT, ///< send a train to a depot CMD_FORCE_TRAIN_PROCEED, ///< proceed a train to pass a red signal CMD_REVERSE_TRAIN_DIRECTION, ///< turn a train around @@ -211,12 +211,9 @@ enum Commands { CMD_RENAME_STATION, ///< rename a station CMD_RENAME_DEPOT, ///< rename a depot - CMD_SEND_AIRCRAFT_TO_HANGAR, ///< send an aircraft to a hanger - CMD_PLACE_SIGN, ///< place 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_PAUSE, ///< pause the game @@ -231,8 +228,6 @@ enum Commands { CMD_EXPAND_TOWN, ///< expand 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_CLONE_ORDER, ///< clone (and share) an order CMD_CLEAR_AREA, ///< clear an area diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 562d358be..70c6e2122 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -573,13 +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) - | DEPOT_MASS_SEND - | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type)); + 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)); break; case ADI_DEPOT: // Send to Depots - DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) - | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); + 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)); break; case ADI_ADD_SHARED: // Add shared Vehicles assert(Group::IsValidID(this->group_sel)); diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index d2529185f..1391d8cb7 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -311,31 +311,6 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati } /** - * 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. * @param tile unused * @param flags operation to perform diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index ef2b49fcc..019693547 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -635,28 +635,3 @@ bool Ship::FindClosestDepot(TileIndex *location, DestinationID *destination, boo 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)); -} diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 28b1d997f..2f0733e91 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1919,31 +1919,6 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bo 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] = { 1, 1, 1, 0, -1, -1, -1, 0 }; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index fd31393e2..5670e2e71 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -58,10 +58,10 @@ const uint32 _veh_refit_proc_table[] = { const uint32 _send_to_depot_proc_table[] = { /* 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_ROADVEH_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_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_TRAIN_TO_DEPOT) | CMD_NO_TEST_IF_IN_NETWORK, + CMD_SEND_VEHICLE_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_SHIP_TO_DEPOT), + CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR), }; @@ -840,6 +840,32 @@ 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 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 * @param tile unused * @param flags type of operation diff --git a/src/vehicle_func.h b/src/vehicle_func.h index 8cd52d7d9..ac6834b3f 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -59,7 +59,6 @@ void MarkSingleVehicleDirty(const Vehicle *v); UnitID GetFreeUnitNumber(VehicleType type); -CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id); void VehicleEnterDepot(Vehicle *v); bool CanBuildVehicleInfrastructure(VehicleType type); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index ee2c448ac..0312346dc 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1307,11 +1307,11 @@ public: 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) | 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; 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) | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); + (this->window_number & VLW_MASK) | this->vehicle_type << 11 | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); break; default: NOT_REACHED(); |