Changeset - r9365:9bd51de92a64
[Not reviewed]
master
0 9 0
peter1138 - 16 years ago 2008-05-26 16:23:23
peter1138@openttd.org
(svn r13266) -Codechange: Use SmallVector in GUIList
9 files changed with 92 insertions and 185 deletions:
0 comments (0 inline, 0 general)
src/bridge_gui.cpp
Show inline comments
 
@@ -117,23 +117,23 @@ private:
 
	TileIndex end_tile;
 
	uint32 type;
 
	GUIBridgeList *bridges;
 

	
 
	void BuildBridge(uint8 i)
 
	{
 
		DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->sort_list[i].index,
 
		DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index,
 
				CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
 
	}
 

	
 
	/** Sort the builable bridges */
 
	void SortBridgeList()
 
	{
 
		/* Skip sorting if resort bit is not set */
 
		if (!(bridges->flags & VL_RESORT)) return;
 

	
 
		qsort(this->bridges->sort_list, this->bridges->list_length, sizeof(this->bridges->sort_list[0]), _bridge_sorter[_bridge_sorting.criteria]);
 
		qsort(this->bridges->Begin(), this->bridges->Length(), sizeof(this->bridges->Begin()), _bridge_sorter[_bridge_sorting.criteria]);
 

	
 
		/* Display the current sort variant */
 
		this->widget[BBSW_DROPDOWN_CRITERIA].data = _bridge_sort_listing[this->bridges->sort_type];
 

	
 
		bridges->flags &= ~VL_RESORT;
 

	
 
@@ -152,13 +152,13 @@ public:
 
		this->SortBridgeList();
 

	
 
		/* Change the data, or the caption of the gui. Set it to road or rail, accordingly */
 
		this->widget[BBSW_CAPTION].data = (GB(this->type, 15, 2) == TRANSPORT_ROAD) ? STR_1803_SELECT_ROAD_BRIDGE : STR_100D_SELECT_RAIL_BRIDGE;
 

	
 
		this->resize.step_height = 22;
 
		this->vscroll.count = bl->list_length;
 
		this->vscroll.count = bl->Length();
 

	
 
		if (this->last_size <= 4) {
 
			this->vscroll.cap = 4;
 
		} else {
 
			/* Resize the bridge selection window if we used a bigger one the last time */
 
			this->vscroll.cap = (this->vscroll.count > this->last_size) ? this->last_size : this->vscroll.count;
 
@@ -168,28 +168,27 @@ public:
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~BuildBridgeWindow()
 
	{
 
		free(this->bridges->sort_list);
 
		delete bridges;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 

	
 
		this->DrawSortButtonState(BBSW_DROPDOWN_ORDER, (this->bridges->flags & VL_DESC) ? SBS_DOWN : SBS_UP);
 

	
 
		uint y = this->widget[BBSW_BRIDGE_LIST].top + 2;
 

	
 
		for (int i = this->vscroll.pos; (i < (this->vscroll.cap + this->vscroll.pos)) && (i < this->bridges->list_length); i++) {
 
			const BridgeSpec *b = this->bridges->sort_list[i].spec;
 
		for (int i = this->vscroll.pos; (i < (this->vscroll.cap + this->vscroll.pos)) && (i < (int)this->bridges->Length()); i++) {
 
			const BridgeSpec *b = this->bridges->Get(i)->spec;
 

	
 
			SetDParam(2, this->bridges->sort_list[i].cost);
 
			SetDParam(2, this->bridges->Get(i)->cost);
 
			SetDParam(1, b->speed * 10 / 16);
 
			SetDParam(0, b->material);
 

	
 
			DrawSprite(b->sprite, b->pal, 3, y);
 
			DrawString(44, y, STR_500D, TC_FROMSTRING);
 
			y += this->resize.step_height;
 
@@ -197,13 +196,13 @@ public:
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		const uint8 i = keycode - '1';
 
		if (i < 9 && i < this->bridges->list_length) {
 
		if (i < 9 && i < this->bridges->Length()) {
 
			/* Build the requested bridge */
 
			this->BuildBridge(i);
 
			delete this;
 
			return ES_HANDLED;
 
		}
 
		return ES_NOT_HANDLED;
 
@@ -214,13 +213,13 @@ public:
 
		switch (widget) {
 
			default: break;
 
			case BBSW_BRIDGE_LIST: {
 
				uint i = ((int)pt.y - this->widget[BBSW_BRIDGE_LIST].top) / this->resize.step_height;
 
				if (i < this->vscroll.cap) {
 
					i += this->vscroll.pos;
 
					if (i < this->bridges->list_length) {
 
					if (i < this->bridges->Length()) {
 
						this->BuildBridge(i);
 
						delete this;
 
					}
 
				}
 
			} break;
 

	
 
@@ -251,13 +250,13 @@ public:
 
	}
 

	
 
	virtual void OnResize(Point new_size, Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 
		this->widget[BBSW_BRIDGE_LIST].data = (this->vscroll.cap << 8) + 1;
 
		SetVScrollCount(this, this->bridges->list_length);
 
		SetVScrollCount(this, this->bridges->Length());
 

	
 
		this->last_size = this->vscroll.cap;
 
	}
 
};
 

	
 
/* Set the default size of the Build Bridge Window */
 
@@ -283,41 +282,12 @@ static const WindowDesc _build_bridge_de
 
	WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
 
	_build_bridge_widgets,
 
};
 

	
 
/**
 
 * Add a buildable bridge to the list.
 
 *  If the list is empty a new one is created.
 
 *
 
 * @param bl The list which we want to manage
 
 * @param item The item to add
 
 * @return The pointer to the list
 
 */
 
static GUIBridgeList *PushBridgeList(GUIBridgeList *bl, BuildBridgeData item)
 
{
 
	if (bl == NULL) {
 
		/* Create the list if needed */
 
		bl = new GUIBridgeList();
 
		bl->flags |= VL_RESORT;
 
		if (_bridge_sorting.order) bl->flags |= VL_DESC;
 
		bl->list_length = 1;
 
		bl->sort_type = _bridge_sorting.criteria;
 
	} else {
 
		/* Resize the list */
 
		bl->list_length++;
 
	}
 

	
 
	bl->sort_list = ReallocT(bl->sort_list, bl->list_length);
 

	
 
	bl->sort_list[bl->list_length - 1] = item;
 

	
 
	return bl;
 
}
 

	
 
/**
 
 * Prepare the data for the build a bridge window.
 
 *  If we can't build a bridge under the given conditions
 
 *  show an error message.
 
 *
 
 * @parma start The start tile of the bridge
 
 * @param end The end tile of the bridge
 
@@ -347,27 +317,29 @@ void ShowBuildBridgeWindow(TileIndex sta
 
		 * get absolute bridge length
 
		 * length of the middle parts of the bridge */
 
		const uint bridge_len = GetTunnelBridgeLength(start, end);
 
		/* total length of bridge */
 
		const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
 

	
 
		bl = new GUIBridgeList();
 

	
 
		/* loop for all bridgetypes */
 
		for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
 
			if (CheckBridge_Stuff(brd_type, bridge_len)) {
 
				/* bridge is accepted, add to list */
 
				BuildBridgeData item;
 
				item.index = brd_type;
 
				item.spec = GetBridgeSpec(brd_type);
 
				BuildBridgeData *item = bl->Append();
 
				item->index = brd_type;
 
				item->spec = GetBridgeSpec(brd_type);
 
				/* Add to terraforming & bulldozing costs the cost of the
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				item.cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * item.spec->price) >> 8);
 
				bl = PushBridgeList(bl, item);
 
				item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * item->spec->price) >> 8);
 
			}
 
		}
 
	}
 

	
 
	if (bl != NULL) {
 
	if (bl != NULL && bl->Length() != 0) {
 
		new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
 
	} else {
 
		if (bl != NULL) delete bl;
 
		ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 
	}
 
}
src/group_gui.cpp
Show inline comments
 
@@ -29,28 +29,22 @@
 
#include "table/sprites.h"
 

	
 
typedef GUIList<const Group*> GUIGroupList;
 

	
 
static void BuildGroupList(GUIGroupList *gl, PlayerID owner, VehicleType vehicle_type)
 
{
 
	uint n = 0;
 

	
 
	if (!(gl->flags & VL_REBUILD)) return;
 

	
 
	const Group **list = MallocT<const Group*>(GetGroupArraySize());
 
	gl->Clear();
 

	
 
	const Group *g;
 
	FOR_ALL_GROUPS(g) {
 
		if (g->owner == owner && g->vehicle_type == vehicle_type) list[n++] = g;
 
		if (g->owner == owner && g->vehicle_type != vehicle_type) *gl->Append() = g;
 
	}
 

	
 
	gl->sort_list = ReallocT(gl->sort_list, n);
 
	gl->list_length = n;
 

	
 
	for (uint i = 0; i < n; ++i) gl->sort_list[i] = list[i];
 
	free(list);
 
	gl->Compact();
 

	
 
	gl->flags &= ~VL_REBUILD;
 
	gl->flags |= VL_RESORT;
 
}
 

	
 

	
 
@@ -84,13 +78,13 @@ static int CDECL GroupNameSorter(const v
 

	
 

	
 
static void SortGroupList(GUIGroupList *gl)
 
{
 
	if (!(gl->flags & VL_RESORT)) return;
 

	
 
	qsort((void*)gl->sort_list, gl->list_length, sizeof(gl->sort_list[0]), GroupNameSorter);
 
	qsort((void*)gl->Begin(), gl->Length(), sizeof(gl->Begin()), GroupNameSorter);
 

	
 
	gl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 
	gl->flags &= ~VL_RESORT;
 
}
 

	
 

	
 
@@ -220,18 +214,18 @@ struct VehicleGroupWindow : public Windo
 
			case VEH_TRAIN:    this->sorting = &_sorting.train;    break;
 
			case VEH_ROAD:     this->sorting = &_sorting.roadveh;  break;
 
			case VEH_SHIP:     this->sorting = &_sorting.ship;     break;
 
			case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
 
		}
 

	
 
		this->vehicles.sort_list = NULL;
 
		this->vehicles.Clear();
 
		this->vehicles.sort_type = this->sorting->criteria;
 
		this->vehicles.flags = VL_REBUILD | (this->sorting->order ? VL_DESC : VL_NONE);
 
		this->vehicles.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
 

	
 
		this->groups.sort_list = NULL;
 
		this->groups.Clear();
 
		this->groups.flags = VL_REBUILD | VL_NONE;
 
		this->groups.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
 

	
 
		this->group_sel = ALL_GROUP;
 
		this->vehicle_sel = INVALID_VEHICLE;
 

	
 
@@ -277,14 +271,12 @@ struct VehicleGroupWindow : public Windo
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~VehicleGroupWindow()
 
	{
 
		free((void*)this->vehicles.sort_list);
 
		free((void*)this->groups.sort_list);
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		this->vehicles.flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
 
		this->groups.flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
 
@@ -310,23 +302,23 @@ struct VehicleGroupWindow : public Windo
 
		SortVehicleList(this);
 

	
 

	
 
		BuildGroupList(&this->groups, owner, this->vehicle_type);
 
		SortGroupList(&this->groups);
 

	
 
		SetVScrollCount(this, this->groups.list_length);
 
		SetVScroll2Count(this, this->vehicles.list_length);
 
		SetVScrollCount(this, this->groups.Length());
 
		SetVScroll2Count(this, this->vehicles.Length());
 

	
 
		/* The drop down menu is out, *but* it may not be used, retract it. */
 
		if (this->vehicles.list_length == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
 
		if (this->vehicles.Length() == 0 && this->IsWidgetLowered(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN)) {
 
			this->RaiseWidget(GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
 
			HideDropDownMenu(this);
 
		}
 

	
 
		/* Disable all lists management button when the list is empty */
 
		this->SetWidgetsDisabledState(this->vehicles.list_length == 0 || _local_player != owner,
 
		this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_player != owner,
 
				GRP_WIDGET_STOP_ALL,
 
				GRP_WIDGET_START_ALL,
 
				GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN,
 
				WIDGET_LIST_END);
 

	
 
		/* Disable the group specific function when we select the default group or all vehicles */
 
@@ -349,13 +341,13 @@ struct VehicleGroupWindow : public Windo
 

	
 

	
 
		/* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
 
				We list all vehicles or ungrouped vehicles */
 
		if (IsDefaultGroupID(this->group_sel) || IsAllGroupID(this->group_sel)) {
 
			SetDParam(0, owner);
 
			SetDParam(1, this->vehicles.list_length);
 
			SetDParam(1, this->vehicles.Length());
 

	
 
			switch (this->vehicle_type) {
 
				case VEH_TRAIN:
 
					this->widget[GRP_WIDGET_CAPTION].data = STR_881B_TRAINS;
 
					this->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_TRAIN;
 
					break;
 
@@ -431,15 +423,15 @@ struct VehicleGroupWindow : public Windo
 
		DrawString(10, y1, str_all_veh, IsAllGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
 

	
 
		y1 += 13;
 

	
 
		DrawString(10, y1, str_no_group_veh, IsDefaultGroupID(this->group_sel) ? TC_WHITE : TC_BLACK);
 

	
 
		max = min(this->vscroll.pos + this->vscroll.cap, this->groups.list_length);
 
		max = min(this->vscroll.pos + this->vscroll.cap, this->groups.Length());
 
		for (i = this->vscroll.pos ; i < max ; ++i) {
 
			const Group *g = this->groups.sort_list[i];
 
			const Group *g = this->groups[i];
 

	
 
			assert(g->owner == owner);
 

	
 
			y1 += PLY_WND_PRC__SIZE_OF_ROW_TINY;
 

	
 
			/* draw the selected group in white, else we draw it in black */
 
@@ -451,15 +443,15 @@ struct VehicleGroupWindow : public Windo
 
			DrawStringRightAligned(187, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK);
 
		}
 

	
 
		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
 

	
 
		/* Draw Matrix Vehicle according to the vehicle list built before */
 
		max = min(this->vscroll2.pos + this->vscroll2.cap, this->vehicles.list_length);
 
		max = min(this->vscroll2.pos + this->vscroll2.cap, this->vehicles.Length());
 
		for (i = this->vscroll2.pos ; i < max ; ++i) {
 
			const Vehicle* v = this->vehicles.sort_list[i];
 
			const Vehicle* v = this->vehicles[i];
 

	
 
			assert(v->type == this->vehicle_type && v->owner == owner);
 

	
 
			DrawVehicleImage(v, x + 19, y2 + 6, this->vehicle_sel, this->hscroll.cap, 0);
 
			DrawVehicleProfitButton(v, x, y2 + 13);
 

	
 
@@ -518,15 +510,15 @@ struct VehicleGroupWindow : public Windo
 
				uint16 id_g = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET - 26) / PLY_WND_PRC__SIZE_OF_ROW_TINY;
 

	
 
				if (id_g >= this->vscroll.cap) return;
 

	
 
				id_g += this->vscroll.pos;
 

	
 
				if (id_g >= this->groups.list_length) return;
 
				if (id_g >= this->groups.Length()) return;
 

	
 
				this->group_sel = this->groups.sort_list[id_g]->index;;
 
				this->group_sel = this->groups[id_g]->index;;
 

	
 
				this->vehicles.flags |= VL_REBUILD;
 
				this->SetDirty();
 
				break;
 
			}
 

	
 
@@ -535,15 +527,15 @@ struct VehicleGroupWindow : public Windo
 
				const Vehicle *v;
 

	
 
				if (id_v >= this->vscroll2.cap) return; // click out of bounds
 

	
 
				id_v += this->vscroll2.pos;
 

	
 
				if (id_v >= this->vehicles.list_length) return; // click out of list bound
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 

	
 
				v = this->vehicles.sort_list[id_v];
 
				v = this->vehicles[id_v];
 

	
 
				this->vehicle_sel = v->index;
 

	
 
				if (v->IsValid()) {
 
					SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), VHM_DRAG, this);
 
					_cursor.vehchain = true;
 
@@ -625,15 +617,15 @@ struct VehicleGroupWindow : public Windo
 
				this->SetDirty();
 

	
 
				if (id_g >= this->vscroll.cap) return;
 

	
 
				id_g += this->vscroll.pos;
 

	
 
				if (id_g >= this->groups.list_length) return;
 
				if (id_g >= this->groups.Length()) return;
 

	
 
				DoCommandP(0, this->groups.sort_list[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
 
				DoCommandP(0, this->groups[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
 

	
 
				break;
 
			}
 

	
 
			case GRP_WIDGET_LIST_VEHICLE: { // Maxtrix vehicle
 
				uint32 id_v = (pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / (int)this->resize.step_height;
 
@@ -645,15 +637,15 @@ struct VehicleGroupWindow : public Windo
 
				this->SetDirty();
 

	
 
				if (id_v >= this->vscroll2.cap) return; // click out of bounds
 

	
 
				id_v += this->vscroll2.pos;
 

	
 
				if (id_v >= this->vehicles.list_length) return; // click out of list bound
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 

	
 
				v = this->vehicles.sort_list[id_v];
 
				v = this->vehicles[id_v];
 

	
 
				if (vindex == v->index) {
 
					ShowVehicleViewWindow(v);
 
				}
 

	
 
				break;
 
@@ -690,13 +682,13 @@ struct VehicleGroupWindow : public Windo
 
					this->vehicles.sort_type = index;
 
					this->sorting->criteria = this->vehicles.sort_type;
 
				}
 
				break;
 

	
 
			case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN:
 
				assert(this->vehicles.list_length != 0);
 
				assert(this->vehicles.Length() != 0);
 

	
 
				switch (index) {
 
					case GALF_REPLACE: // Replace window
 
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
 
						break;
 
					case GALF_SERVICE: // Send for servicing
src/industry_gui.cpp
Show inline comments
 
@@ -809,33 +809,27 @@ typedef GUIList<const Industry*> GUIIndu
 
 * Rebuild industries list if the VL_REBUILD flag is set
 
 *
 
 * @param sl pointer to industry list
 
 */
 
static void BuildIndustriesList(GUIIndustryList *sl)
 
{
 
	uint n = 0;
 
	const Industry *i;
 

	
 
	if (!(sl->flags & VL_REBUILD)) return;
 

	
 
	/* Create array for sorting */
 
	const Industry **industry_sort = MallocT<const Industry*>(GetMaxIndustryIndex() + 1);
 
	sl->Clear();
 

	
 
	DEBUG(misc, 3, "Building industry list");
 

	
 
	FOR_ALL_INDUSTRIES(i) industry_sort[n++] = i;
 
	const Industry *i;
 
	FOR_ALL_INDUSTRIES(i) {
 
		*sl->Append() = i;
 
	}
 

	
 
	free((void*)sl->sort_list);
 
	sl->sort_list = MallocT<const Industry*>(n);
 
	sl->list_length = n;
 

	
 
	for (uint i = 0; i < n; ++i) sl->sort_list[i] = industry_sort[i];
 
	sl->Compact();
 

	
 
	sl->flags &= ~VL_REBUILD;
 
	sl->flags |= VL_RESORT;
 
	free((void*)industry_sort);
 
}
 

	
 

	
 
/**
 
 * Sort industry list if the VL_RESORT flag is set
 
 *
 
@@ -844,13 +838,13 @@ static void BuildIndustriesList(GUIIndus
 
static void SortIndustriesList(GUIIndustryList *sl)
 
{
 
	if (!(sl->flags & VL_RESORT)) return;
 

	
 
	_internal_sort_order = (sl->sort_type << 1) | (sl->flags & VL_DESC);
 
	_last_industry = NULL; // used for "cache" in namesorting
 
	qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), &GeneralIndustrySorter);
 
	qsort((void*)sl->Begin(), sl->Length(), sizeof(sl->Begin()), &GeneralIndustrySorter);
 

	
 
	sl->flags &= ~VL_RESORT;
 
}
 

	
 
/**
 
 * The list of industries.
 
@@ -862,33 +856,32 @@ struct IndustryDirectoryWindow : public 
 
	{
 
		this->vscroll.cap = 16;
 
		this->resize.height = this->height - 6 * 10; // minimum 10 items
 
		this->resize.step_height = 10;
 
		this->FindWindowPlacementAndResize(desc);
 

	
 
		this->sort_list = NULL;
 
		this->flags = VL_REBUILD;
 
		this->sort_type = industry_sort.criteria;
 
		if (industry_sort.order) this->flags |= VL_DESC;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		BuildIndustriesList(this);
 
		SortIndustriesList(this);
 

	
 
		SetVScrollCount(this, this->list_length);
 
		SetVScrollCount(this, this->Length());
 

	
 
		this->DrawWidgets();
 
		this->DrawSortButtonState(IDW_SORTBYNAME + this->sort_type, this->flags & VL_DESC ? SBS_DOWN : SBS_UP);
 

	
 
		int max = min(this->vscroll.pos + this->vscroll.cap, this->list_length);
 
		int max = min(this->vscroll.pos + this->vscroll.cap, this->Length());
 
		int y = 28; // start of the list-widget
 

	
 
		for (int n = this->vscroll.pos; n < max; ++n) {
 
			const Industry* i = this->sort_list[n];
 
			const Industry* i = *this->Get(n);
 
			const IndustrySpec *indsp = GetIndustrySpec(i->type);
 
			byte p = 0;
 

	
 
			/* Industry name */
 
			SetDParam(p++, i->index);
 

	
 
@@ -937,17 +930,17 @@ struct IndustryDirectoryWindow : public 
 
			case IDW_INDUSTRY_LIST: {
 
				int y = (pt.y - 28) / 10;
 
				uint16 p;
 

	
 
				if (!IsInsideMM(y, 0, this->vscroll.cap)) return;
 
				p = y + this->vscroll.pos;
 
				if (p < this->list_length) {
 
				if (p < this->Length()) {
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(this->sort_list[p]->xy);
 
						ShowExtraViewPortWindow((*this->Get(p))->xy);
 
					} else {
 
						ScrollMainWindowToTile(this->sort_list[p]->xy);
 
						ScrollMainWindowToTile((*this->Get(p))->xy);
 
					}
 
				}
 
			} break;
 
		}
 
	}
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -187,46 +187,38 @@ struct NetworkGameWindow : public QueryS
 
		this->vscroll.cap = 11;
 
		this->resize.step_height = NET_PRC__SIZE_OF_ROW;
 

	
 
		this->field = NGWW_PLAYER;
 
		this->server = NULL;
 

	
 
		this->servers.sort_list = NULL;
 
		this->servers.flags = VL_REBUILD | (_ng_sorting.order ? VL_DESC : VL_NONE);
 
		this->servers.sort_type = _ng_sorting.criteria;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~NetworkGameWindow()
 
	{
 
		free(this->servers.sort_list);
 
	}
 

	
 
	/**
 
	 * (Re)build the network game list as its amount has changed because
 
	 * an item has been added or deleted for example
 
	 */
 
	void BuildNetworkGameList()
 
	{
 
		NetworkGameList *ngl_temp;
 
		uint n = 0;
 

	
 
		if (!(this->servers.flags & VL_REBUILD)) return;
 

	
 
		/* Count the number of games in the list */
 
		for (ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) n++;
 
		if (n == 0) return;
 
		/* Create temporary array of games to use for listing */
 
		this->servers.Clear();
 

	
 
		/* Create temporary array of games to use for listing */
 
		this->servers.sort_list = ReallocT(this->servers.sort_list, n);
 
		this->servers.list_length = n;
 
		for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) {
 
			*this->servers.Append() = ngl;
 
		}
 

	
 
		for (n = 0, ngl_temp = _network_game_list; ngl_temp != NULL; ngl_temp = ngl_temp->next) {
 
			this->servers.sort_list[n++] = ngl_temp;
 
		}
 
		this->servers.Compact();
 

	
 
		/* Force resort */
 
		this->servers.flags &= ~VL_REBUILD;
 
		this->servers.flags |= VL_RESORT;
 
	}
 

	
 
@@ -239,23 +231,23 @@ struct NetworkGameWindow : public QueryS
 
		};
 

	
 
		NetworkGameList *item;
 
		uint i;
 

	
 
		if (!(this->servers.flags & VL_RESORT)) return;
 
		if (this->servers.list_length == 0) return;
 
		if (this->servers.Length() == 0) return;
 

	
 
		_internal_sort_order = !!(this->servers.flags & VL_DESC);
 
		qsort(this->servers.sort_list, this->servers.list_length, sizeof(this->servers.sort_list[0]), ngame_sorter[this->servers.sort_type]);
 
		qsort(this->servers.Begin(), this->servers.Length(), sizeof(this->servers.Begin()), ngame_sorter[this->servers.sort_type]);
 

	
 
		/* After sorting ngl->sort_list contains the sorted items. Put these back
 
		 * into the original list. Basically nothing has changed, we are only
 
		 * shuffling the ->next pointers */
 
		_network_game_list = this->servers.sort_list[0];
 
		for (item = _network_game_list, i = 1; i != this->servers.list_length; i++) {
 
			item->next = this->servers.sort_list[i];
 
		_network_game_list = this->servers[0];
 
		for (item = _network_game_list, i = 1; i != this->servers.Length(); i++) {
 
			item->next = this->servers[i];
 
			item = item->next;
 
		}
 
		item->next = NULL;
 

	
 
		this->servers.flags &= ~VL_RESORT;
 
	}
 
@@ -297,13 +289,13 @@ struct NetworkGameWindow : public QueryS
 
	{
 
		const NetworkGameList *sel = this->server;
 
		const SortButtonState arrow = (this->servers.flags & VL_DESC) ? SBS_DOWN : SBS_UP;
 

	
 
		if (this->servers.flags & VL_REBUILD) {
 
			this->BuildNetworkGameList();
 
			SetVScrollCount(this, this->servers.list_length);
 
			SetVScrollCount(this, this->servers.Length());
 
		}
 
		if (this->servers.flags & VL_RESORT) this->SortNetworkGameList();
 

	
 
		/* 'Refresh' button invisible if no server selected */
 
		this->SetWidgetDisabledState(NGWW_REFRESH, sel == NULL);
 
		/* 'Join' button disabling conditions */
 
@@ -579,13 +571,13 @@ struct NetworkGameWindow : public QueryS
 
	virtual void OnResize(Point new_size, Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 

	
 
		this->widget[NGWW_MATRIX].data = (this->vscroll.cap << 8) + 1;
 

	
 
		SetVScrollCount(this, this->servers.list_length);
 
		SetVScrollCount(this, this->servers.Length());
 

	
 
		int widget_width = this->widget[NGWW_FIND].right - this->widget[NGWW_FIND].left;
 
		int space = (this->width - 4 * widget_width - 25) / 3;
 

	
 
		int offset = 10;
 
		for (uint i = 0; i < 4; i++) {
src/sortlist_type.h
Show inline comments
 
@@ -2,12 +2,14 @@
 

	
 
/** @file sortlist_type.h Base types for having sorted lists in GUIs. */
 

	
 
#ifndef SORTLIST_TYPE_H
 
#define SORTLIST_TYPE_H
 

	
 
#include "misc/smallvec.h"
 

	
 
enum SortListFlags {
 
	VL_NONE    = 0,      ///< no sort
 
	VL_DESC    = 1 << 0, ///< sort descending or ascending
 
	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
 
	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
 
	VL_END     = 1 << 3,
 
@@ -17,15 +19,13 @@ DECLARE_ENUM_AS_BIT_SET(SortListFlags);
 
struct Listing {
 
	bool order;    ///< Ascending/descending
 
	byte criteria; ///< Sorting criteria
 
};
 

	
 
template <typename T>
 
struct GUIList {
 
	T* sort_list;        ///< The items to sort.
 
struct GUIList : public SmallVector<T, 32> {
 
	SortListFlags flags; ///< used to control sorting/resorting/etc.
 
	uint16 list_length;  ///< length of the list being sorted
 
	uint16 resort_timer; ///< resort list after a given amount of ticks if set
 
	byte sort_type;      ///< what criteria to sort on
 
};
 

	
 
#endif /* SORTLIST_TYPE_H */
src/station_gui.cpp
Show inline comments
 
@@ -175,52 +175,44 @@ typedef GUIList<const Station*> GUIStati
 
 * @param facilities types of stations of interest
 
 * @param cargo_filter bitmap of cargo types to include
 
 * @param include_empty whether we should include stations without waiting cargo
 
 */
 
static void BuildStationsList(GUIStationList *sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty)
 
{
 
	uint n = 0;
 
	const Station *st;
 

	
 
	if (!(sl->flags & VL_REBUILD)) return;
 

	
 
	/* Create array for sorting */
 
	const Station **station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
 
	sl->Clear();
 

	
 
	DEBUG(misc, 3, "Building station list for player %d", owner);
 

	
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) {
 
			if (facilities & st->facilities) { //only stations with selected facilities
 
				int num_waiting_cargo = 0;
 
				for (CargoID j = 0; j < NUM_CARGO; j++) {
 
					if (!st->goods[j].cargo.Empty()) {
 
						num_waiting_cargo++; //count number of waiting cargo
 
						if (HasBit(cargo_filter, j)) {
 
							station_sort[n++] = st;
 
							*sl->Append() = st;
 
							break;
 
						}
 
					}
 
				}
 
				/* stations without waiting cargo */
 
				if (num_waiting_cargo == 0 && include_empty) {
 
					station_sort[n++] = st;
 
					*sl->Append() = st;
 
				}
 
			}
 
		}
 
	}
 

	
 
	free((void*)sl->sort_list);
 
	sl->sort_list = MallocT<const Station*>(n);
 
	sl->list_length = n;
 

	
 
	for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i];
 
	sl->Compact();
 

	
 
	sl->flags &= ~VL_REBUILD;
 
	sl->flags |= VL_RESORT;
 
	free((void*)station_sort);
 
}
 

	
 

	
 
/**
 
 * Sort station list if the VL_RESORT flag is set
 
 *
 
@@ -236,13 +228,13 @@ static void SortStationsList(GUIStationL
 
	};
 

	
 
	if (!(sl->flags & VL_RESORT)) return;
 

	
 
	_internal_sort_order = sl->flags & VL_DESC;
 
	_last_station = NULL; // used for "cache" in namesorting
 
	qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]);
 
	qsort((void*)sl->Begin(), sl->Length(), sizeof(sl->Begin()), _station_sorter[sl->sort_type]);
 

	
 
	sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 
	sl->flags &= ~VL_RESORT;
 
}
 

	
 
/**
 
@@ -308,13 +300,12 @@ struct PlayerStationsWindow : public Win
 
			if (HasBit(facilities, i)) this->LowerWidget(i + SLW_TRAIN);
 
		}
 
		this->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
 
		this->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
 
		this->SetWidgetLoweredState(SLW_NOCARGOWAITING, include_empty);
 

	
 
		this->sort_list = NULL;
 
		this->flags = VL_REBUILD;
 
		this->sort_type = station_sort.criteria;
 
		if (station_sort.order) this->flags |= VL_DESC;
 

	
 
		/* set up resort timer */
 
		this->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 
@@ -326,13 +317,13 @@ struct PlayerStationsWindow : public Win
 
	{
 
		PlayerID owner = (PlayerID)this->window_number;
 

	
 
		BuildStationsList(this, owner, facilities, _cargo_filter, include_empty);
 
		SortStationsList(this);
 

	
 
		SetVScrollCount(this, this->list_length);
 
		SetVScrollCount(this, this->Length());
 

	
 
		/* draw widgets, with player's name in the caption */
 
		SetDParam(0, owner);
 
		SetDParam(1, this->vscroll.count);
 

	
 
		/* Set text of sort by dropdown */
 
@@ -372,17 +363,17 @@ struct PlayerStationsWindow : public Win
 

	
 
		if (this->vscroll.count == 0) { // player has no stations
 
			DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING);
 
			return;
 
		}
 

	
 
		int max = min(this->vscroll.pos + this->vscroll.cap, this->list_length);
 
		int max = min(this->vscroll.pos + this->vscroll.cap, this->Length());
 
		y = 40; // start of the list-widget
 

	
 
		for (int i = this->vscroll.pos; i < max; ++i) { // do until max number of stations of owner
 
			const Station *st = this->sort_list[i];
 
			const Station *st = *this->Get(i);
 
			int x;
 

	
 
			assert(st->xy != 0);
 

	
 
			/* Do not do the complex check HasStationInUse here, it may be even false
 
				* when the order had been removed and the station list hasn't been removed yet */
 
@@ -410,15 +401,15 @@ struct PlayerStationsWindow : public Win
 
				uint32 id_v = (pt.y - 41) / 10;
 

	
 
				if (id_v >= this->vscroll.cap) return; // click out of bounds
 

	
 
				id_v += this->vscroll.pos;
 

	
 
				if (id_v >= this->list_length) return; // click out of list bound
 
				if (id_v >= this->Length()) return; // click out of list bound
 

	
 
				const Station *st = this->sort_list[id_v];
 
				const Station *st = *this->Get(id_v);
 
				/* do not check HasStationInUse - it is slow and may be invalid */
 
				assert(st->owner == (PlayerID)this->window_number || (st->owner == OWNER_NONE && !st->IsBuoy()));
 

	
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(st->xy);
 
				} else {
src/vehicle.cpp
Show inline comments
 
@@ -1332,41 +1332,12 @@ void BuildDepotVehicleList(VehicleType t
 
	 * (i.e. built within a command) then this will actually do nothing. */
 
	engines->Compact();
 
	if (wagons != NULL && wagons != engines) wagons->Compact();
 
}
 

	
 
/**
 
 * @param sort_list list to store the list in. Either NULL or the length length_of_array tells
 
 * @param length_of_array informs the length allocated for sort_list. This is not the same as the number of vehicles in the list. Needs to be 0 when sort_list is NULL
 
 * @param type type of vehicle
 
 * @param owner PlayerID of owner to generate a list for
 
 * @param index This parameter has different meanings depending on window_type
 
 *    <ul>
 
 *      <li>VLW_STATION_LIST:  index of station to generate a list for</li>
 
 *      <li>VLW_SHARED_ORDERS: index of order to generate a list for<li>
 
 *      <li>VLW_STANDARD: not used<li>
 
 *      <li>VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for</li>
 
 *      <li>VLW_GROUP_LIST: index of group to generate a 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, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
 
{
 
	VehicleList list;
 
	GenerateVehicleSortList(&list, type, owner, index, window_type);
 

	
 
	if (list.Length() > 0) {
 
		*sort_list = ReallocT(*sort_list, list.Length());
 
		memcpy(*sort_list, list.Begin(), sizeof(list.Begin()) * list.Length());
 
	}
 

	
 
	return list.Length();
 
}
 

	
 
/**
 
 * Generate a list of vehicles based on window type.
 
 * @param list        Pointer to list to add vehicles to
 
 * @param type        Type of vehicle
 
 * @param owner       Player to generate list for
 
 * @param index       This parameter has different meanings depending on window_type
 
 *    <ul>
src/vehicle_func.h
Show inline comments
 
@@ -65,14 +65,12 @@ void MarkSingleVehicleDirty(const Vehicl
 
UnitID GetFreeUnitNumber(VehicleType type);
 

	
 
void TrainConsistChanged(Vehicle *v);
 
void TrainPowerChanged(Vehicle *v);
 
Money GetTrainRunningCost(const Vehicle *v);
 

	
 
/* Old style list kept for migration */
 
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
 
void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
 
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list);
 
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
 
void VehicleEnterDepot(Vehicle *v);
 

	
 
CommandCost MaybeReplaceVehicle(Vehicle *v, uint32 flags, bool display_costs);
src/vehicle_gui.cpp
Show inline comments
 
@@ -89,13 +89,13 @@ const StringID _vehicle_sort_listing[] =
 
void BuildVehicleList(VehicleListBase *vl, PlayerID owner, uint16 index, uint16 window_type)
 
{
 
	if (!(vl->vehicles.flags & VL_REBUILD)) return;
 

	
 
	DEBUG(misc, 3, "Building vehicle list for player %d at station %d", owner, index);
 

	
 
	vl->vehicles.list_length = GenerateVehicleSortList(&vl->vehicles.sort_list, &vl->vehicles.list_length, vl->vehicle_type, owner, index, window_type);
 
	GenerateVehicleSortList(&vl->vehicles, vl->vehicle_type, owner, index, window_type);
 

	
 
	vl->vehicles.flags &= ~VL_REBUILD;
 
	vl->vehicles.flags |= VL_RESORT;
 
}
 

	
 
/* cached values for VehicleNameSorter to spare many GetString() calls */
 
@@ -107,13 +107,13 @@ void SortVehicleList(VehicleListBase *vl
 
	if (!(vl->vehicles.flags & VL_RESORT)) return;
 

	
 
	/* invalidate cached values for name sorter - vehicle names could change */
 
	_last_vehicle[0] = _last_vehicle[1] = NULL;
 

	
 
	_internal_sort_order = (vl->vehicles.flags & VL_DESC) != 0;
 
	qsort((void*)vl->vehicles.sort_list, vl->vehicles.list_length, sizeof(vl->vehicles.sort_list[0]),
 
	qsort((void*)vl->vehicles.Begin(), vl->vehicles.Length(), sizeof(vl->vehicles.Begin()),
 
		_vehicle_sorter[vl->vehicles.sort_type]);
 

	
 
	vl->vehicles.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
 
	vl->vehicles.flags &= ~VL_RESORT;
 
}
 

	
 
@@ -803,14 +803,13 @@ struct VehicleListWindow : public Window
 
	VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		uint16 window_type = this->window_number & VLW_MASK;
 
		PlayerID player = (PlayerID)GB(this->window_number, 0, 8);
 

	
 
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
 
		this->vehicles.list_length = 0;
 
		this->vehicles.sort_list = NULL;
 
		this->vehicles.Clear();
 
		this->caption_color = player;
 

	
 
		/* Hide the widgets that we will not use in this window
 
		* Some windows contains actions only fit for the owner */
 
		if (player == _local_player) {
 
			this->HideWidget(VLW_WIDGET_OTHER_PLAYER_FILLER);
 
@@ -922,13 +921,12 @@ struct VehicleListWindow : public Window
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	~VehicleListWindow()
 
	{
 
		free((void*)this->vehicles.sort_list);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		int x = 2;
 
		int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
 
@@ -937,18 +935,18 @@ struct VehicleListWindow : public Window
 
		const PlayerID owner = (PlayerID)this->caption_color;
 
		const uint16 window_type = this->window_number & VLW_MASK;
 
		const uint16 index = GB(this->window_number, 16, 16);
 

	
 
		BuildVehicleList(this, owner, index, window_type);
 
		SortVehicleList(this);
 
		SetVScrollCount(this, this->vehicles.list_length);
 
		SetVScrollCount(this, this->vehicles.Length());
 

	
 
		/* draw the widgets */
 
		switch (window_type) {
 
			case VLW_SHARED_ORDERS: /* Shared Orders */
 
				if (this->vehicles.list_length == 0) {
 
				if (this->vehicles.Length() == 0) {
 
					/* We can't open this window without vehicles using this order
 
					* and we should close the window when deleting the order      */
 
					NOT_REACHED();
 
				}
 
				SetDParam(0, this->vscroll.count);
 
				break;
 
@@ -978,28 +976,28 @@ struct VehicleListWindow : public Window
 
				}
 
				SetDParam(2, this->vscroll.count);
 
				break;
 
			default: NOT_REACHED(); break;
 
		}
 

	
 
		this->SetWidgetsDisabledState(this->vehicles.list_length == 0,
 
		this->SetWidgetsDisabledState(this->vehicles.Length() == 0,
 
			VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
 
			VLW_WIDGET_STOP_ALL,
 
			VLW_WIDGET_START_ALL,
 
			WIDGET_LIST_END);
 

	
 
		this->DrawWidgets();
 

	
 
		/* draw sorting criteria string */
 
		DrawString(85, 15, _vehicle_sort_listing[this->vehicles.sort_type], TC_BLACK);
 
		/* draw arrow pointing up/down for ascending/descending sorting */
 
		this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.flags & VL_DESC ? SBS_DOWN : SBS_UP);
 

	
 
		max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.list_length);
 
		max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.Length());
 
		for (i = this->vscroll.pos; i < max; ++i) {
 
			const Vehicle *v = this->vehicles.sort_list[i];
 
			const Vehicle *v = this->vehicles[i];
 
			StringID str;
 

	
 
			SetDParam(0, v->GetDisplayProfitThisYear());
 
			SetDParam(1, v->GetDisplayProfitLastYear());
 

	
 
			DrawVehicleImage(v, x + 19, y + 6, INVALID_VEHICLE, this->widget[VLW_WIDGET_LIST].right - this->widget[VLW_WIDGET_LIST].left - 20, 0);
 
@@ -1046,15 +1044,15 @@ struct VehicleListWindow : public Window
 
				const Vehicle *v;
 

	
 
				if (id_v >= this->vscroll.cap) return; // click out of bounds
 

	
 
				id_v += this->vscroll.pos;
 

	
 
				if (id_v >= this->vehicles.list_length) return; // click out of list bound
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 

	
 
				v = this->vehicles.sort_list[id_v];
 
				v = this->vehicles[id_v];
 

	
 
				ShowVehicleViewWindow(v);
 
			} break;
 

	
 
			case VLW_WIDGET_AVAILABLE_VEHICLES:
 
				ShowBuildVehicleWindow(0, this->vehicle_type);
 
@@ -1097,13 +1095,13 @@ struct VehicleListWindow : public Window
 
					this->vehicles.flags |= VL_RESORT;
 
					this->vehicles.sort_type = index;
 
					this->sorting->criteria = this->vehicles.sort_type;
 
				}
 
				break;
 
			case VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN:
 
				assert(this->vehicles.list_length != 0);
 
				assert(this->vehicles.Length() != 0);
 

	
 
				switch (index) {
 
					case 0: /* Replace window */
 
						ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type);
 
						break;
 
					case 1: /* Send for servicing */
0 comments (0 inline, 0 general)