summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-18 23:38:29 +0000
committerrubidium <rubidium@openttd.org>2007-05-18 23:38:29 +0000
commitc17c5e972b4735aa4403290f2d89e97fbd3c652d (patch)
tree1e88755eb84e37a678801bac38bf96f319d82f44
parent96e90442499241432d02bba99ff6fce92d4950af (diff)
downloadopenttd-c17c5e972b4735aa4403290f2d89e97fbd3c652d.tar.xz
(svn r9872) -Codechange: more type strictness for vehicle types
-rw-r--r--src/vehicle.cpp15
-rw-r--r--src/vehicle.h21
2 files changed, 18 insertions, 18 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 8b626a4d3..22fd5d8fe 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1566,7 +1566,7 @@ int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
int32 return_value = CMD_ERROR;
uint i;
uint stop_command;
- byte vehicle_type = GB(p2, 0, 5);
+ VehicleType vehicle_type = (VehicleType)GB(p2, 0, 5);
bool start_stop = HASBIT(p2, 5);
bool vehicle_list_window = HASBIT(p2, 6);
@@ -1633,7 +1633,7 @@ int32 CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
int32 cost = 0;
uint i, sell_command, total_number_vehicles;
- byte vehicle_type = GB(p1, 0, 8);
+ VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
switch (vehicle_type) {
case VEH_TRAIN: sell_command = CMD_SELL_RAIL_WAGON; break;
@@ -1682,8 +1682,7 @@ int32 CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
uint16 engine_count = 0;
uint i, x = 0, y = 0, z = 0;
int32 cost = 0;
- byte vehicle_type = GB(p1, 0, 8);
-
+ VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
@@ -1895,7 +1894,7 @@ static inline void ExtendVehicleListSize(const Vehicle ***engine_list, uint16 *e
* @param *wagon_list_length Allocated size of wagon_list. Needs to be set to 0 when wagon_list points to a NULL array
* @param *wagon_count The number of engines stored in the list
*/
-void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count)
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count)
{
Vehicle *v;
@@ -1978,7 +1977,7 @@ void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, ui
* @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h
* @return the number of vehicles added to the list
*/
-uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type)
+uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
{
const byte subtype = (type != VEH_AIRCRAFT) ? (byte)Train_Front : (byte)AIR_AIRCRAFT;
uint n = 0;
@@ -2075,7 +2074,7 @@ uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array
* @param vlw_flag tells what kind of list requested the goto depot
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
*/
-int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
+int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
{
const Vehicle **sort_list = NULL;
uint n, i;
@@ -2385,7 +2384,7 @@ uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
}
-UnitID GetFreeUnitNumber(byte type)
+UnitID GetFreeUnitNumber(VehicleType type)
{
UnitID unit, max = 0;
const Vehicle *u;
diff --git a/src/vehicle.h b/src/vehicle.h
index 81efc6293..d2f66c1be 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -522,7 +522,7 @@ void EndVehicleMove(Vehicle *v);
void ShowAircraftViewWindow(const Vehicle* v);
-UnitID GetFreeUnitNumber(byte type);
+UnitID GetFreeUnitNumber(VehicleType type);
void TrainConsistChanged(Vehicle *v);
void TrainPowerChanged(Vehicle *v);
@@ -532,9 +532,9 @@ int CheckTrainStoppedInDepot(const Vehicle *v);
bool VehicleNeedsService(const Vehicle *v);
-uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type);
-void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
-int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
+uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
+int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
bool IsVehicleInDepot(const Vehicle *v);
void VehicleEnterDepot(Vehicle *v);
@@ -610,7 +610,7 @@ static inline void DeleteVehicle(Vehicle *v)
v = new (v) InvalidVehicle();
}
-static inline bool IsPlayerBuildableVehicleType(byte type)
+static inline bool IsPlayerBuildableVehicleType(VehicleType type)
{
switch (type) {
case VEH_TRAIN:
@@ -618,8 +618,9 @@ static inline bool IsPlayerBuildableVehicleType(byte type)
case VEH_SHIP:
case VEH_AIRCRAFT:
return true;
+
+ default: return false;
}
- return false;
}
static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
@@ -715,7 +716,7 @@ extern const uint32 _veh_refit_proc_table[];
extern const uint32 _send_to_depot_proc_table[];
/* Functions to find the right command for certain vehicle type */
-static inline uint32 GetCmdBuildVeh(byte type)
+static inline uint32 GetCmdBuildVeh(VehicleType type)
{
return _veh_build_proc_table[type];
}
@@ -725,7 +726,7 @@ static inline uint32 GetCmdBuildVeh(const Vehicle *v)
return GetCmdBuildVeh(v->type);
}
-static inline uint32 GetCmdSellVeh(byte type)
+static inline uint32 GetCmdSellVeh(VehicleType type)
{
return _veh_sell_proc_table[type];
}
@@ -735,7 +736,7 @@ static inline uint32 GetCmdSellVeh(const Vehicle *v)
return GetCmdSellVeh(v->type);
}
-static inline uint32 GetCmdRefitVeh(byte type)
+static inline uint32 GetCmdRefitVeh(VehicleType type)
{
return _veh_refit_proc_table[type];
}
@@ -745,7 +746,7 @@ static inline uint32 GetCmdRefitVeh(const Vehicle *v)
return GetCmdRefitVeh(v->type);
}
-static inline uint32 GetCmdSendToDepot(byte type)
+static inline uint32 GetCmdSendToDepot(VehicleType type)
{
return _send_to_depot_proc_table[type];
}