Changeset - r6641:2d673d99874d
[Not reviewed]
master
0 2 0
rubidium - 17 years ago 2007-05-18 23:38:29
rubidium@openttd.org
(svn r9872) -Codechange: more type strictness for vehicle types
2 files changed with 18 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -1563,13 +1563,13 @@ int32 CmdMassStartStopVehicle(TileIndex 
 
	Vehicle **vl = NULL;
 
	uint16 engine_list_length = 0;
 
	uint16 engine_count = 0;
 
	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);
 

	
 
	switch (vehicle_type) {
 
		case VEH_TRAIN:    stop_command = CMD_START_STOP_TRAIN;    break;
 
		case VEH_ROAD:     stop_command = CMD_START_STOP_ROADVEH;  break;
 
@@ -1630,13 +1630,13 @@ int32 CmdDepotSellAllVehicles(TileIndex 
 
	uint16 engine_count = 0;
 
	uint16 wagon_list_length = 0;
 
	uint16 wagon_count = 0;
 

	
 
	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;
 
		case VEH_ROAD:     sell_command = CMD_SELL_ROAD_VEH;   break;
 
		case VEH_SHIP:     sell_command = CMD_SELL_SHIP;       break;
 
		case VEH_AIRCRAFT: sell_command = CMD_SELL_AIRCRAFT;   break;
 
@@ -1679,14 +1679,13 @@ int32 CmdDepotMassAutoReplace(TileIndex 
 
{
 
	Vehicle **vl = NULL;
 
	uint16 engine_list_length = 0;
 
	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;
 

	
 
	/* Get the list of vehicles in the depot */
 
	BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, NULL, NULL, NULL);
 

	
 
@@ -1892,13 +1891,13 @@ static inline void ExtendVehicleListSize
 
 * @param *engine_list_length Allocated size of engine_list. Needs to be set to 0 when engine_list points to a NULL array
 
 * @param *engine_count The number of engines stored in the list
 
 * @param ***wagon_list Pointer to a pointer to an array of free wagons in the depot (old list is freed and a new one is malloced)
 
 * @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;
 

	
 
	/* This function should never be called without an array to store results */
 
	assert(!(engine_list == NULL && type != VEH_TRAIN));
 
	assert(!(type == VEH_TRAIN && engine_list == NULL && wagon_list == NULL));
 
@@ -1975,13 +1974,13 @@ void BuildDepotVehicleList(byte type, Ti
 
      <li>VLW_STANDARD: not used<li>
 
      <li>VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for</li>
 
    </ul>
 
* @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;
 
	const Vehicle *v;
 

	
 
	switch (window_type) {
 
@@ -2072,13 +2071,13 @@ uint GenerateVehicleSortList(const Vehic
 
 * @param flags the flags used for DoCommand()
 
 * @param service should the vehicles only get service in the depots
 
 * @param owner PlayerID of owner of the vehicles to send
 
 * @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;
 
	uint16 array_length = 0;
 

	
 
	n = GenerateVehicleSortList(&sort_list, &array_length, type, owner, id, vlw_flag);
 
@@ -2382,13 +2381,13 @@ Trackdir GetVehicleTrackdir(const Vehicl
 
 */
 
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;
 
	static bool *cache = NULL;
 
	static UnitID gmax = 0;
 

	
src/vehicle.h
Show inline comments
 
@@ -519,25 +519,25 @@ void VehicleEnteredDepotThisTick(Vehicle
 

	
 
void BeginVehicleMove(Vehicle *v);
 
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);
 
int32 GetTrainRunningCost(const Vehicle *v);
 

	
 
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);
 

	
 
void InvalidateAutoreplaceWindow(EngineID e);
 

	
 
int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
 
@@ -607,22 +607,23 @@ void DestroyVehicle(Vehicle *v);
 
static inline void DeleteVehicle(Vehicle *v)
 
{
 
	DestroyVehicle(v);
 
	v = new (v) InvalidVehicle();
 
}
 

	
 
static inline bool IsPlayerBuildableVehicleType(byte type)
 
static inline bool IsPlayerBuildableVehicleType(VehicleType type)
 
{
 
	switch (type) {
 
		case VEH_TRAIN:
 
		case VEH_ROAD:
 
		case VEH_SHIP:
 
		case VEH_AIRCRAFT:
 
			return true;
 

	
 
		default: return false;
 
	}
 
	return false;
 
}
 

	
 
static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
 
{
 
	return IsPlayerBuildableVehicleType(v->type);
 
}
 
@@ -712,43 +713,43 @@ SpriteID GetVehiclePalette(const Vehicle
 
extern const uint32 _veh_build_proc_table[];
 
extern const uint32 _veh_sell_proc_table[];
 
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];
 
}
 

	
 
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];
 
}
 

	
 
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];
 
}
 

	
 
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];
 
}
 

	
 
static inline uint32 GetCmdSendToDepot(const Vehicle *v)
 
{
0 comments (0 inline, 0 general)