summaryrefslogtreecommitdiff
path: root/src/vehicle_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-04-17 13:31:41 +0000
committerfrosch <frosch@openttd.org>2010-04-17 13:31:41 +0000
commit75d4bc947ddbb92ecf660d9a9858c854d5e34a15 (patch)
treeb218a672a78b894388373d2e700e6ad6ebe75b63 /src/vehicle_cmd.cpp
parent184fa43df2e14c73162e641bc9bc83e403f069ed (diff)
downloadopenttd-75d4bc947ddbb92ecf660d9a9858c854d5e34a15.tar.xz
(svn r19654) -Codechange: Use Extract<> in more places.
Diffstat (limited to 'src/vehicle_cmd.cpp')
-rw-r--r--src/vehicle_cmd.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 892d05c52..1d3963162 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -13,6 +13,7 @@
#include "roadveh.h"
#include "news_func.h"
#include "airport.h"
+#include "cmd_helper.h"
#include "command_func.h"
#include "company_func.h"
#include "vehicle_gui.h"
@@ -126,17 +127,19 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
* - bit 0-4 Vehicle type
* - bit 5 false = start vehicles, true = stop vehicles
* - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
- * - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
+ * - bit 8-11 Vehicle List Window type (ignored unless bit 6 is set)
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
VehicleList list;
- VehicleType vehicle_type = (VehicleType)GB(p2, 0, 5);
+ VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p2);
bool start_stop = HasBit(p2, 5);
bool vehicle_list_window = HasBit(p2, 6);
+ if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
+
if (vehicle_list_window) {
uint32 id = p1;
uint16 window_type = p2 & VLW_MASK;
@@ -180,9 +183,11 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
VehicleList list;
CommandCost cost(EXPENSES_NEW_VEHICLES);
- VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
+ VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
uint sell_command = GetCmdSellVeh(vehicle_type);
+ if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
+
/* Get the list of vehicles in the depot */
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
@@ -214,8 +219,9 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32
{
VehicleList list;
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
- VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
+ VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
+ if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
/* Get the list of vehicles in the depot */