Changeset - r6638:3cf9aa498970
[Not reviewed]
master
0 13 0
rubidium - 17 years ago 2007-05-18 17:31:41
rubidium@openttd.org
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
13 files changed with 39 insertions and 28 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -62,7 +62,7 @@ void InvalidateAutoreplaceWindow(EngineI
 
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
 * @param type The type of engine
 
 */
 
void AddRemoveEngineFromAutoreplaceAndBuildWindows(byte type)
 
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
 
{
 
	_rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable
 
	_rebuild_right_list = true;
 
@@ -202,7 +202,7 @@ static void GenerateLists(Window *w)
 
}
 

	
 

	
 
void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count);
 
void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count);
 

	
 
static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
 
{
 
@@ -296,7 +296,7 @@ static void ReplaceVehicleWndProc(Window
 
				EngineID end    = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
 

	
 
				/* Do the actual drawing */
 
				DrawEngineList(w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0);
 
				DrawEngineList((VehicleType)w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0);
 

	
 
				/* Also draw the details if an engine is selected */
 
				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
 
@@ -480,7 +480,7 @@ static const WindowDesc _replace_ship_ai
 
};
 

	
 

	
 
void ShowReplaceVehicleWindow(byte vehicletype)
 
void ShowReplaceVehicleWindow(VehicleType vehicletype)
 
{
 
	Window *w;
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -543,6 +543,7 @@ int DrawVehiclePurchaseInfo(int x, int y
 
	bool refitable = false;
 

	
 
	switch (e->type) {
 
		default: NOT_REACHED();
 
		case VEH_TRAIN: {
 
			const RailVehicleInfo *rvi = RailVehInfo(engine_number);
 
			uint capacity = GetEngineProperty(engine_number, 0x14, rvi->capacity);
 
@@ -720,6 +721,7 @@ static void GenerateBuildList(Window *w)
 
	buildvehicle_d *bv = &WP(w, buildvehicle_d);
 

	
 
	switch (bv->vehicle_type) {
 
		default: NOT_REACHED();
 
		case VEH_TRAIN:
 
			GenerateBuildTrainList(w);
 
			return; // trains should not reach the last sorting
 
@@ -757,7 +759,7 @@ static void DrawVehicleEngine(byte type,
 
 * @param selected_id what engine to highlight as selected, if any
 
 * @param show_count Display the number of vehicles (used by autoreplace)
 
 */
 
void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count)
 
void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count)
 
{
 
	byte step_size = GetVehicleListHeight(type);
 
	byte x_offset = 0;
 
@@ -872,6 +874,7 @@ static void BuildVehicleClickEvent(Windo
 
			EngineID sel_eng = bv->sel_engine;
 
			if (sel_eng != INVALID_ENGINE) {
 
				switch (bv->vehicle_type) {
 
					default: NOT_REACHED();
 
					case VEH_TRAIN:
 
						DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco,
 
								   CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
 
@@ -897,6 +900,7 @@ static void BuildVehicleClickEvent(Windo
 

	
 
				bv->rename_engine = sel_eng;
 
				switch (bv->vehicle_type) {
 
					default: NOT_REACHED();
 
					case VEH_TRAIN:    str = STR_886A_RENAME_TRAIN_VEHICLE_TYPE; break;
 
					case VEH_ROAD:     str = STR_9036_RENAME_ROAD_VEHICLE_TYPE;  break;
 
					case VEH_SHIP:     str = STR_9838_RENAME_SHIP_TYPE;          break;
 
@@ -940,6 +944,7 @@ static void NewVehicleWndProc(Window *w,
 
				StringID str = STR_NULL;
 
				_cmd_text = e->we.edittext.str;
 
				switch (bv->vehicle_type) {
 
					default: NOT_REACHED();
 
					case VEH_TRAIN:    str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break;
 
					case VEH_ROAD:     str = STR_9037_CAN_T_RENAME_ROAD_VEHICLE;  break;
 
					case VEH_SHIP:     str = STR_9839_CAN_T_RENAME_SHIP_TYPE;     break;
 
@@ -977,7 +982,7 @@ static const WindowDesc _build_vehicle_d
 
	NewVehicleWndProc
 
};
 

	
 
void ShowBuildVehicleWindow(TileIndex tile, byte type)
 
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
 
{
 
	buildvehicle_d *bv;
 
	Window *w;
 
@@ -1006,6 +1011,7 @@ void ShowBuildVehicleWindow(TileIndex ti
 
	bv->descending_sort_order = _last_sort_order[type];
 

	
 
	switch (type) {
 
		default: NOT_REACHED();
 
		case VEH_TRAIN:
 
			WP(w, buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile);
 
			ResizeWindow(w, 0, 16);
src/depot.cpp
Show inline comments
 
@@ -4,6 +4,7 @@
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "vehicle.h"
 
#include "depot.h"
 
#include "functions.h"
 
#include "landscape.h"
src/depot.h
Show inline comments
 
@@ -42,7 +42,7 @@ static inline void DeleteDepot(Depot *de
 
	depot->xy = 0;
 
}
 

	
 
void ShowDepotWindow(TileIndex tile, byte type);
 
void ShowDepotWindow(TileIndex tile, VehicleType type);
 

	
 
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (IsValidDepot(d))
 
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
src/depot_gui.cpp
Show inline comments
 
@@ -657,7 +657,7 @@ static void ResizeDefaultWindowSizeForRo
 
	_block_sizes[VEH_ROAD][1] = GetVehicleListHeight(VEH_ROAD);
 
}
 

	
 
static void ResizeDefaultWindowSize(byte type)
 
static void ResizeDefaultWindowSize(VehicleType type)
 
{
 
	EngineID engine;
 
	uint max_width  = 0;
 
@@ -697,7 +697,7 @@ void InitDepotWindowBlockSizes()
 
	ResizeDefaultWindowSize(VEH_AIRCRAFT);
 
}
 

	
 
static void CreateDepotListWindow(Window *w, byte type)
 
static void CreateDepotListWindow(Window *w, VehicleType type)
 
{
 
	WP(w, depot_d).type = type;
 
	_backup_orders_tile = 0;
 
@@ -975,7 +975,7 @@ static void DepotWndProc(Window *w, Wind
 
 * @param tile The tile where the depot/hangar is located
 
 * @param type The type of vehicles in the depot
 
 */
 
void ShowDepotWindow(TileIndex tile, byte type)
 
void ShowDepotWindow(TileIndex tile, VehicleType type)
 
{
 
	Window *w;
 

	
src/engine.h
Show inline comments
 
@@ -120,7 +120,7 @@ struct Engine {
 
	PlayerByte preview_player;
 
	byte preview_wait;
 
	byte player_avail;
 
	byte type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. Same as in vehicle.h
 
	VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc. Same as in vehicle.h
 
};
 

	
 
/**
 
@@ -341,7 +341,7 @@ int32 RemoveEngineReplacement(EngineRene
 
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
 * @param type The type of engine
 
 */
 
void AddRemoveEngineFromAutoreplaceAndBuildWindows(byte type);
 
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
 

	
 
/* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */
 
void EngList_Create(EngineList *el);            ///< Creates engine list
src/newgrf.cpp
Show inline comments
 
@@ -4550,6 +4550,8 @@ static void CalculateRefitMasks()
 
		/* Check if this engine's cargo type is valid. If not, set to the first refittable
 
		 * cargo type. Apparently cargo_type isn't a common property... */
 
		switch (GetEngine(engine)->type) {
 
			default: NOT_REACHED();
 
			case VEH_AIRCRAFT: break;
 
			case VEH_TRAIN: {
 
				RailVehicleInfo *rvi = &_rail_vehicle_info[engine];
 
				if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine);
src/order_cmd.cpp
Show inline comments
 
@@ -6,10 +6,10 @@
 
#include "openttd.h"
 
#include "order.h"
 
#include "airport.h"
 
#include "vehicle.h"
 
#include "depot.h"
 
#include "functions.h"
 
#include "table/strings.h"
 
#include "vehicle.h"
 
#include "waypoint.h"
 
#include "command.h"
 
#include "station.h"
src/vehicle.cpp
Show inline comments
 
@@ -2443,6 +2443,7 @@ const Livery *GetEngineLivery(EngineID e
 
	if (p->livery[LS_DEFAULT].in_use && (_patches.liveries == 2 || (_patches.liveries == 1 && player == _local_player))) {
 
		/* Determine the livery scheme to use */
 
		switch (GetEngine(engine_type)->type) {
 
			default: NOT_REACHED();
 
			case VEH_TRAIN: {
 
				const RailVehicleInfo *rvi = RailVehInfo(engine_type);
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -45,7 +45,7 @@ struct vehiclelist_d {
 
	const Vehicle** sort_list;  // List of vehicles (sorted)
 
	Listing *_sorting;          // pointer to the appropiate subcategory of _sorting
 
	uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
 
	byte vehicle_type;          // The vehicle type that is sorted
 
	VehicleType vehicle_type;   // The vehicle type that is sorted
 
	list_d l;                   // General list struct
 
};
 
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
 
@@ -809,7 +809,7 @@ static void CreateVehicleListWindow(Wind
 
	uint16 window_type = w->window_number & VLW_MASK;
 
	PlayerID player = (PlayerID)GB(w->window_number, 0, 8);
 

	
 
	vl->vehicle_type = GB(w->window_number, 11, 5);
 
	vl->vehicle_type = (VehicleType)GB(w->window_number, 11, 5);
 
	vl->length_of_sort_list = 0;
 
	vl->sort_list = NULL;
 
	w->caption_color = player;
 
@@ -1236,7 +1236,7 @@ static const WindowDesc _player_vehicle_
 
	PlayerVehWndProc
 
};
 

	
 
static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number)
 
static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
 
{
 
	Window *w;
 
	WindowNumber num;
 
@@ -1273,7 +1273,7 @@ static void ShowVehicleListWindowLocal(P
 
	}
 
}
 

	
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type)
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
 
{
 
	ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
 
}
 
@@ -1284,12 +1284,12 @@ void ShowVehicleListWindow(const Vehicle
 
	ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index);
 
}
 

	
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station)
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
 
{
 
	ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station);
 
}
 

	
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile)
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile)
 
{
 
	uint16 depot_airport_index;
 

	
src/vehicle_gui.h
Show inline comments
 
@@ -41,7 +41,7 @@ void DrawRoadVehImage(const Vehicle *v, 
 
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
 
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
 

	
 
void ShowBuildVehicleWindow(TileIndex tile, byte type);
 
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
 

	
 
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
 

	
 
@@ -49,11 +49,11 @@ uint ShowAdditionalText(int x, int y, ui
 
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine);
 

	
 
void ShowVehicleListWindow(const Vehicle *v);
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type);
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station);
 
void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile);
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type);
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
 
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
 

	
 
void ShowReplaceVehicleWindow(byte vehicletype);
 
void ShowReplaceVehicleWindow(VehicleType vehicletype);
 

	
 
static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
 
{
 
@@ -66,7 +66,7 @@ static inline void DrawVehicleImage(cons
 
	}
 
}
 

	
 
static inline uint GetVehicleListHeight(byte type)
 
static inline uint GetVehicleListHeight(VehicleType type)
 
{
 
	return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
 
}
src/window.h
Show inline comments
 
@@ -10,6 +10,7 @@
 
#include "order.h"
 
#include "rail.h"
 
#include "airport.h"
 
#include "vehicle.h"
 

	
 
struct WindowEvent;
 

	
 
@@ -323,7 +324,7 @@ struct tooltips_d {
 
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
 

	
 
struct buildvehicle_d {
 
	byte vehicle_type;
 
	VehicleType vehicle_type;
 
	union {
 
		RailTypeByte railtype;
 
		AirportFTAClass::Flags flags;
 
@@ -352,7 +353,7 @@ assert_compile(WINDOW_CUSTOM_SIZE >= siz
 

	
 
struct depot_d {
 
	VehicleID sel;
 
	byte type;
 
	VehicleType type;
 
	bool generate_list;
 
	uint16 engine_list_length;
 
	uint16 wagon_list_length;
src/yapf/yapf.hpp
Show inline comments
 
@@ -7,6 +7,7 @@
 

	
 
#include "track_dir.hpp"
 

	
 
#include "../vehicle.h"
 
#include "../depot.h"
 
#include "../road_map.h"
 
#include "../tunnel_map.h"
 
@@ -14,7 +15,6 @@
 
#include "../bridge.h"
 
#include "../station.h"
 
#include "../station_map.h"
 
#include "../vehicle.h"
 
#include "../date.h"
 
#include "../functions.h"
 
#include "../landscape.h"
0 comments (0 inline, 0 general)