Changeset - r23520:20bbc807b0eb
[Not reviewed]
master
! ! !
Henry Wilson - 6 years ago 2018-09-23 11:23:54
m3henry@googlemail.com
Codechange: Replace SmallVector::Length() with std::vector::size()
71 files changed with 287 insertions and 297 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -157,14 +157,14 @@ class ReplaceVehicleWindow : public Wind
 
	{
 
		EngineID e = this->sel_engine[0];
 

	
 
		if (this->engines[0].NeedRebuild()) {
 
			/* We need to rebuild the left engines list */
 
			this->GenerateReplaceVehList(true);
 
			this->vscroll[0]->SetCount(this->engines[0].Length());
 
			if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].Length() != 0) {
 
			this->vscroll[0]->SetCount(this->engines[0].size());
 
			if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
 
				this->sel_engine[0] = this->engines[0][0];
 
			}
 
		}
 

	
 
		if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
 
			/* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
 
@@ -177,13 +177,13 @@ class ReplaceVehicleWindow : public Wind
 
					/* Select the current replacement for sel_engine[0]. */
 
					const Company *c = Company::Get(_local_company);
 
					this->sel_engine[1] = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group);
 
				}
 
				/* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
 
				this->GenerateReplaceVehList(false);
 
				this->vscroll[1]->SetCount(this->engines[1].Length());
 
				this->vscroll[1]->SetCount(this->engines[1].size());
 
				if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
 
					int position = 0;
 
					for (EngineID *it = this->engines[1].Begin(); it != this->engines[1].End(); ++it) {
 
						if (*it == this->sel_engine[1]) break;
 
						++position;
 
					}
 
@@ -381,13 +381,13 @@ public:
 
			}
 

	
 
			case WID_RV_LEFT_MATRIX:
 
			case WID_RV_RIGHT_MATRIX: {
 
				int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
 
				EngineID start  = this->vscroll[side]->GetPosition(); // what is the offset for the start (scrolling)
 
				EngineID end    = min(this->vscroll[side]->GetCapacity() + start, this->engines[side].Length());
 
				EngineID end    = min(this->vscroll[side]->GetCapacity() + start, this->engines[side].size());
 

	
 
				/* Do the actual drawing */
 
				DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
 
						&this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
 
				break;
 
			}
 
@@ -505,13 +505,13 @@ public:
 
				if (widget == WID_RV_LEFT_MATRIX) {
 
					click_side = 0;
 
				} else {
 
					click_side = 1;
 
				}
 
				uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
 
				size_t engine_count = this->engines[click_side].Length();
 
				size_t engine_count = this->engines[click_side].size();
 

	
 
				EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
 
				if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
 
				this->sel_engine[click_side] = e;
 
				if (click_side == 0) {
 
					this->engines[1].ForceRebuild();
src/bridge_gui.cpp
Show inline comments
 
@@ -150,13 +150,13 @@ public:
 
		this->parent = FindWindowById(WC_BUILD_TOOLBAR, GB(this->type, 15, 2));
 
		this->bridges->SetListing(this->last_sorting);
 
		this->bridges->SetSortFuncs(this->sorter_funcs);
 
		this->bridges->NeedResort();
 
		this->SortBridgeList();
 

	
 
		this->vscroll->SetCount(bl->Length());
 
		this->vscroll->SetCount(bl->size());
 
	}
 

	
 
	~BuildBridgeWindow()
 
	{
 
		this->last_sorting = this->bridges->GetListing();
 

	
 
@@ -183,13 +183,13 @@ public:
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
			case WID_BBS_BRIDGE_LIST: {
 
				Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
 
				Dimension text_dim   = {0, 0}; // Biggest text dimension
 
				for (int i = 0; i < (int)this->bridges->Length(); i++) {
 
				for (int i = 0; i < (int)this->bridges->size(); i++) {
 
					const BridgeSpec *b = this->bridges->Get(i)->spec;
 
					sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
 

	
 
					SetDParam(2, this->bridges->Get(i)->cost);
 
					SetDParam(1, b->speed);
 
					SetDParam(0, b->material);
 
@@ -223,13 +223,13 @@ public:
 
			case WID_BBS_DROPDOWN_ORDER:
 
				this->DrawSortButtonState(widget, this->bridges->IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
			case WID_BBS_BRIDGE_LIST: {
 
				uint y = r.top;
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->Length(); i++) {
 
				for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
 
					const BridgeSpec *b = this->bridges->Get(i)->spec;
 

	
 
					SetDParam(2, this->bridges->Get(i)->cost);
 
					SetDParam(1, b->speed);
 
					SetDParam(0, b->material);
 

	
 
@@ -243,13 +243,13 @@ public:
 
		}
 
	}
 

	
 
	EventState OnKeyPress(WChar key, uint16 keycode) override
 
	{
 
		const uint8 i = keycode - '1';
 
		if (i < 9 && i < this->bridges->Length()) {
 
		if (i < 9 && i < this->bridges->size()) {
 
			/* Build the requested bridge */
 
			this->BuildBridge(i);
 
			delete this;
 
			return ES_HANDLED;
 
		}
 
		return ES_NOT_HANDLED;
 
@@ -258,13 +258,13 @@ public:
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			default: break;
 
			case WID_BBS_BRIDGE_LIST: {
 
				uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BBS_BRIDGE_LIST);
 
				if (i < this->bridges->Length()) {
 
				if (i < this->bridges->size()) {
 
					this->BuildBridge(i);
 
					delete this;
 
				}
 
				break;
 
			}
 

	
 
@@ -423,13 +423,13 @@ void ShowBuildBridgeWindow(TileIndex sta
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8) + infra_cost;
 
			}
 
		}
 
	}
 

	
 
	if (bl != NULL && bl->Length() != 0) {
 
	if (bl != NULL && bl->size() != 0) {
 
		new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
 
	} else {
 
		delete bl;
 
		ShowErrorMessage(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, errmsg, WL_INFO, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
 
	}
 
}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -937,13 +937,13 @@ int DrawVehiclePurchaseInfo(int left, in
 
 */
 
void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
 
{
 
	static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
 

	
 
	/* Obligatory sanity checks! */
 
	assert(max <= eng_list->Length());
 
	assert(max <= eng_list->size());
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int step_size = GetEngineListHeight(type);
 
	int sprite_left  = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_left;
 
	int sprite_right = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_right;
 
	int sprite_width = sprite_left + sprite_right;
 
@@ -1107,13 +1107,13 @@ struct BuildVehicleWindow : Window {
 

	
 
		this->owner = (tile != INVALID_TILE) ? GetTileOwner(tile) : _local_company;
 

	
 
		this->eng_list.ForceRebuild();
 
		this->GenerateBuildList(); // generate the list, since we need it in the next line
 
		/* Select the first engine in the list as default when opening the window */
 
		if (this->eng_list.Length() > 0) {
 
		if (this->eng_list.size() > 0) {
 
			this->SelectEngine(this->eng_list[0]);
 
		} else {
 
			this->SelectEngine(INVALID_ENGINE);
 
		}
 
	}
 

	
 
@@ -1202,13 +1202,13 @@ struct BuildVehicleWindow : Window {
 
	}
 

	
 
	/** Filter the engine list against the currently selected cargo filter */
 
	void FilterEngineList()
 
	{
 
		this->eng_list.Filter(this->cargo_filter[this->cargo_filter_criteria]);
 
		if (0 == this->eng_list.Length()) { // no engine passed through the filter, invalidate the previously selected engine
 
		if (0 == this->eng_list.size()) { // no engine passed through the filter, invalidate the previously selected engine
 
			this->SelectEngine(INVALID_ENGINE);
 
		} else if (!this->eng_list.Contains(this->sel_engine)) { // previously selected engine didn't pass the filter, select the first engine of the list
 
			this->SelectEngine(this->eng_list[0]);
 
		}
 
	}
 

	
 
@@ -1385,13 +1385,13 @@ struct BuildVehicleWindow : Window {
 
				this->SetWidgetLoweredState(widget, this->show_hidden_engines);
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_BV_LIST: {
 
				uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BV_LIST);
 
				size_t num_items = this->eng_list.Length();
 
				size_t num_items = this->eng_list.size();
 
				this->SelectEngine((i < num_items) ? this->eng_list[i] : INVALID_ENGINE);
 
				this->SetDirty();
 
				if (_ctrl_pressed) {
 
					this->OnClick(pt, WID_BV_SHOW_HIDE, 1);
 
				} else if (click_count > 1 && !this->listview_mode) {
 
					this->OnClick(pt, WID_BV_BUILD, 1);
 
@@ -1526,25 +1526,25 @@ struct BuildVehicleWindow : Window {
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_BV_LIST:
 
				DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.Length()), this->sel_engine, false, DEFAULT_GROUP);
 
				DrawEngineList(this->vehicle_type, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(), min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size()), this->sel_engine, false, DEFAULT_GROUP);
 
				break;
 

	
 
			case WID_BV_SORT_ASCENDING_DESCENDING:
 
				this->DrawSortButtonState(WID_BV_SORT_ASCENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
 
				break;
 
		}
 
	}
 

	
 
	void OnPaint() override
 
	{
 
		this->GenerateBuildList();
 
		this->vscroll->SetCount(this->eng_list.Length());
 
		this->vscroll->SetCount(this->eng_list.size());
 

	
 
		this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
 

	
 
		this->DrawWidgets();
 

	
 
		if (!this->IsShaded()) {
src/company_gui.cpp
Show inline comments
 
@@ -683,13 +683,13 @@ private:
 
			for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
 
				if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) {
 
					this->rows++;
 
				}
 
			}
 
		} else {
 
			this->rows = this->groups.Length();
 
			this->rows = this->groups.size();
 
		}
 

	
 
		this->vscroll->SetCount(this->rows);
 
	}
 

	
 
public:
 
@@ -899,13 +899,13 @@ public:
 
				if (_livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme)) {
 
					if (pos-- > 0) continue;
 
					draw_livery(STR_LIVERY_DEFAULT + scheme, c->livery[scheme], HasBit(this->sel, scheme), scheme == LS_DEFAULT, 0);
 
				}
 
			}
 
		} else {
 
			uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.Length());
 
			uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size());
 
			for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
				const Group *g = this->groups[i];
 
				SetDParam(0, g->index);
 
				draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, this->indents[i] * LEVEL_WIDTH);
 
			}
 
		}
 
@@ -939,13 +939,13 @@ public:
 
					}
 
				} else {
 
					this->sel = INVALID_GROUP;
 
					this->groups.ForceRebuild();
 
					this->BuildGroupList((CompanyID)this->window_number);
 

	
 
					if (this->groups.Length() > 0) {
 
					if (this->groups.size() > 0) {
 
						this->sel = this->groups[0]->index;
 
					}
 
				}
 

	
 
				this->SetRows();
 
				this->SetDirty();
 
@@ -1026,13 +1026,13 @@ public:
 
				this->groups.ForceRebuild();
 
				this->BuildGroupList((CompanyID)this->window_number);
 
				this->SetRows();
 

	
 
				if (!Group::IsValidID(this->sel)) {
 
					this->sel = INVALID_GROUP;
 
					if (this->groups.Length() > 0) this->sel = this->groups[0]->index;
 
					if (this->groups.size() > 0) this->sel = this->groups[0]->index;
 
				}
 

	
 
				this->SetDirty();
 
			}
 
			return;
 
		}
src/console_cmds.cpp
Show inline comments
 
@@ -549,22 +549,22 @@ DEF_CONSOLE_CMD(ConUnBan)
 
	}
 

	
 
	if (argc != 2) return false;
 

	
 
	/* Try by IP. */
 
	uint index;
 
	for (index = 0; index < _network_ban_list.Length(); index++) {
 
	for (index = 0; index < _network_ban_list.size(); index++) {
 
		if (strcmp(_network_ban_list[index], argv[1]) == 0) break;
 
	}
 

	
 
	/* Try by index. */
 
	if (index >= _network_ban_list.Length()) {
 
	if (index >= _network_ban_list.size()) {
 
		index = atoi(argv[1]) - 1U; // let it wrap
 
	}
 

	
 
	if (index < _network_ban_list.Length()) {
 
	if (index < _network_ban_list.size()) {
 
		char msg[64];
 
		seprintf(msg, lastof(msg), "Unbanned %s", _network_ban_list[index]);
 
		IConsolePrint(CC_DEFAULT, msg);
 
		free(_network_ban_list[index]);
 
		_network_ban_list.Erase(_network_ban_list.Get(index));
 
	} else {
src/core/pool_func.cpp
Show inline comments
 
@@ -19,13 +19,13 @@
 
 * deletes the vector itself if this was the last item removed.
 
 */
 
/* virtual */ PoolBase::~PoolBase()
 
{
 
	PoolVector *pools = PoolBase::GetPools();
 
	pools->Erase(pools->Find(this));
 
	if (pools->Length() == 0) delete pools;
 
	if (pools->size() == 0) delete pools;
 
}
 

	
 
/**
 
 * Clean all pools of given type.
 
 * @param pt pool types to clean.
 
 */
src/core/smallstack_type.hpp
Show inline comments
 
@@ -70,13 +70,13 @@ private:
 
	{
 
		Tindex index = this->first_free;
 
		for (; index < this->first_unused; index++) {
 
			if (!this->data[index].valid) return index;
 
		}
 

	
 
		if (index >= this->data.Length() && index < Tmax_size) {
 
		if (index >= this->data.size() && index < Tmax_size) {
 
			this->data.Resize(index + 1);
 
		}
 
		return index;
 
	}
 

	
 
	struct SimplePoolPoolItem : public Titem {
src/core/smallvec_type.hpp
Show inline comments
 
@@ -215,22 +215,12 @@ public:
 
		bool is_member = this->Contains(item);
 
		if (!is_member) *this->Append() = item;
 
		return is_member;
 
	}
 

	
 
	/**
 
	 * Get the number of items in the list.
 
	 *
 
	 * @return The number of items in the list.
 
	 */
 
	inline uint Length() const
 
	{
 
		return std::vector<T>::size();
 
	}
 

	
 
	/**
 
	 * Get the pointer to the first item (const)
 
	 *
 
	 * @return the pointer to the first item
 
	 */
 
	inline const T *Begin() const
 
	{
src/depot_gui.cpp
Show inline comments
 
@@ -395,13 +395,13 @@ struct DepotWindow : Window {
 
			}
 
		}
 

	
 
		uint16 rows_in_display = wid->current_y / wid->resize_y;
 

	
 
		uint16 num = this->vscroll->GetPosition() * this->num_columns;
 
		int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * this->num_columns));
 
		int maxval = min(this->vehicle_list.size(), num + (rows_in_display * this->num_columns));
 
		int y;
 
		for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
 
			for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
 
				/* Draw all vehicles in the current row */
 
				const Vehicle *v = this->vehicle_list[num];
 
				if (this->num_columns == 1) {
 
@@ -410,17 +410,17 @@ struct DepotWindow : Window {
 
					int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->resize.step_width;
 
					this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1, y);
 
				}
 
			}
 
		}
 

	
 
		maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
 
		maxval = min(this->vehicle_list.size() + this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
 

	
 
		/* Draw the train wagons without an engine in front. */
 
		for (; num < maxval; num++, y += this->resize.step_height) {
 
			const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
 
			const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
 
			this->DrawVehicleInDepot(v, r.left, r.right, y);
 
		}
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
@@ -462,31 +462,31 @@ struct DepotWindow : Window {
 

	
 
		uint row = y / this->resize.step_height;
 
		if (row >= this->vscroll->GetCapacity()) return MODE_ERROR;
 

	
 
		uint pos = ((row + this->vscroll->GetPosition()) * this->num_columns) + xt;
 

	
 
		if (this->vehicle_list.Length() + this->wagon_list.Length() <= pos) {
 
		if (this->vehicle_list.size() + this->wagon_list.size() <= pos) {
 
			/* Clicking on 'line' / 'block' without a vehicle */
 
			if (this->type == VEH_TRAIN) {
 
				/* End the dragging */
 
				d->head  = NULL;
 
				d->wagon = NULL;
 
				return MODE_DRAG_VEHICLE;
 
			} else {
 
				return MODE_ERROR; // empty block, so no vehicle is selected
 
			}
 
		}
 

	
 
		bool wagon = false;
 
		if (this->vehicle_list.Length() > pos) {
 
		if (this->vehicle_list.size() > pos) {
 
			*veh = this->vehicle_list[pos];
 
			/* Skip vehicles that are scrolled off the list */
 
			if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
 
		} else {
 
			pos -= this->vehicle_list.Length();
 
			pos -= this->vehicle_list.size();
 
			*veh = this->wagon_list[pos];
 
			/* free wagons don't have an initial loco. */
 
			x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			wagon = true;
 
		}
 

	
 
@@ -723,25 +723,25 @@ struct DepotWindow : Window {
 
			}
 
		}
 

	
 
		/* determine amount of items for scroller */
 
		if (this->type == VEH_TRAIN) {
 
			uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			for (uint num = 0; num < this->vehicle_list.Length(); num++) {
 
			for (uint num = 0; num < this->vehicle_list.size(); num++) {
 
				uint width = 0;
 
				for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
 
					width += v->GetDisplayImageWidth();
 
				}
 
				max_width = max(max_width, width);
 
			}
 
			/* Always have 1 empty row, so people can change the setting of the train */
 
			this->vscroll->SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
 
			this->vscroll->SetCount(this->vehicle_list.size() + this->wagon_list.size() + 1);
 
			/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
 
			this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
 
		} else {
 
			this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->num_columns));
 
			this->vscroll->SetCount(CeilDiv(this->vehicle_list.size(), this->num_columns));
 
		}
 

	
 
		/* Setup disabled buttons. */
 
		TileIndex tile = this->window_number;
 
		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
 
			WID_D_STOP_ALL,
 
@@ -808,13 +808,13 @@ struct DepotWindow : Window {
 
				DoCommandP(this->window_number, (widget == WID_D_START_ALL ? (1 << 0) : 0), vli.Pack(), CMD_MASS_START_STOP);
 
				break;
 
			}
 

	
 
			case WID_D_SELL_ALL:
 
				/* Only open the confirmation window if there are anything to sell */
 
				if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
 
				if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) {
 
					TileIndex tile = this->window_number;
 
					byte vehtype = this->type;
 

	
 
					SetDParam(0, vehtype);
 
					SetDParam(1, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile));
 
					ShowQuery(
src/engine.cpp
Show inline comments
 
@@ -544,13 +544,13 @@ bool EngineOverrideManager::ResetToCurre
 
 */
 
void SetupEngines()
 
{
 
	DeleteWindowByClass(WC_ENGINE_PREVIEW);
 
	_engine_pool.CleanPool();
 

	
 
	assert(_engine_mngr.Length() >= _engine_mngr.NUM_DEFAULT_ENGINES);
 
	assert(_engine_mngr.size() >= _engine_mngr.NUM_DEFAULT_ENGINES);
 
	const EngineIDMapping *end = _engine_mngr.End();
 
	uint index = 0;
 
	for (const EngineIDMapping *eid = _engine_mngr.Begin(); eid != end; eid++, index++) {
 
		/* Assert is safe; there won't be more than 256 original vehicles
 
		 * in any case, and we just cleaned the pool. */
 
		assert(Engine::CanAllocateItem());
src/engine_gui.cpp
Show inline comments
 
@@ -322,13 +322,13 @@ void DrawVehicleEngine(int left, int rig
 
 * Sort all items using quick sort and given 'CompareItems' function
 
 * @param el list to be sorted
 
 * @param compare function for evaluation of the quicksort
 
 */
 
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
 
{
 
	uint size = el->Length();
 
	uint size = el->size();
 
	/* out-of-bounds access at the next line for size == 0 (even with operator[] at some systems)
 
	 * generally, do not sort if there are less than 2 items */
 
	if (size < 2) return;
 
	QSortT(el->Begin(), size, compare);
 
}
 

	
 
@@ -339,11 +339,11 @@ void EngList_Sort(GUIEngineList *el, Eng
 
 * @param begin start of sorting
 
 * @param num_items count of items to be sorted
 
 */
 
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
 
{
 
	if (num_items < 2) return;
 
	assert(begin < el->Length());
 
	assert(begin + num_items <= el->Length());
 
	assert(begin < el->size());
 
	assert(begin + num_items <= el->size());
 
	QSortT(el->Get(begin), num_items, compare);
 
}
 

	
src/fios.cpp
Show inline comments
 
@@ -377,13 +377,13 @@ static void FiosGetFileList(SaveLoadOper
 
	}
 

	
 
	/* Sort the subdirs always by name, ascending, remember user-sorting order */
 
	{
 
		SortingBits order = _savegame_sort_order;
 
		_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
 
		QSortT(file_list.files.Begin(), file_list.files.Length(), CompareFiosItems);
 
		QSortT(file_list.files.Begin(), file_list.files.size(), CompareFiosItems);
 
		_savegame_sort_order = order;
 
	}
 

	
 
	/* This is where to start sorting for the filenames */
 
	sort_start = file_list.Length();
 

	
src/fios.h
Show inline comments
 
@@ -126,13 +126,13 @@ public:
 
	/**
 
	 * Get the number of files in the list.
 
	 * @return The number of files stored in the list.
 
	 */
 
	inline uint Length() const
 
	{
 
		return this->files.Length();
 
		return this->files.size();
 
	}
 

	
 
	/**
 
	 * Get a pointer to the first file information.
 
	 * @return Address of the first file information.
 
	 */
src/game/game_text.cpp
Show inline comments
 
@@ -209,13 +209,13 @@ struct StringNameWriter : HeaderWriter {
 
	StringNameWriter(StringList *strings) : strings(strings)
 
	{
 
	}
 

	
 
	void WriteStringID(const char *name, int stringid)
 
	{
 
		if (stringid == (int)this->strings->Length()) *this->strings->Append() = stredup(name);
 
		if (stringid == (int)this->strings->size()) *this->strings->Append() = stredup(name);
 
	}
 

	
 
	void Finalise(const StringData &data)
 
	{
 
		/* Nothing to do. */
 
	}
 
@@ -337,13 +337,13 @@ GameStrings *_current_data = NULL;
 
 * Get the string pointer of a particular game string.
 
 * @param id The ID of the game string.
 
 * @return The encoded string.
 
 */
 
const char *GetGameStringPtr(uint id)
 
{
 
	if (id >= _current_data->cur_language->lines.Length()) return GetStringPtr(STR_UNDEFINED);
 
	if (id >= _current_data->cur_language->lines.size()) return GetStringPtr(STR_UNDEFINED);
 
	return _current_data->cur_language->lines[id];
 
}
 

	
 
/**
 
 * Register the current translation to the Squirrel engine.
 
 * @param engine The engine to update/
src/gfx.cpp
Show inline comments
 
@@ -506,13 +506,13 @@ int DrawString(int left, int right, int 
 
	if (_cur_dpi->top + _cur_dpi->height + extra < top || _cur_dpi->top > top + max_height + extra ||
 
			_cur_dpi->left + _cur_dpi->width + extra < left || _cur_dpi->left > right + extra) {
 
		return 0;
 
	}
 

	
 
	Layouter layout(str, INT32_MAX, colour, fontsize);
 
	if (layout.Length() == 0) return 0;
 
	if (layout.size() == 0) return 0;
 

	
 
	return DrawLayoutLine(*layout.Begin(), top, left, right, align, underline, true);
 
}
 

	
 
/**
 
 * Draw string, possibly truncated to make it fit in its allocated space
 
@@ -571,13 +571,13 @@ int GetStringHeight(StringID str, int ma
 
int GetStringLineCount(StringID str, int maxw)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	GetString(buffer, str, lastof(buffer));
 

	
 
	Layouter layout(buffer, maxw);
 
	return layout.Length();
 
	return layout.size();
 
}
 

	
 
/**
 
 * Calculate string bounding box for multi-line strings.
 
 * @param str        String to check.
 
 * @param suggestion Suggested bounding box.
src/gfx_layout.cpp
Show inline comments
 
@@ -197,13 +197,13 @@ public:
 
			buff[0] = ' ';
 
			length = 1;
 
			fontMapping.End()[-1].first++;
 
		}
 

	
 
		/* Fill ICU's FontRuns with the right data. */
 
		icu::FontRuns runs(fontMapping.Length());
 
		icu::FontRuns runs(fontMapping.size());
 
		for (FontMap::iterator iter = fontMapping.Begin(); iter != fontMapping.End(); iter++) {
 
			runs.add(iter->second, iter->first);
 
		}
 

	
 
		LEErrorCode status = LE_NO_ERROR;
 
		/* ParagraphLayout does not copy "buff", so it must stay valid.
 
@@ -429,13 +429,13 @@ int FallbackParagraphLayout::FallbackLin
 
/**
 
 * Get the width of this line.
 
 * @return The width of the line.
 
 */
 
int FallbackParagraphLayout::FallbackLine::GetWidth() const
 
{
 
	if (this->Length() == 0) return 0;
 
	if (this->size() == 0) return 0;
 

	
 
	/*
 
	 * The last X position of a run contains is the end of that run.
 
	 * Since there is no left-to-right support, taking this value of
 
	 * the last run gives us the end of the line and thus the width.
 
	 */
 
@@ -446,13 +446,13 @@ int FallbackParagraphLayout::FallbackLin
 
/**
 
 * Get the number of runs in this line.
 
 * @return The number of runs.
 
 */
 
int FallbackParagraphLayout::FallbackLine::CountRuns() const
 
{
 
	return this->Length();
 
	return this->size();
 
}
 

	
 
/**
 
 * Get a specific visual run.
 
 * @return The visual run.
 
 */
 
@@ -569,13 +569,13 @@ const ParagraphLayouter::Line *FallbackP
 
			}
 
		}
 

	
 
		this->buffer++;
 
	}
 

	
 
	if (l->Length() == 0 || last_char - begin != 0) {
 
	if (l->size() == 0 || last_char - begin != 0) {
 
		int w = l->GetWidth();
 
		*l->Append() = new FallbackVisualRun(iter->second, begin, last_char - begin, w);
 
	}
 
	return l;
 
}
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -1180,13 +1180,13 @@ public:
 
		uint ordinal_left  = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT;
 
		uint ordinal_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->ordinal_width;
 
		uint icon_left     = r.left + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + (rtl ? this->text_width : this->ordinal_width);
 
		uint text_left     = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width;
 
		uint text_right    = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT;
 

	
 
		for (uint i = 0; i != this->companies.Length(); i++) {
 
		for (uint i = 0; i != this->companies.size(); i++) {
 
			const Company *c = this->companies[i];
 
			DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
 

	
 
			DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
 

	
 
			SetDParam(0, c->index);
src/group_gui.cpp
Show inline comments
 
@@ -457,14 +457,14 @@ public:
 
			case WID_GL_CAPTION:
 
				/* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
 
				 * We list all vehicles or ungrouped vehicles */
 
				if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
 
					SetDParam(0, STR_COMPANY_NAME);
 
					SetDParam(1, this->vli.company);
 
					SetDParam(2, this->vehicles.Length());
 
					SetDParam(3, this->vehicles.Length());
 
					SetDParam(2, this->vehicles.size());
 
					SetDParam(3, this->vehicles.size());
 
				} else {
 
					const Group *g = Group::Get(this->vli.index);
 

	
 
					SetDParam(0, STR_GROUP_NAME);
 
					SetDParam(1, g->index);
 
					SetDParam(2, g->statistics.num_vehicle);
 
@@ -480,23 +480,23 @@ public:
 
		 * else this->list will contain all vehicles which belong to the selected group */
 
		this->BuildVehicleList();
 
		this->SortVehicleList();
 

	
 
		this->BuildGroupList(this->owner);
 

	
 
		this->group_sb->SetCount(this->groups.Length());
 
		this->vscroll->SetCount(this->vehicles.Length());
 
		this->group_sb->SetCount(this->groups.size());
 
		this->vscroll->SetCount(this->vehicles.size());
 

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

	
 
		/* Disable all lists management button when the list is empty */
 
		this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company,
 
		this->SetWidgetsDisabledState(this->vehicles.size() == 0 || _local_company != this->vli.company,
 
				WID_GL_STOP_ALL,
 
				WID_GL_START_ALL,
 
				WID_GL_MANAGE_VEHICLES_DROPDOWN,
 
				WIDGET_LIST_END);
 

	
 
		/* Disable the group specific function when we select the default group or all vehicles */
 
@@ -541,13 +541,13 @@ public:
 
				break;
 

	
 
			case WID_GL_INFO: {
 
				Money this_year = 0;
 
				Money last_year = 0;
 
				uint32 occupancy = 0;
 
				uint32 vehicle_count = this->vehicles.Length();
 
				uint32 vehicle_count = this->vehicles.size();
 

	
 
				for (uint i = 0; i < vehicle_count; i++) {
 
					const Vehicle *v = this->vehicles[i];
 
					assert(v->owner == this->owner);
 

	
 
					this_year += v->GetDisplayProfitThisYear();
 
@@ -577,23 +577,23 @@ public:
 

	
 
				break;
 
			}
 

	
 
			case WID_GL_LIST_GROUP: {
 
				int y1 = r.top + WD_FRAMERECT_TOP;
 
				int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.Length());
 
				int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.size());
 
				for (int i = this->group_sb->GetPosition(); i < max; ++i) {
 
					const Group *g = this->groups[i];
 

	
 
					assert(g->owner == this->owner);
 

	
 
					DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * LEVEL_WIDTH, g->replace_protection);
 

	
 
					y1 += this->tiny_step_height;
 
				}
 
				if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.Length()) {
 
				if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) {
 
					DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
 
				}
 
				break;
 
			}
 

	
 
			case WID_GL_SORT_BY_ORDER:
 
@@ -601,13 +601,13 @@ public:
 
				break;
 

	
 
			case WID_GL_LIST_VEHICLE:
 
				if (this->vli.index != ALL_GROUP) {
 
					/* Mark vehicles which are in sub-groups */
 
					int y = r.top;
 
					uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.Length());
 
					uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
 
					for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
						const Vehicle *v = this->vehicles[i];
 
						if (v->group_id != this->vli.index) {
 
							GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 2, _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
 
						}
 
						y += this->resize.step_height;
 
@@ -655,26 +655,26 @@ public:
 
					this->SetDirty();
 
				}
 
				break;
 

	
 
			case WID_GL_LIST_GROUP: { // Matrix Group
 
				uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
 
				if (id_g >= this->groups.Length()) return;
 
				if (id_g >= this->groups.size()) return;
 

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

	
 
				SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
 

	
 
				this->vehicles.ForceRebuild();
 
				this->SetDirty();
 
				break;
 
			}
 

	
 
			case WID_GL_LIST_VEHICLE: { // Matrix Vehicle
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 
				if (id_v >= this->vehicles.size()) return; // click out of list bound
 

	
 
				const Vehicle *v = this->vehicles[id_v];
 
				if (VehicleClicked(v)) break;
 

	
 
				this->vehicle_sel = v->index;
 

	
 
@@ -746,13 +746,13 @@ public:
 
				this->group_over = INVALID_GROUP;
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_GL_LIST_GROUP: { // Matrix group
 
				uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
 
				GroupID new_g = id_g >= this->groups.Length() ? INVALID_GROUP : this->groups[id_g]->index;
 
				GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index;
 

	
 
				if (this->group_sel != new_g && g->parent != new_g) {
 
					DoCommandP(0, this->group_sel | (1 << 16), new_g, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT));
 
				}
 

	
 
				this->group_sel = INVALID_GROUP;
 
@@ -779,26 +779,26 @@ public:
 
				const VehicleID vindex = this->vehicle_sel;
 
				this->vehicle_sel = INVALID_VEHICLE;
 
				this->group_over = INVALID_GROUP;
 
				this->SetDirty();
 

	
 
				uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
 
				GroupID new_g = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index;
 
				GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
 

	
 
				DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : NULL);
 
				break;
 
			}
 

	
 
			case WID_GL_LIST_VEHICLE: { // Matrix vehicle
 
				const VehicleID vindex = this->vehicle_sel;
 
				this->vehicle_sel = INVALID_VEHICLE;
 
				this->group_over = INVALID_GROUP;
 
				this->SetDirty();
 

	
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 
				if (id_v >= this->vehicles.size()) return; // click out of list bound
 

	
 
				const Vehicle *v = this->vehicles[id_v];
 
				if (!VehicleClicked(v) && vindex == v->index) {
 
					ShowVehicleViewWindow(v);
 
				}
 
				break;
 
@@ -831,13 +831,13 @@ public:
 
		switch (widget) {
 
			case WID_GL_SORT_BY_DROPDOWN:
 
				this->vehicles.SetSortType(index);
 
				break;
 

	
 
			case WID_GL_MANAGE_VEHICLES_DROPDOWN:
 
				assert(this->vehicles.Length() != 0);
 
				assert(this->vehicles.size() != 0);
 

	
 
				switch (index) {
 
					case ADI_REPLACE: // Replace window
 
						ShowReplaceGroupVehicleWindow(this->vli.index, this->vli.vtype);
 
						break;
 
					case ADI_SERVICE: // Send for servicing
 
@@ -892,13 +892,13 @@ public:
 
			case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
 
				new_group_over = DEFAULT_GROUP;
 
				break;
 

	
 
			case WID_GL_LIST_GROUP: { // ... the list of custom groups.
 
				uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
 
				new_group_over = id_g >= this->groups.Length() ? NEW_GROUP : this->groups[id_g]->index;
 
				new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
 
				break;
 
			}
 
		}
 

	
 
		/* Do not highlight when dragging over the current group */
 
		if (this->vehicle_sel != INVALID_VEHICLE) {
src/hotkeys.cpp
Show inline comments
 
@@ -200,13 +200,13 @@ static const char *KeycodeToString(uint1
 
 *  this function again.
 
 */
 
const char *SaveKeycodes(const Hotkey *hotkey)
 
{
 
	static char buf[128];
 
	buf[0] = '\0';
 
	for (uint i = 0; i < hotkey->keycodes.Length(); i++) {
 
	for (uint i = 0; i < hotkey->keycodes.size(); i++) {
 
		const char *str = KeycodeToString(hotkey->keycodes[i]);
 
		if (i > 0) strecat(buf, ",", lastof(buf));
 
		strecat(buf, str, lastof(buf));
 
	}
 
	return buf;
 
}
src/industry_gui.cpp
Show inline comments
 
@@ -1208,13 +1208,13 @@ protected:
 
			FOR_ALL_INDUSTRIES(i) {
 
				*this->industries.Append() = i;
 
			}
 

	
 
			this->industries.shrink_to_fit();
 
			this->industries.RebuildDone();
 
			this->vscroll->SetCount(this->industries.Length()); // Update scrollbar as well.
 
			this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well.
 
		}
 

	
 
		if (!this->industries.Sort()) return;
 
		IndustryDirectoryWindow::last_industry = NULL; // Reset name sorter sort cache
 
		this->SetWidgetDirty(WID_ID_INDUSTRY_LIST); // Set the modified widget dirty
 
	}
 
@@ -1369,17 +1369,17 @@ public:
 
				this->DrawSortButtonState(widget, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				int n = 0;
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				if (this->industries.Length() == 0) {
 
				if (this->industries.size() == 0) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_DIRECTORY_NONE);
 
					break;
 
				}
 
				for (uint i = this->vscroll->GetPosition(); i < this->industries.Length(); i++) {
 
				for (uint i = this->vscroll->GetPosition(); i < this->industries.size(); i++) {
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, this->GetIndustryString(this->industries[i]));
 

	
 
					y += this->resize.step_height;
 
					if (++n == this->vscroll->GetCapacity()) break; // max number of industries in 1 window
 
				}
 
				break;
 
@@ -1408,13 +1408,13 @@ public:
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
 
				for (uint i = 0; i < this->industries.Length(); i++) {
 
				for (uint i = 0; i < this->industries.size(); i++) {
 
					d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
 
				}
 
				resize->height = d.height;
 
				d.height *= 5;
 
				d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
@@ -1436,13 +1436,13 @@ public:
 
			case WID_ID_DROPDOWN_CRITERIA:
 
				ShowDropDownMenu(this, IndustryDirectoryWindow::sorter_names, this->industries.SortType(), WID_ID_DROPDOWN_CRITERIA, 0, 0);
 
				break;
 

	
 
			case WID_ID_INDUSTRY_LIST: {
 
				uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP);
 
				if (p < this->industries.Length()) {
 
				if (p < this->industries.size()) {
 
					if (_ctrl_pressed) {
 
						ShowExtraViewPortWindow(this->industries[p]->location.tile);
 
					} else {
 
						ScrollMainWindowToTile(this->industries[p]->location.tile);
 
					}
 
				}
 
@@ -2586,13 +2586,13 @@ struct IndustryCargoesWindow : public Wi
 
		int left_pos = WD_FRAMERECT_LEFT;
 
		if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::cargo_field_width) / 2;
 
		int last_column = (this->ind_cargo < NUM_INDUSTRYTYPES) ? 4 : 2;
 

	
 
		const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
 
		int vpos = -this->vscroll->GetPosition() * nwp->resize_y;
 
		for (uint i = 0; i < this->fields.Length(); i++) {
 
		for (uint i = 0; i < this->fields.size(); i++) {
 
			int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
 
			if (vpos + row_height >= 0) {
 
				int xpos = left_pos;
 
				int col, dir;
 
				if (_current_text_dir == TD_RTL) {
 
					col = last_column;
 
@@ -2628,13 +2628,13 @@ struct IndustryCargoesWindow : public Wi
 
		pt.y -= nw->pos_y;
 

	
 
		int vpos = WD_FRAMERECT_TOP + CargoesField::small_height - this->vscroll->GetPosition() * nw->resize_y;
 
		if (pt.y < vpos) return false;
 

	
 
		int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
 
		if (row + 1 >= (int)this->fields.Length()) return false;
 
		if (row + 1 >= (int)this->fields.size()) return false;
 
		vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
 
		row++; // rebase row to match index of this->fields.
 

	
 
		int xpos = 2 * WD_FRAMERECT_LEFT + ((this->ind_cargo < NUM_INDUSTRYTYPES) ? 0 :  (CargoesField::industry_width + CargoesField::cargo_field_width) / 2);
 
		if (pt.x < xpos) return false;
 
		int column;
 
@@ -2707,13 +2707,13 @@ struct IndustryCargoesWindow : public Wi
 
			case WID_IC_CARGO_DROPDOWN: {
 
				DropDownList *lst = new DropDownList;
 
				const CargoSpec *cs;
 
				FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
 
					*lst->Append() = new DropDownListStringItem(cs->name, cs->Index(), false);
 
				}
 
				if (lst->Length() == 0) {
 
				if (lst->size() == 0) {
 
					delete lst;
 
					break;
 
				}
 
				int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
 
				ShowDropDownList(this, lst, selected, WID_IC_CARGO_DROPDOWN, 0, true);
 
				break;
 
@@ -2724,13 +2724,13 @@ struct IndustryCargoesWindow : public Wi
 
				for (uint i = 0; i < NUM_INDUSTRYTYPES; i++) {
 
					IndustryType ind = _sorted_industry_types[i];
 
					const IndustrySpec *indsp = GetIndustrySpec(ind);
 
					if (!indsp->enabled) continue;
 
					*lst->Append() = new DropDownListStringItem(indsp->name, ind, false);
 
				}
 
				if (lst->Length() == 0) {
 
				if (lst->size() == 0) {
 
					delete lst;
 
					break;
 
				}
 
				int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;
 
				ShowDropDownList(this, lst, selected, WID_IC_IND_DROPDOWN, 0, true);
 
				break;
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -493,13 +493,13 @@ public:
 
	inline ConstNode operator[](NodeID num) const { return ConstNode(this, num); }
 

	
 
	/**
 
	 * Get the current size of the component.
 
	 * @return Size.
 
	 */
 
	inline uint Size() const { return this->nodes.Length(); }
 
	inline uint Size() const { return this->nodes.size(); }
 

	
 
	/**
 
	 * Get date of last compression.
 
	 * @return Date of last compression.
 
	 */
 
	inline Date LastCompression() const { return this->last_compression; }
src/music/dmusic.cpp
Show inline comments
 
@@ -683,13 +683,13 @@ static void MidiThreadProc(void *)
 
				/* find first block after start time and pretend playback started earlier
 
				 * this is to allow all blocks prior to the actual start to still affect playback,
 
				 * as they may contain important controller and program changes */
 
				size_t preload_bytes = 0;
 
				for (size_t bl = 0; bl < current_file.blocks.size(); bl++) {
 
					MidiFile::DataBlock &block = current_file.blocks[bl];
 
					preload_bytes += block.data.Length();
 
					preload_bytes += block.data.size();
 
					if (block.ticktime >= current_segment.start) {
 
						if (current_segment.loop) {
 
							DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes);
 
							current_segment.start_block = bl;
 
							break;
 
						} else {
 
@@ -749,13 +749,13 @@ static void MidiThreadProc(void *)
 

	
 
				/* Timestamp of the current block. */
 
				block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME;
 
				DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME));
 

	
 
				byte *data = block.data.Begin();
 
				size_t remaining = block.data.Length();
 
				size_t remaining = block.data.size();
 
				byte last_status = 0;
 
				while (remaining > 0) {
 
					/* MidiFile ought to have converted everything out of running status,
 
					 * but handle it anyway just to be safe */
 
					byte status = data[0];
 
					if (status & 0x80) {
src/music/midifile.cpp
Show inline comments
 
@@ -327,20 +327,20 @@ static bool FixupMidiData(MidiFile &targ
 

	
 
	/* Merge blocks with identical tick times */
 
	std::vector<MidiFile::DataBlock> merged_blocks;
 
	uint32 last_ticktime = 0;
 
	for (size_t i = 0; i < target.blocks.size(); i++) {
 
		MidiFile::DataBlock &block = target.blocks[i];
 
		if (block.data.Length() == 0) {
 
		if (block.data.size() == 0) {
 
			continue;
 
		} else if (block.ticktime > last_ticktime || merged_blocks.size() == 0) {
 
			merged_blocks.push_back(block);
 
			last_ticktime = block.ticktime;
 
		} else {
 
			byte *datadest = merged_blocks.back().data.Append(block.data.Length());
 
			memcpy(datadest, block.data.Begin(), block.data.Length());
 
			byte *datadest = merged_blocks.back().data.Append(block.data.size());
 
			memcpy(datadest, block.data.Begin(), block.data.size());
 
		}
 
	}
 
	std::swap(merged_blocks, target.blocks);
 

	
 
	/* Annotate blocks with real time */
 
	last_ticktime = 0;
src/music/win32_m.cpp
Show inline comments
 
@@ -184,13 +184,13 @@ void CALLBACK TimerCallback(UINT uTimerI
 
		/* find first block after start time and pretend playback started earlier
 
		* this is to allow all blocks prior to the actual start to still affect playback,
 
		* as they may contain important controller and program changes */
 
		uint preload_bytes = 0;
 
		for (size_t bl = 0; bl < _midi.current_file.blocks.size(); bl++) {
 
			MidiFile::DataBlock &block = _midi.current_file.blocks[bl];
 
			preload_bytes += block.data.Length();
 
			preload_bytes += block.data.size();
 
			if (block.ticktime >= _midi.current_segment.start) {
 
				if (_midi.current_segment.loop) {
 
					DEBUG(driver, 2, "Win32-MIDI: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime)/1000.0, (int)preload_bytes);
 
					_midi.current_segment.start_block = bl;
 
					break;
 
				} else {
 
@@ -227,13 +227,13 @@ void CALLBACK TimerCallback(UINT uTimerI
 
		/* check that block is not in the future */
 
		if (block.realtime / 1000 > playback_time) {
 
			break;
 
		}
 

	
 
		byte *data = block.data.Begin();
 
		size_t remaining = block.data.Length();
 
		size_t remaining = block.data.size();
 
		byte last_status = 0;
 
		while (remaining > 0) {
 
			/* MidiFile ought to have converted everything out of running status,
 
			 * but handle it anyway just to be safe */
 
			byte status = data[0];
 
			if (status & 0x80) {
src/network/core/tcp_http.cpp
Show inline comments
 
@@ -294,13 +294,13 @@ int NetworkHTTPSocketHandler::Receive()
 
/**
 
 * Do the receiving for all HTTP connections.
 
 */
 
/* static */ void NetworkHTTPSocketHandler::HTTPReceive()
 
{
 
	/* No connections, just bail out. */
 
	if (_http_connections.Length() == 0) return;
 
	if (_http_connections.size() == 0) return;
 

	
 
	fd_set read_fd;
 
	struct timeval tv;
 

	
 
	FD_ZERO(&read_fd);
 
	for (NetworkHTTPSocketHandler **iter = _http_connections.Begin(); iter < _http_connections.End(); iter++) {
src/network/core/tcp_listen.h
Show inline comments
 
@@ -137,22 +137,22 @@ public:
 
	 * Listen on a particular port.
 
	 * @param port The port to listen on.
 
	 * @return true if listening succeeded.
 
	 */
 
	static bool Listen(uint16 port)
 
	{
 
		assert(sockets.Length() == 0);
 
		assert(sockets.size() == 0);
 

	
 
		NetworkAddressList addresses;
 
		GetBindAddresses(&addresses, port);
 

	
 
		for (NetworkAddress *address = addresses.Begin(); address != addresses.End(); address++) {
 
			address->Listen(SOCK_STREAM, &sockets);
 
		}
 

	
 
		if (sockets.Length() == 0) {
 
		if (sockets.size() == 0) {
 
			DEBUG(net, 0, "[server] could not start network: could not create listening socket");
 
			NetworkError(STR_NETWORK_ERROR_SERVER_START);
 
			return false;
 
		}
 

	
 
		return true;
src/network/core/udp.cpp
Show inline comments
 
@@ -48,13 +48,13 @@ bool NetworkUDPSocketHandler::Listen()
 
	this->Close();
 

	
 
	for (NetworkAddress *addr = this->bind.Begin(); addr != this->bind.End(); addr++) {
 
		addr->Listen(SOCK_DGRAM, &this->sockets);
 
	}
 

	
 
	return this->sockets.Length() != 0;
 
	return this->sockets.size() != 0;
 
}
 

	
 
/**
 
 * Close the given UDP socket
 
 */
 
void NetworkUDPSocketHandler::Close()
 
@@ -77,13 +77,13 @@ NetworkRecvStatus NetworkUDPSocketHandle
 
 * @param recv the receiver (target) of the packet
 
 * @param all  send the packet using all sockets that can send it
 
 * @param broadcast whether to send a broadcast message
 
 */
 
void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool all, bool broadcast)
 
{
 
	if (this->sockets.Length() == 0) this->Listen();
 
	if (this->sockets.size() == 0) this->Listen();
 

	
 
	for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
 
		/* Make a local copy because if we resolve it we cannot
 
		 * easily unresolve it so we can resolve it later again. */
 
		NetworkAddress send(*recv);
 

	
src/network/network.cpp
Show inline comments
 
@@ -634,13 +634,13 @@ void GetBindAddresses(NetworkAddressList
 
{
 
	for (char **iter = _network_bind_list.Begin(); iter != _network_bind_list.End(); iter++) {
 
		*addresses->Append() = NetworkAddress(*iter, port);
 
	}
 

	
 
	/* No address, so bind to everything. */
 
	if (addresses->Length() == 0) {
 
	if (addresses->size() == 0) {
 
		*addresses->Append() = NetworkAddress("", port);
 
	}
 
}
 

	
 
/* Generates the list of manually added hosts from NetworkGameList and
 
 * dumps them into the array _network_host_list. This array is needed
src/network/network_content.cpp
Show inline comments
 
@@ -243,18 +243,18 @@ void ClientNetworkContentSocketHandler::
 
void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bool send_md5sum)
 
{
 
	if (cv == NULL) return;
 

	
 
	this->Connect();
 

	
 
	assert(cv->Length() < 255);
 
	assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
 
	assert(cv->size() < 255);
 
	assert(cv->size() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
 
			(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0)));
 

	
 
	Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID);
 
	p->Send_uint8(cv->Length());
 
	p->Send_uint8(cv->size());
 

	
 
	for (ContentIterator iter = cv->Begin(); iter != cv->End(); iter++) {
 
		const ContentInfo *ci = *iter;
 
		p->Send_uint8((byte)ci->type);
 
		p->Send_uint32(ci->unique_id);
 
		if (!send_md5sum) continue;
 
@@ -301,13 +301,13 @@ void ClientNetworkContentSocketHandler::
 
		if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
 

	
 
		*content.Append() = ci->id;
 
		bytes += ci->filesize;
 
	}
 

	
 
	files = content.Length();
 
	files = content.size();
 

	
 
	/* If there's nothing to download, do nothing. */
 
	if (files == 0) return;
 

	
 
	if (_settings_client.network.no_http_content_downloads || fallback) {
 
		this->DownloadSelectedContentFallback(content);
 
@@ -319,13 +319,13 @@ void ClientNetworkContentSocketHandler::
 
/**
 
 * Initiate downloading the content over HTTP.
 
 * @param content The content to download.
 
 */
 
void ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP(const ContentIDList &content)
 
{
 
	uint count = content.Length();
 
	uint count = content.size();
 

	
 
	/* Allocate memory for the whole request.
 
	 * Requests are "id\nid\n..." (as strings), so assume the maximum ID,
 
	 * which is uint32 so 10 characters long. Then the newlines and
 
	 * multiply that all with the count and then add the '\0'. */
 
	uint bytes = (10 + 1) * count + 1;
 
@@ -347,13 +347,13 @@ void ClientNetworkContentSocketHandler::
 
/**
 
 * Initiate downloading the content over the fallback protocol.
 
 * @param content The content to download.
 
 */
 
void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
 
{
 
	uint count = content.Length();
 
	uint count = content.size();
 
	const ContentID *content_ids = content.Begin();
 
	this->Connect();
 

	
 
	while (count > 0) {
 
		/* We can "only" send a limited number of IDs in a single packet.
 
		 * A packet begins with the packet size and a byte for the type.
 
@@ -604,13 +604,13 @@ void ClientNetworkContentSocketHandler::
 

	
 
	if (this->curFile != NULL) {
 
		/* We've finished downloading a file. */
 
		this->AfterDownload();
 
	}
 

	
 
	if ((uint)this->http_response_index >= this->http_response.Length()) {
 
	if ((uint)this->http_response_index >= this->http_response.size()) {
 
		/* It's not a real failure, but if there's
 
		 * nothing more to download it helps with
 
		 * cleaning up the stuff we allocated. */
 
		this->OnFailure();
 
		return;
 
	}
 
@@ -650,13 +650,13 @@ void ClientNetworkContentSocketHandler::
 
		this->curInfo->filesize = atoi(str);
 

	
 
		/* Read the URL */
 
		str = p + 1;
 
		/* Is it a fallback URL? If so, just continue with the next one. */
 
		if (strncmp(str, "ottd", 4) == 0) {
 
			if ((uint)this->http_response_index >= this->http_response.Length()) {
 
			if ((uint)this->http_response_index >= this->http_response.size()) {
 
				/* Have we gone through all lines? */
 
				this->OnFailure();
 
				return;
 
			}
 
			continue;
 
		}
 
@@ -922,13 +922,13 @@ void ClientNetworkContentSocketHandler::
 
	*tree.Append() = child;
 

	
 
	/* First find all direct parents. We can't use the "normal" iterator as
 
	 * we are including stuff into the vector and as such the vector's data
 
	 * store can be reallocated (and thus move), which means out iterating
 
	 * pointer gets invalid. So fall back to the indices. */
 
	for (uint i = 0; i < tree.Length(); i++) {
 
	for (uint i = 0; i < tree.size(); i++) {
 
		ConstContentVector parents;
 
		this->ReverseLookupDependency(parents, tree[i]);
 

	
 
		for (ConstContentIterator piter = parents.Begin(); piter != parents.End(); piter++) {
 
			tree.Include(*piter);
 
		}
src/network/network_content.h
Show inline comments
 
@@ -126,13 +126,13 @@ public:
 

	
 
	void ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const;
 
	void ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const;
 
	void CheckDependencyState(ContentInfo *ci);
 

	
 
	/** Get the number of content items we know locally. */
 
	uint Length() const { return this->infos.Length(); }
 
	uint Length() const { return this->infos.size(); }
 
	/** Get the begin of the content inf iterator. */
 
	ConstContentIterator Begin() const { return this->infos.Begin(); }
 
	/** Get the nth position of the content inf iterator. */
 
	ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); }
 
	/** Get the end of the content inf iterator. */
 
	ConstContentIterator End() const { return this->infos.End(); }
src/network/network_content_gui.cpp
Show inline comments
 
@@ -398,13 +398,13 @@ class NetworkContentListWindow : public 
 

	
 
		this->FilterContentList();
 
		this->content.shrink_to_fit();
 
		this->content.RebuildDone();
 
		this->SortContentList();
 

	
 
		this->vscroll->SetCount(this->content.Length()); // Update the scrollbar
 
		this->vscroll->SetCount(this->content.size()); // Update the scrollbar
 
		this->ScrollToSelected();
 
	}
 

	
 
	/** Sort content by name. */
 
	static int CDECL NameSorter(const ContentInfo * const *a, const ContentInfo * const *b)
 
	{
 
@@ -788,13 +788,13 @@ public:
 
			return;
 
		}
 

	
 
		switch (widget) {
 
			case WID_NCL_MATRIX: {
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
 
				if (id_v >= this->content.Length()) return; // click out of bounds
 
				if (id_v >= this->content.size()) return; // click out of bounds
 

	
 
				this->selected = *this->content.Get(id_v);
 
				this->list_pos = id_v;
 

	
 
				const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
 
				if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
 
@@ -812,13 +812,13 @@ public:
 

	
 
			case WID_NCL_CHECKBOX:
 
			case WID_NCL_TYPE:
 
			case WID_NCL_NAME:
 
				if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
 
					this->content.ToggleSortOrder();
 
					if (this->content.Length() > 0) this->list_pos = this->content.Length() - this->list_pos - 1;
 
					if (this->content.size() > 0) this->list_pos = this->content.size() - this->list_pos - 1;
 
				} else {
 
					this->content.SetSortType(widget - WID_NCL_CHECKBOX);
 
					this->content.ForceResort();
 
					this->SortContentList();
 
				}
 
				this->ScrollToSelected();
 
@@ -871,29 +871,29 @@ public:
 
			case WKC_UP:
 
				/* scroll up by one */
 
				if (this->list_pos > 0) this->list_pos--;
 
				break;
 
			case WKC_DOWN:
 
				/* scroll down by one */
 
				if (this->list_pos < (int)this->content.Length() - 1) this->list_pos++;
 
				if (this->list_pos < (int)this->content.size() - 1) this->list_pos++;
 
				break;
 
			case WKC_PAGEUP:
 
				/* scroll up a page */
 
				this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
 
				break;
 
			case WKC_PAGEDOWN:
 
				/* scroll down a page */
 
				this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.Length() - 1);
 
				this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->content.size() - 1);
 
				break;
 
			case WKC_HOME:
 
				/* jump to beginning */
 
				this->list_pos = 0;
 
				break;
 
			case WKC_END:
 
				/* jump to end */
 
				this->list_pos = this->content.Length() - 1;
 
				this->list_pos = this->content.size() - 1;
 
				break;
 

	
 
			case WKC_SPACE:
 
			case WKC_RETURN:
 
				if (keycode == WKC_RETURN || !IsWidgetFocused(WID_NCL_FILTER)) {
 
					if (this->selected != NULL) {
 
@@ -911,13 +911,13 @@ public:
 
				FALLTHROUGH;
 

	
 
			default:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		if (this->content.Length() == 0) {
 
		if (this->content.size() == 0) {
 
			this->list_pos = 0; // above stuff may result in "-1".
 
			if (this->UpdateFilterState()) {
 
				this->content.ForceRebuild();
 
				this->InvalidateData();
 
			}
 
			return ES_HANDLED;
src/network/network_gui.cpp
Show inline comments
 
@@ -266,13 +266,13 @@ protected:
 
		} else {
 
			this->servers.SetFilterState(false);
 
		}
 

	
 
		this->servers.shrink_to_fit();
 
		this->servers.RebuildDone();
 
		this->vscroll->SetCount(this->servers.Length());
 
		this->vscroll->SetCount(this->servers.size());
 

	
 
		/* Sort the list of network games as requested. */
 
		this->servers.Sort();
 
		this->UpdateListPos();
 
	}
 

	
 
@@ -351,13 +351,13 @@ protected:
 
	}
 

	
 
	/** Set this->list_pos to match this->server */
 
	void UpdateListPos()
 
	{
 
		this->list_pos = SLP_INVALID;
 
		for (uint i = 0; i != this->servers.Length(); i++) {
 
		for (uint i = 0; i != this->servers.size(); i++) {
 
			if (this->servers[i] == this->server) {
 
				this->list_pos = i;
 
				break;
 
			}
 
		}
 
	}
 
@@ -561,13 +561,13 @@ public:
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NG_MATRIX: {
 
				uint16 y = r.top;
 

	
 
				const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.Length());
 
				const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size());
 

	
 
				for (int i = this->vscroll->GetPosition(); i < max; ++i) {
 
					const NetworkGameList *ngl = this->servers[i];
 
					this->DrawServerLine(ngl, y, ngl == this->server);
 
					y += this->resize.step_height;
 
				}
 
@@ -707,25 +707,25 @@ public:
 
			case WID_NG_MAPSIZE: // Sort by map size
 
			case WID_NG_DATE:    // Sort by date
 
			case WID_NG_YEARS:   // Sort by years
 
			case WID_NG_INFO:    // Connectivity (green dot)
 
				if (this->servers.SortType() == widget - WID_NG_NAME) {
 
					this->servers.ToggleSortOrder();
 
					if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.Length() - this->list_pos - 1;
 
					if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.size() - this->list_pos - 1;
 
				} else {
 
					this->servers.SetSortType(widget - WID_NG_NAME);
 
					this->servers.ForceResort();
 
					this->SortNetworkGameList();
 
				}
 
				this->ScrollToSelectedServer();
 
				this->SetDirty();
 
				break;
 

	
 
			case WID_NG_MATRIX: { // Show available network games
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
 
				this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
 
				this->server = (id_v < this->servers.size()) ? this->servers[id_v] : NULL;
 
				this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
 
				this->SetDirty();
 

	
 
				/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
 
				if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
 
				break;
 
@@ -816,41 +816,41 @@ public:
 
	EventState OnKeyPress(WChar key, uint16 keycode) override
 
	{
 
		EventState state = ES_NOT_HANDLED;
 

	
 
		/* handle up, down, pageup, pagedown, home and end */
 
		if (keycode == WKC_UP || keycode == WKC_DOWN || keycode == WKC_PAGEUP || keycode == WKC_PAGEDOWN || keycode == WKC_HOME || keycode == WKC_END) {
 
			if (this->servers.Length() == 0) return ES_HANDLED;
 
			if (this->servers.size() == 0) return ES_HANDLED;
 
			switch (keycode) {
 
				case WKC_UP:
 
					/* scroll up by one */
 
					if (this->list_pos == SLP_INVALID) return ES_HANDLED;
 
					if (this->list_pos > 0) this->list_pos--;
 
					break;
 
				case WKC_DOWN:
 
					/* scroll down by one */
 
					if (this->list_pos == SLP_INVALID) return ES_HANDLED;
 
					if (this->list_pos < this->servers.Length() - 1) this->list_pos++;
 
					if (this->list_pos < this->servers.size() - 1) this->list_pos++;
 
					break;
 
				case WKC_PAGEUP:
 
					/* scroll up a page */
 
					if (this->list_pos == SLP_INVALID) return ES_HANDLED;
 
					this->list_pos = (this->list_pos < this->vscroll->GetCapacity()) ? 0 : this->list_pos - this->vscroll->GetCapacity();
 
					break;
 
				case WKC_PAGEDOWN:
 
					/* scroll down a page */
 
					if (this->list_pos == SLP_INVALID) return ES_HANDLED;
 
					this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.Length() - 1);
 
					this->list_pos = min(this->list_pos + this->vscroll->GetCapacity(), (int)this->servers.size() - 1);
 
					break;
 
				case WKC_HOME:
 
					/* jump to beginning */
 
					this->list_pos = 0;
 
					break;
 
				case WKC_END:
 
					/* jump to end */
 
					this->list_pos = this->servers.Length() - 1;
 
					this->list_pos = this->servers.size() - 1;
 
					break;
 
				default: NOT_REACHED();
 
			}
 

	
 
			this->server = this->servers[this->list_pos];
 

	
 
@@ -1786,13 +1786,13 @@ struct NetworkClientListPopupWindow : Wi
 
	{
 
		Dimension d = *size;
 
		for (const ClientListAction *action = this->actions.Begin(); action != this->actions.End(); action++) {
 
			d = maxdim(GetStringBoundingBox(action->name), d);
 
		}
 

	
 
		d.height *= this->actions.Length();
 
		d.height *= this->actions.size();
 
		d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
		d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		*size = d;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -1816,18 +1816,18 @@ struct NetworkClientListPopupWindow : Wi
 
	void OnMouseLoop() override
 
	{
 
		/* We selected an action */
 
		uint index = (_cursor.pos.y - this->top - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
 

	
 
		if (_left_button_down) {
 
			if (index == this->sel_index || index >= this->actions.Length()) return;
 
			if (index == this->sel_index || index >= this->actions.size()) return;
 

	
 
			this->sel_index = index;
 
			this->SetDirty();
 
		} else {
 
			if (index < this->actions.Length() && _cursor.pos.y >= this->top) {
 
			if (index < this->actions.size() && _cursor.pos.y >= this->top) {
 
				const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(this->client_id);
 
				if (ci != NULL) this->actions[index].proc(ci);
 
			}
 

	
 
			DeleteWindowByClass(WC_CLIENT_LIST_POPUP);
 
		}
src/newgrf.cpp
Show inline comments
 
@@ -655,13 +655,13 @@ static Engine *GetNewEngine(const GRFFil
 

	
 
	/* ... it's not, so create a new one based off an existing engine */
 
	Engine *e = new Engine(type, internal_id);
 
	e->grf_prop.grffile = file;
 

	
 
	/* Reserve the engine slot */
 
	assert(_engine_mngr.Length() == e->index);
 
	assert(_engine_mngr.size() == e->index);
 
	EngineIDMapping *eid = _engine_mngr.Append();
 
	eid->type            = type;
 
	eid->grfid           = scope_grfid; // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
 
	eid->internal_id     = internal_id;
 
	eid->substitute_id   = min(internal_id, _engine_counts[type]); // substitute_id == _engine_counts[subtype] means "no substitute"
 

	
 
@@ -1055,13 +1055,13 @@ static ChangeInfoResult RailVehicleChang
 
		RailVehicleInfo *rvi = &e->u.rail;
 

	
 
		switch (prop) {
 
			case 0x05: { // Track type
 
				uint8 tracktype = buf->ReadByte();
 

	
 
				if (tracktype < _cur.grffile->railtype_list.Length()) {
 
				if (tracktype < _cur.grffile->railtype_list.size()) {
 
					_gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype];
 
					break;
 
				}
 

	
 
				switch (tracktype) {
 
					case 0: _gted[e->index].railtypelabel = rvi->engclass >= 2 ? RAILTYPE_ELECTRIC_LABEL : RAILTYPE_RAIL_LABEL; break;
 
@@ -1197,13 +1197,13 @@ static ChangeInfoResult RailVehicleChang
 
				} else if (traction <= 0x41) {
 
					engclass = EC_MAGLEV;
 
				} else {
 
					break;
 
				}
 

	
 
				if (_cur.grffile->railtype_list.Length() == 0) {
 
				if (_cur.grffile->railtype_list.size() == 0) {
 
					/* Use traction type to select between normal and electrified
 
					 * rail only when no translation list is in place. */
 
					if (_gted[e->index].railtypelabel == RAILTYPE_RAIL_LABEL     && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_ELECTRIC_LABEL;
 
					if (_gted[e->index].railtypelabel == RAILTYPE_ELECTRIC_LABEL && engclass  < EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_RAIL_LABEL;
 
				}
 

	
 
@@ -4796,13 +4796,13 @@ static void NewSpriteGroup(ByteReader *b
 
			/* Loop through the var adjusts. Unfortunately we don't know how many we have
 
			 * from the outset, so we shall have to keep reallocing. */
 
			do {
 
				DeterministicSpriteGroupAdjust *adjust = adjusts.Append();
 

	
 
				/* The first var adjust doesn't have an operation specified, so we set it to add. */
 
				adjust->operation = adjusts.Length() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte();
 
				adjust->operation = adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte();
 
				adjust->variable  = buf->ReadByte();
 
				if (adjust->variable == 0x7E) {
 
					/* Link subroutine group */
 
					adjust->subroutine = GetGroupFromGroupID(setid, type, buf->ReadByte());
 
				} else {
 
					adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? buf->ReadByte() : 0;
 
@@ -4821,13 +4821,13 @@ static void NewSpriteGroup(ByteReader *b
 
					adjust->divmod_val = 0;
 
				}
 

	
 
				/* Continue reading var adjusts while bit 5 is set. */
 
			} while (HasBit(varadjust, 5));
 

	
 
			group->num_adjusts = adjusts.Length();
 
			group->num_adjusts = adjusts.size();
 
			group->adjusts = MallocT<DeterministicSpriteGroupAdjust>(group->num_adjusts);
 
			MemCpyT(group->adjusts, adjusts.Begin(), group->num_adjusts);
 

	
 
			std::vector<DeterministicSpriteGroupRange> ranges;
 
			ranges.resize(buf->ReadByte());
 
			for (uint i = 0; i < ranges.size(); i++) {
 
@@ -5082,13 +5082,13 @@ static CargoID TranslateCargo(uint8 feat
 
		}
 
	}
 
	/* Special cargo types for purchase list and stations */
 
	if (feature == GSF_STATIONS && ctype == 0xFE) return CT_DEFAULT_NA;
 
	if (ctype == 0xFF) return CT_PURCHASE;
 

	
 
	if (_cur.grffile->cargo_list.Length() == 0) {
 
	if (_cur.grffile->cargo_list.size() == 0) {
 
		/* No cargo table, so use bitnum values */
 
		if (ctype >= 32) {
 
			grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
 
			return CT_INVALID;
 
		}
 

	
 
@@ -5102,14 +5102,14 @@ static CargoID TranslateCargo(uint8 feat
 

	
 
		grfmsg(5, "TranslateCargo: Cargo bitnum %d not available in this climate, skipping.", ctype);
 
		return CT_INVALID;
 
	}
 

	
 
	/* Check if the cargo type is out of bounds of the cargo translation table */
 
	if (ctype >= _cur.grffile->cargo_list.Length()) {
 
		grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, _cur.grffile->cargo_list.Length() - 1);
 
	if (ctype >= _cur.grffile->cargo_list.size()) {
 
		grfmsg(1, "TranslateCargo: Cargo type %d out of range (max %d), skipping.", ctype, (unsigned int)_cur.grffile->cargo_list.size() - 1);
 
		return CT_INVALID;
 
	}
 

	
 
	/* Look up the cargo label from the translation table */
 
	CargoLabel cl = _cur.grffile->cargo_list[ctype];
 
	if (cl == 0) {
 
@@ -7847,14 +7847,14 @@ static bool HandleParameterInfo(ByteRead
 
			grfmsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA' should have type 'C' and their parameter number as id");
 
			if (!SkipUnknownInfo(buf, type)) return false;
 
			type = buf->ReadByte();
 
			continue;
 
		}
 

	
 
		if (id >= _cur.grfconfig->param_info.Length()) {
 
			uint num_to_add = id - _cur.grfconfig->param_info.Length() + 1;
 
		if (id >= _cur.grfconfig->param_info.size()) {
 
			uint num_to_add = id - _cur.grfconfig->param_info.size() + 1;
 
			GRFParameterInfo **newdata = _cur.grfconfig->param_info.Append(num_to_add);
 
			MemSetT<GRFParameterInfo *>(newdata, 0, num_to_add);
 
		}
 
		if (_cur.grfconfig->param_info[id] == NULL) {
 
			_cur.grfconfig->param_info[id] = new GRFParameterInfo(id);
 
		}
 
@@ -8377,13 +8377,13 @@ static void BuildCargoTranslationMap()
 
	memset(_cur.grffile->cargo_map, 0xFF, sizeof(_cur.grffile->cargo_map));
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		const CargoSpec *cs = CargoSpec::Get(c);
 
		if (!cs->IsValid()) continue;
 

	
 
		if (_cur.grffile->cargo_list.Length() == 0) {
 
		if (_cur.grffile->cargo_list.size() == 0) {
 
			/* Default translation table, so just a straight mapping to bitnum */
 
			_cur.grffile->cargo_map[c] = cs->bitnum;
 
		} else {
 
			/* Check the translation table for this cargo's label */
 
			int index = _cur.grffile->cargo_list.FindIndex(cs->label);
 
			if (index >= 0) _cur.grffile->cargo_map[c] = index;
 
@@ -8557,13 +8557,13 @@ static void CalculateRefitMasks()
 
		if (ei->cargo_type == CT_INVALID && ei->refit_mask != 0) {
 
			/* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */
 
			const uint8 *cargo_map_for_first_refittable = NULL;
 
			{
 
				const GRFFile *file = _gted[engine].defaultcargo_grf;
 
				if (file == NULL) file = e->GetGRF();
 
				if (file != NULL && file->grf_version >= 8 && file->cargo_list.Length() != 0) {
 
				if (file != NULL && file->grf_version >= 8 && file->cargo_list.size() != 0) {
 
					cargo_map_for_first_refittable = file->cargo_map;
 
				}
 
			}
 

	
 
			if (cargo_map_for_first_refittable != NULL) {
 
				/* Use first refittable cargo from cargo translation table */
 
@@ -9213,13 +9213,13 @@ static void FinalisePriceBaseMultipliers
 
{
 
	extern const PriceBaseSpec _price_base_specs[];
 
	/** Features, to which '_grf_id_overrides' applies. Currently vehicle features only. */
 
	static const uint32 override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT);
 

	
 
	/* Evaluate grf overrides */
 
	int num_grfs = _grf_files.Length();
 
	int num_grfs = _grf_files.size();
 
	int *grf_overrides = AllocaM(int, num_grfs);
 
	for (int i = 0; i < num_grfs; i++) {
 
		grf_overrides[i] = -1;
 

	
 
		GRFFile *source = _grf_files[i];
 
		uint32 override = _grf_id_overrides[source->grfid];
src/newgrf_cargo.cpp
Show inline comments
 
@@ -79,16 +79,16 @@ CargoID GetCargoTranslation(uint8 cargo,
 
{
 
	/* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */
 
	if (grffile->grf_version < 7 && !usebit) return cargo;
 

	
 
	/* Other cases use (possibly translated) cargobits */
 

	
 
	if (grffile->cargo_list.Length() > 0) {
 
	if (grffile->cargo_list.size() > 0) {
 
		/* ...and the cargo is in bounds, then get the cargo ID for
 
		 * the label */
 
		if (cargo < grffile->cargo_list.Length()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
 
		if (cargo < grffile->cargo_list.size()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
 
	} else {
 
		/* Else the cargo value is a 'climate independent' 'bitnum' */
 
		return GetCargoIDByBitnum(cargo);
 
	}
 
	return CT_INVALID;
 
}
src/newgrf_config.cpp
Show inline comments
 
@@ -80,13 +80,13 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
 
	if (config.filename != NULL) this->filename = stredup(config.filename);
 
	this->name->AddRef();
 
	this->info->AddRef();
 
	this->url->AddRef();
 
	if (config.error != NULL) this->error = new GRFError(*config.error);
 
	for (uint i = 0; i < config.param_info.Length(); i++) {
 
	for (uint i = 0; i < config.param_info.size(); i++) {
 
		if (config.param_info[i] == NULL) {
 
			*this->param_info.Append() = NULL;
 
		} else {
 
			*this->param_info.Append() = new GRFParameterInfo(*config.param_info[i]);
 
		}
 
	}
 
@@ -101,13 +101,13 @@ GRFConfig::~GRFConfig()
 
		delete this->error;
 
	}
 
	this->name->Release();
 
	this->info->Release();
 
	this->url->Release();
 

	
 
	for (uint i = 0; i < this->param_info.Length(); i++) delete this->param_info[i];
 
	for (uint i = 0; i < this->param_info.size(); i++) delete this->param_info[i];
 
}
 

	
 
/**
 
 * Copy the parameter information from the \a src config.
 
 * @param src Source config.
 
 */
 
@@ -152,13 +152,13 @@ void GRFConfig::SetParameterDefaults()
 
{
 
	this->num_params = 0;
 
	MemSetT<uint32>(this->param, 0, lengthof(this->param));
 

	
 
	if (!this->has_param_defaults) return;
 

	
 
	for (uint i = 0; i < this->param_info.Length(); i++) {
 
	for (uint i = 0; i < this->param_info.size(); i++) {
 
		if (this->param_info[i] == NULL) continue;
 
		this->param_info[i]->SetValue(this, this->param_info[i]->def_value);
 
	}
 
}
 

	
 
/**
 
@@ -258,24 +258,24 @@ GRFParameterInfo::GRFParameterInfo(GRFPa
 
	def_value(info.def_value),
 
	param_nr(info.param_nr),
 
	first_bit(info.first_bit),
 
	num_bit(info.num_bit),
 
	complete_labels(info.complete_labels)
 
{
 
	for (uint i = 0; i < info.value_names.Length(); i++) {
 
	for (uint i = 0; i < info.value_names.size(); i++) {
 
		SmallPair<uint32, GRFText *> *data = info.value_names.Get(i);
 
		this->value_names.Insert(data->first, DuplicateGRFText(data->second));
 
	}
 
}
 

	
 
/** Cleanup all parameter info. */
 
GRFParameterInfo::~GRFParameterInfo()
 
{
 
	CleanUpGRFText(this->name);
 
	CleanUpGRFText(this->desc);
 
	for (uint i = 0; i < this->value_names.Length(); i++) {
 
	for (uint i = 0; i < this->value_names.size(); i++) {
 
		SmallPair<uint32, GRFText *> *data = this->value_names.Get(i);
 
		CleanUpGRFText(data->second);
 
	}
 
}
 

	
 
/**
 
@@ -606,13 +606,13 @@ compatible_grf:
 
				c->info->AddRef();
 
				c->error = NULL;
 
				c->version = f->version;
 
				c->min_loadable_version = f->min_loadable_version;
 
				c->num_valid_params = f->num_valid_params;
 
				c->has_param_defaults = f->has_param_defaults;
 
				for (uint i = 0; i < f->param_info.Length(); i++) {
 
				for (uint i = 0; i < f->param_info.size(); i++) {
 
					if (f->param_info[i] == NULL) {
 
						*c->param_info.Append() = NULL;
 
					} else {
 
						*c->param_info.Append() = new GRFParameterInfo(*f->param_info[i]);
 
					}
 
				}
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -892,13 +892,13 @@ struct SpriteAlignerWindow : Window {
 

	
 
			case WID_SA_LIST: {
 
				const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
				int step_size = nwid->resize_y;
 

	
 
				SmallVector<SpriteID, 256> &list = _newgrf_debug_sprite_picker.sprites;
 
				int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.Length());
 
				int max = min<int>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), list.size());
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (int i = this->vscroll->GetPosition(); i < max; i++) {
 
					SetDParam(0, list[i]);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
 
					y += step_size;
 
@@ -937,13 +937,13 @@ struct SpriteAlignerWindow : Window {
 

	
 
			case WID_SA_LIST: {
 
				const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 
				int step_size = nwid->resize_y;
 

	
 
				uint i = this->vscroll->GetPosition() + (pt.y - nwid->pos_y) / step_size;
 
				if (i < _newgrf_debug_sprite_picker.sprites.Length()) {
 
				if (i < _newgrf_debug_sprite_picker.sprites.size()) {
 
					SpriteID spr = _newgrf_debug_sprite_picker.sprites[i];
 
					if (GetSpriteType(spr) == ST_NORMAL) this->current_sprite = spr;
 
				}
 
				this->SetDirty();
 
				break;
 
			}
 
@@ -1012,13 +1012,13 @@ struct SpriteAlignerWindow : Window {
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		if (data == 1) {
 
			/* Sprite picker finished */
 
			this->RaiseWidget(WID_SA_PICKER);
 
			this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.Length());
 
			this->vscroll->SetCount(_newgrf_debug_sprite_picker.sprites.size());
 
		}
 
	}
 

	
 
	void OnResize() override
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, WID_SA_LIST);
src/newgrf_engine.cpp
Show inline comments
 
@@ -1230,13 +1230,13 @@ void CommitVehicleListOrderChanges()
 
	/* Pre-sort engines by scope-grfid and local index */
 
	SmallVector<EngineID, 16> ordering;
 
	Engine *e;
 
	FOR_ALL_ENGINES(e) {
 
		*ordering.Append() = e->index;
 
	}
 
	QSortT(ordering.Begin(), ordering.Length(), EnginePreSort);
 
	QSortT(ordering.Begin(), ordering.size(), EnginePreSort);
 

	
 
	/* Apply Insertion-Sort operations */
 
	const ListOrderChange *end = _list_order_changes.End();
 
	for (const ListOrderChange *it = _list_order_changes.Begin(); it != end; ++it) {
 
		EngineID source = it->engine;
 
		uint local_target = it->target;
src/newgrf_gui.cpp
Show inline comments
 
@@ -163,13 +163,13 @@ struct NewGRFParametersWindow : public W
 
		clicked_button(UINT_MAX),
 
		clicked_dropdown(false),
 
		closing_dropdown(false),
 
		clicked_row(UINT_MAX),
 
		editable(editable)
 
	{
 
		this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.Length() != 0);
 
		this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.size() != 0);
 

	
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR);
 
		this->GetWidget<NWidgetStacked>(WID_NP_SHOW_NUMPAR)->SetDisplayedPlane(this->action14present ? SZSP_HORIZONTAL : 0);
 
		this->GetWidget<NWidgetStacked>(WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL);
 
		this->FinishInitNested();  // Initializes 'this->line_height' as side effect.
 
@@ -217,13 +217,13 @@ struct NewGRFParametersWindow : public W
 
				size->height = 5 * this->line_height;
 
				break;
 

	
 
			case WID_NP_DESCRIPTION:
 
				/* Minimum size of 4 lines. The 500 is the default size of the window. */
 
				Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, (uint)FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
 
				for (uint i = 0; i < this->grf_config->param_info.Length(); i++) {
 
				for (uint i = 0; i < this->grf_config->param_info.size(); i++) {
 
					const GRFParameterInfo *par_info = this->grf_config->param_info[i];
 
					if (par_info == NULL) continue;
 
					const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
					if (desc == NULL) continue;
 
					Dimension d = GetStringMultiLineBoundingBox(desc, suggestion);
 
					d.height += WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM;
 
@@ -243,13 +243,13 @@ struct NewGRFParametersWindow : public W
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget == WID_NP_DESCRIPTION) {
 
			const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
			const GRFParameterInfo *par_info = (this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
			if (par_info == NULL) return;
 
			const char *desc = GetGRFStringFromGRFText(par_info->desc);
 
			if (desc == NULL) return;
 
			DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_TEXTPANEL_TOP, r.bottom - WD_TEXTPANEL_BOTTOM, desc, TC_BLACK);
 
			return;
 
		} else if (widget != WID_NP_BACKGROUND) {
 
@@ -262,13 +262,13 @@ struct NewGRFParametersWindow : public W
 
		uint text_right   = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
 

	
 
		int y = r.top;
 
		int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
 
		int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
 
		for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
 
			GRFParameterInfo *par_info = (i < this->grf_config->param_info.Length()) ? this->grf_config->param_info[i] : NULL;
 
			GRFParameterInfo *par_info = (i < this->grf_config->param_info.size()) ? this->grf_config->param_info[i] : NULL;
 
			if (par_info == NULL) par_info = GetDummyParameterInfo(i);
 
			uint32 current_value = par_info->GetValue(this->grf_config);
 
			bool selected = (i == this->clicked_row);
 

	
 
			if (par_info->type == PTYPE_BOOL) {
 
				DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, this->editable);
 
@@ -347,13 +347,13 @@ struct NewGRFParametersWindow : public W
 

	
 
				const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_NP_BACKGROUND);
 
				int x = pt.x - wid->pos_x;
 
				if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
 
				x -= 4;
 

	
 
				GRFParameterInfo *par_info = (num < this->grf_config->param_info.Length()) ? this->grf_config->param_info[num] : NULL;
 
				GRFParameterInfo *par_info = (num < this->grf_config->param_info.size()) ? this->grf_config->param_info[num] : NULL;
 
				if (par_info == NULL) par_info = GetDummyParameterInfo(num);
 

	
 
				/* One of the arrows is clicked */
 
				uint32 old_val = par_info->GetValue(this->grf_config);
 
				if (par_info->type != PTYPE_BOOL && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info->complete_labels) {
 
					if (this->clicked_dropdown) {
 
@@ -428,23 +428,23 @@ struct NewGRFParametersWindow : public W
 
	}
 

	
 
	void OnQueryTextFinished(char *str) override
 
	{
 
		if (StrEmpty(str)) return;
 
		int32 value = atoi(str);
 
		GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
		GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
		if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
 
		uint32 val = Clamp<uint32>(value, par_info->min_value, par_info->max_value);
 
		par_info->SetValue(this->grf_config, val);
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	{
 
		assert(this->clicked_dropdown);
 
		GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.Length()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
		GRFParameterInfo *par_info = ((uint)this->clicked_row < this->grf_config->param_info.size()) ? this->grf_config->param_info[this->clicked_row] : NULL;
 
		if (par_info == NULL) par_info = GetDummyParameterInfo(this->clicked_row);
 
		par_info->SetValue(this->grf_config, index);
 
		this->SetDirty();
 
	}
 

	
 
	void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
 
@@ -744,13 +744,13 @@ struct NewGRFWindow : public Window, New
 
			case WID_NS_NEWGRF_INFO:
 
				size->height = max(size->height, WD_FRAMERECT_TOP + 10 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + padding.height + 2);
 
				break;
 

	
 
			case WID_NS_PRESET_LIST: {
 
				Dimension d = GetStringBoundingBox(STR_NUM_CUSTOM);
 
				for (uint i = 0; i < _grf_preset_list.Length(); i++) {
 
				for (uint i = 0; i < _grf_preset_list.size(); i++) {
 
					if (_grf_preset_list[i] != NULL) {
 
						SetDParamStr(0, _grf_preset_list[i]);
 
						d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
 
					}
 
				}
 
				d.width += padding.width;
 
@@ -879,13 +879,13 @@ struct NewGRFWindow : public Window, New
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, this->active_over == -2 ? PC_DARK_GREY : PC_BLACK);
 

	
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_NS_AVAIL_LIST)->resize_y;
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				uint min_index = this->vscroll2->GetPosition();
 
				uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.Length());
 
				uint max_index = min(min_index + this->vscroll2->GetCapacity(), this->avails.size());
 

	
 
				for (uint i = min_index; i < max_index; i++) {
 
					const GRFConfig *c = this->avails[i];
 
					bool h = (c == this->avail_sel);
 
					const char *text = c->GetName();
 

	
 
@@ -926,13 +926,13 @@ struct NewGRFWindow : public Window, New
 
			case WID_NS_PRESET_LIST: {
 
				DropDownList *list = new DropDownList();
 

	
 
				/* Add 'None' option for clearing list */
 
				*list->Append() = new DropDownListStringItem(STR_NONE, -1, false);
 

	
 
				for (uint i = 0; i < _grf_preset_list.Length(); i++) {
 
				for (uint i = 0; i < _grf_preset_list.size(); i++) {
 
					if (_grf_preset_list[i] != NULL) {
 
						*list->Append() = new DropDownListCharStringItem(_grf_preset_list[i], i, false);
 
					}
 
				}
 

	
 
				this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
 
@@ -1066,13 +1066,13 @@ struct NewGRFWindow : public Window, New
 
			case WID_NS_AVAIL_LIST: { // Select a non-active GRF.
 
				ResetObjectToPlace();
 

	
 
				uint i = this->vscroll2->GetScrolledRowFromWidget(pt.y, this, WID_NS_AVAIL_LIST);
 
				this->active_sel = NULL;
 
				DeleteWindowByClass(WC_GRF_PARAMETERS);
 
				if (i < this->avails.Length()) {
 
				if (i < this->avails.size()) {
 
					if (this->avail_sel != this->avails[i]) DeleteWindowByClass(WC_TEXTFILE);
 
					this->avail_sel = this->avails[i];
 
					this->avail_pos = i;
 
				}
 
				this->InvalidateData();
 
				if (click_count == 1) {
 
@@ -1172,13 +1172,13 @@ struct NewGRFWindow : public Window, New
 
		if (str == NULL) return;
 

	
 
		SaveGRFPresetToConfig(str, this->actives);
 
		GetGRFPresetList(&_grf_preset_list);
 

	
 
		/* Switch to this preset */
 
		for (uint i = 0; i < _grf_preset_list.Length(); i++) {
 
		for (uint i = 0; i < _grf_preset_list.size(); i++) {
 
			if (_grf_preset_list[i] != NULL && strcmp(_grf_preset_list[i], str) == 0) {
 
				this->preset = i;
 
				break;
 
			}
 
		}
 

	
 
@@ -1305,40 +1305,40 @@ struct NewGRFWindow : public Window, New
 
				/* scroll up by one */
 
				if (this->avail_pos > 0) this->avail_pos--;
 
				break;
 

	
 
			case WKC_DOWN:
 
				/* scroll down by one */
 
				if (this->avail_pos < (int)this->avails.Length() - 1) this->avail_pos++;
 
				if (this->avail_pos < (int)this->avails.size() - 1) this->avail_pos++;
 
				break;
 

	
 
			case WKC_PAGEUP:
 
				/* scroll up a page */
 
				this->avail_pos = (this->avail_pos < this->vscroll2->GetCapacity()) ? 0 : this->avail_pos - this->vscroll2->GetCapacity();
 
				break;
 

	
 
			case WKC_PAGEDOWN:
 
				/* scroll down a page */
 
				this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.Length() - 1);
 
				this->avail_pos = min(this->avail_pos + this->vscroll2->GetCapacity(), (int)this->avails.size() - 1);
 
				break;
 

	
 
			case WKC_HOME:
 
				/* jump to beginning */
 
				this->avail_pos = 0;
 
				break;
 

	
 
			case WKC_END:
 
				/* jump to end */
 
				this->avail_pos = this->avails.Length() - 1;
 
				this->avail_pos = this->avails.size() - 1;
 
				break;
 

	
 
			default:
 
				return ES_NOT_HANDLED;
 
		}
 

	
 
		if (this->avails.Length() == 0) this->avail_pos = -1;
 
		if (this->avails.size() == 0) this->avail_pos = -1;
 
		if (this->avail_pos >= 0) {
 
			this->active_sel = NULL;
 
			DeleteWindowByClass(WC_GRF_PARAMETERS);
 
			if (this->avail_sel != this->avails[this->avail_pos]) DeleteWindowByClass(WC_TEXTFILE);
 
			this->avail_sel = this->avails[this->avail_pos];
 
			this->vscroll2->ScrollTowards(this->avail_pos);
 
@@ -1487,13 +1487,13 @@ private:
 

	
 
		if (this->avail_sel != NULL) {
 
			this->avail_pos = this->avails.FindIndex(this->avail_sel);
 
			if (this->avail_pos < 0) this->avail_sel = NULL;
 
		}
 

	
 
		this->vscroll2->SetCount(this->avails.Length()); // Update the scrollbar
 
		this->vscroll2->SetCount(this->avails.size()); // Update the scrollbar
 
	}
 

	
 
	/**
 
	 * Insert a GRF into the active list.
 
	 * @param ins_pos Insert GRF at this position.
 
	 * @return True if the GRF was successfully added.
 
@@ -1528,13 +1528,13 @@ private:
 
		/* Insert GRF config to configuration list. */
 
		c->next = *entry;
 
		*entry = c;
 

	
 
		/* Select next (or previous, if last one) item in the list. */
 
		int new_pos = this->avail_pos + 1;
 
		if (new_pos >= (int)this->avails.Length()) new_pos = this->avail_pos - 1;
 
		if (new_pos >= (int)this->avails.size()) new_pos = this->avail_pos - 1;
 
		this->avail_pos = new_pos;
 
		if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
 

	
 
		this->avails.ForceRebuild();
 
		this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
 
		return true;
 
@@ -1557,13 +1557,13 @@ void ShowMissingContentWindow(const GRFC
 
		ci->state = ContentInfo::DOES_NOT_EXIST;
 
		strecpy(ci->name, c->GetName(), lastof(ci->name));
 
		ci->unique_id = BSWAP32(c->ident.grfid);
 
		memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
 
		*cv.Append() = ci;
 
	}
 
	ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
	ShowNetworkContentListWindow(cv.size() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
}
 

	
 
Listing NewGRFWindow::last_sorting     = {false, 0};
 
Filtering NewGRFWindow::last_filtering = {false, 0};
 

	
 
NewGRFWindow::GUIGRFConfigList::SortFunction * const NewGRFWindow::sorter_funcs[] = {
 
@@ -2046,13 +2046,13 @@ struct SavePresetWindow : public Window 
 
	 */
 
	SavePresetWindow(const char *initial_text) : Window(&_save_preset_desc), presetname_editbox(32)
 
	{
 
		GetGRFPresetList(&this->presets);
 
		this->selected = -1;
 
		if (initial_text != NULL) {
 
			for (uint i = 0; i < this->presets.Length(); i++) {
 
			for (uint i = 0; i < this->presets.size(); i++) {
 
				if (!strcmp(initial_text, this->presets[i])) {
 
					this->selected = i;
 
					break;
 
				}
 
			}
 
		}
 
@@ -2062,13 +2062,13 @@ struct SavePresetWindow : public Window 
 
		this->presetname_editbox.cancel_button = WID_SVP_CANCEL;
 

	
 
		this->CreateNestedTree();
 
		this->vscroll = this->GetScrollbar(WID_SVP_SCROLLBAR);
 
		this->FinishInitNested(0);
 

	
 
		this->vscroll->SetCount(this->presets.Length());
 
		this->vscroll->SetCount(this->presets.size());
 
		this->SetFocusedWidget(WID_SVP_EDITBOX);
 
		if (initial_text != NULL) this->presetname_editbox.text.Assign(initial_text);
 
	}
 

	
 
	~SavePresetWindow()
 
	{
 
@@ -2077,18 +2077,18 @@ struct SavePresetWindow : public Window 
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				resize->height = FONT_HEIGHT_NORMAL + 2U;
 
				size->height = 0;
 
				for (uint i = 0; i < this->presets.Length(); i++) {
 
				for (uint i = 0; i < this->presets.size(); i++) {
 
					Dimension d = GetStringBoundingBox(this->presets[i]);
 
					size->width = max(size->width, d.width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
 
					resize->height = max(resize->height, d.height);
 
				}
 
				size->height = ClampU(this->presets.Length(), 5, 20) * resize->height + 1;
 
				size->height = ClampU(this->presets.size(), 5, 20) * resize->height + 1;
 
				break;
 
			}
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -2098,13 +2098,13 @@ struct SavePresetWindow : public Window 
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 

	
 
				uint step_height = this->GetWidget<NWidgetBase>(WID_SVP_PRESET_LIST)->resize_y;
 
				int offset_y = (step_height - FONT_HEIGHT_NORMAL) / 2;
 
				uint y = r.top + WD_FRAMERECT_TOP;
 
				uint min_index = this->vscroll->GetPosition();
 
				uint max_index = min(min_index + this->vscroll->GetCapacity(), this->presets.Length());
 
				uint max_index = min(min_index + this->vscroll->GetCapacity(), this->presets.size());
 

	
 
				for (uint i = min_index; i < max_index; i++) {
 
					if ((int)i == this->selected) GfxFillRect(r.left + 1, y, r.right - 1, y + step_height - 2, PC_DARK_BLUE);
 

	
 
					const char *text = this->presets[i];
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y + offset_y, text, ((int)i == this->selected) ? TC_WHITE : TC_SILVER);
 
@@ -2117,13 +2117,13 @@ struct SavePresetWindow : public Window 
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_SVP_PRESET_LIST: {
 
				uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SVP_PRESET_LIST);
 
				if (row < this->presets.Length()) {
 
				if (row < this->presets.size()) {
 
					this->selected = row;
 
					this->presetname_editbox.text.Assign(this->presets[row]);
 
					this->SetWidgetDirty(WID_SVP_PRESET_LIST);
 
					this->SetWidgetDirty(WID_SVP_EDITBOX);
 
				}
 
				break;
src/newgrf_railtype.cpp
Show inline comments
 
@@ -136,13 +136,13 @@ SpriteID GetCustomSignalSprite(const Rai
 
 * @param grffile The GRF to do the lookup for.
 
 * @return the GRF internal ID.
 
 */
 
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
 
{
 
	/* No rail type table present, return rail type as-is */
 
	if (grffile == NULL || grffile->railtype_list.Length() == 0) return railtype;
 
	if (grffile == NULL || grffile->railtype_list.size() == 0) return railtype;
 

	
 
	/* Look for a matching rail type label in the table */
 
	RailTypeLabel label = GetRailTypeInfo(railtype)->label;
 
	int index = grffile->railtype_list.FindIndex(label);
 
	if (index >= 0) return index;
 

	
src/newgrf_sound.cpp
Show inline comments
 
@@ -46,20 +46,20 @@ void InitializeSoundPool()
 
	SndCopyToPool();
 
}
 

	
 

	
 
SoundEntry *GetSound(SoundID index)
 
{
 
	if (index >= _sounds.Length()) return NULL;
 
	if (index >= _sounds.size()) return NULL;
 
	return &_sounds[index];
 
}
 

	
 

	
 
uint GetNumSounds()
 
{
 
	return _sounds.Length();
 
	return _sounds.size();
 
}
 

	
 

	
 
/**
 
 * Extract meta data from a NewGRF sound.
 
 * @param sound Sound to load.
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -82,13 +82,13 @@ public:
 
			}
 
			CFRelease(line);
 
		}
 

	
 
		virtual int GetLeading() const;
 
		virtual int GetWidth() const;
 
		virtual int CountRuns() const { return this->Length();  }
 
		virtual int CountRuns() const { return this->size();  }
 
		virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run);  }
 

	
 
		int GetInternalCharLength(WChar c) const
 
		{
 
			/* CoreText uses UTF-16 internally which means we need to account for surrogate pairs. */
 
			return c >= 0x010000U ? 2 : 1;
 
@@ -253,13 +253,13 @@ int CoreTextParagraphLayout::CoreTextLin
 
/**
 
 * Get the width of this line.
 
 * @return The width of the line.
 
 */
 
int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
 
{
 
	if (this->Length() == 0) return 0;
 
	if (this->size() == 0) return 0;
 

	
 
	int total_width = 0;
 
	for (const CoreTextVisualRun * const *run = this->Begin(); run != this->End(); run++) {
 
		total_width += (*run)->GetAdvance();
 
	}
 

	
src/os/windows/string_uniscribe.cpp
Show inline comments
 
@@ -107,13 +107,13 @@ public:
 

	
 
	/** A single line worth of VisualRuns. */
 
	class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *, 4>, public ParagraphLayouter::Line {
 
	public:
 
		virtual int GetLeading() const;
 
		virtual int GetWidth() const;
 
		virtual int CountRuns() const { return this->Length();  }
 
		virtual int CountRuns() const { return this->size();  }
 
		virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run);  }
 

	
 
		int GetInternalCharLength(WChar c) const
 
		{
 
			/* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */
 
			return c >= 0x010000U ? 2 : 1;
src/rail_cmd.cpp
Show inline comments
 
@@ -1744,13 +1744,13 @@ CommandCost CmdConvertRail(TileIndex til
 
				}
 

	
 
				cost.AddCost(RailConvertCost(type, totype));
 
				break;
 
		}
 

	
 
		for (uint i = 0; i < vehicles_affected.Length(); ++i) {
 
		for (uint i = 0; i < vehicles_affected.size(); ++i) {
 
			TryPathReserve(vehicles_affected[i], true);
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* Railtype changed, update trains as when entering different track */
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -22,14 +22,14 @@ extern SmallVector<TileIndex, 256> _anim
 

	
 
/**
 
 * Save the ANIT chunk.
 
 */
 
static void Save_ANIT()
 
{
 
	SlSetLength(_animated_tiles.Length() * sizeof(*_animated_tiles.Begin()));
 
	SlArray(_animated_tiles.Begin(), _animated_tiles.Length(), SLE_UINT32);
 
	SlSetLength(_animated_tiles.size() * sizeof(*_animated_tiles.Begin()));
 
	SlArray(_animated_tiles.Begin(), _animated_tiles.size(), SLE_UINT32);
 
}
 

	
 
/**
 
 * Load the ANIT chunk; the chunk containing the animated tiles.
 
 */
 
static void Load_ANIT()
src/saveload/game_sl.cpp
Show inline comments
 
@@ -129,13 +129,13 @@ static const SaveLoad _game_language_str
 
	 SLE_END()
 
};
 

	
 
static void SaveReal_GSTR(LanguageStrings *ls)
 
{
 
	_game_saveload_string  = ls->language;
 
	_game_saveload_strings = ls->lines.Length();
 
	_game_saveload_strings = ls->lines.size();
 

	
 
	SlObject(NULL, _game_language_header);
 
	for (uint i = 0; i < _game_saveload_strings; i++) {
 
		_game_saveload_string = ls->lines[i];
 
		SlObject(NULL, _game_language_string);
 
	}
 
@@ -157,13 +157,13 @@ static void Load_GSTR()
 
		}
 

	
 
		*_current_data->raw_strings.Append() = ls;
 
	}
 

	
 
	/* If there were no strings in the savegame, set GameStrings to NULL */
 
	if (_current_data->raw_strings.Length() == 0) {
 
	if (_current_data->raw_strings.size() == 0) {
 
		delete _current_data;
 
		_current_data = NULL;
 
		return;
 
	}
 

	
 
	_current_data->Compile();
 
@@ -171,13 +171,13 @@ static void Load_GSTR()
 
}
 

	
 
static void Save_GSTR()
 
{
 
	if (_current_data == NULL) return;
 

	
 
	for (uint i = 0; i < _current_data->raw_strings.Length(); i++) {
 
	for (uint i = 0; i < _current_data->raw_strings.size(); i++) {
 
		SlSetArrayIndex(i);
 
		SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]);
 
	}
 
}
 

	
 
extern const ChunkHandler _game_chunk_handlers[] = {
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -23,13 +23,13 @@ static SmallVector<RailTypeLabel, RAILTY
 
 * Test if any saved rail type labels are different to the currently loaded
 
 * rail types, which therefore requires conversion.
 
 * @return true if (and only if) conversion due to rail type changes is needed.
 
 */
 
static bool NeedRailTypeConversion()
 
{
 
	for (uint i = 0; i < _railtype_list.Length(); i++) {
 
	for (uint i = 0; i < _railtype_list.size(); i++) {
 
		if ((RailType)i < RAILTYPE_END) {
 
			const RailtypeInfo *rti = GetRailTypeInfo((RailType)i);
 
			if (rti->label != _railtype_list[i]) return true;
 
		} else {
 
			if (_railtype_list[i] != 0) return true;
 
		}
 
@@ -41,13 +41,13 @@ static bool NeedRailTypeConversion()
 

	
 
void AfterLoadLabelMaps()
 
{
 
	if (NeedRailTypeConversion()) {
 
		SmallVector<RailType, RAILTYPE_END> railtype_conversion_map;
 

	
 
		for (uint i = 0; i < _railtype_list.Length(); i++) {
 
		for (uint i = 0; i < _railtype_list.size(); i++) {
 
			RailType r = GetRailTypeByLabel(_railtype_list[i]);
 
			if (r == INVALID_RAILTYPE) r = RAILTYPE_BEGIN;
 

	
 
			*railtype_conversion_map.Append() = r;
 
		}
 

	
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -52,13 +52,13 @@ const SaveLoad *GetLinkGraphDesc()
 
const SaveLoad *GetLinkGraphJobDesc()
 
{
 
	static SmallVector<SaveLoad, 16> saveloads;
 
	static const char *prefix = "linkgraph.";
 

	
 
	/* Build the SaveLoad array on first call and don't touch it later on */
 
	if (saveloads.Length() == 0) {
 
	if (saveloads.size() == 0) {
 
		size_t offset_gamesettings = cpp_offsetof(GameSettings, linkgraph);
 
		size_t offset_component = cpp_offsetof(LinkGraphJob, settings);
 

	
 
		size_t prefixlen = strlen(prefix);
 

	
 
		int setting = 0;
 
@@ -80,13 +80,13 @@ const SaveLoad *GetLinkGraphJobDesc()
 
			SLE_END()
 
		};
 

	
 
		int i = 0;
 
		do {
 
			*(saveloads.Append()) = job_desc[i++];
 
		} while (saveloads[saveloads.Length() - 1].cmd != SL_END);
 
		} while (saveloads[saveloads.size() - 1].cmd != SL_END);
 
	}
 

	
 
	return &saveloads[0];
 
}
 

	
 
/**
src/saveload/saveload.cpp
Show inline comments
 
@@ -172,13 +172,13 @@ struct MemoryDumper {
 
	/**
 
	 * Get the size of the memory dump made so far.
 
	 * @return The size.
 
	 */
 
	size_t GetSize() const
 
	{
 
		return this->blocks.Length() * MEMORY_CHUNK_SIZE - (this->bufe - this->buf);
 
		return this->blocks.size() * MEMORY_CHUNK_SIZE - (this->bufe - this->buf);
 
	}
 
};
 

	
 
/** The saveload struct, containing reader-writer functions, buffer, version, etc. */
 
struct SaveLoadParams {
 
	SaveLoadAction action;               ///< are we doing a save or a load atm.
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -93,13 +93,13 @@ void MoveWaypointsToBaseStations()
 
					break;
 
				}
 
			}
 
		}
 
	}
 

	
 
	if (!Waypoint::CanAllocateItem(_old_waypoints.Length())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING);
 
	if (!Waypoint::CanAllocateItem(_old_waypoints.size())) SlError(STR_ERROR_TOO_MANY_STATIONS_LOADING);
 

	
 
	/* All saveload conversions have been done. Create the new waypoints! */
 
	for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) {
 
		Waypoint *new_wp = new Waypoint(wp->xy);
 
		new_wp->town       = wp->town;
 
		new_wp->town_cn    = wp->town_cn;
src/script/squirrel_helper.hpp
Show inline comments
 
@@ -144,15 +144,15 @@ namespace SQConvert {
 
			}
 

	
 
			sq_pop(vm, 2);
 
		}
 
		sq_pop(vm, 2);
 

	
 
		Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.Length());
 
		arr->size = data.Length();
 
		memcpy(arr->array, data.Begin(), sizeof(int32) * data.Length());
 
		Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.size());
 
		arr->size = data.size();
 
		memcpy(arr->array, data.Begin(), sizeof(int32) * data.size());
 

	
 
		*ptr->Append() = arr;
 
		return arr;
 
	}
 

	
 
	/**
src/settings_gui.cpp
Show inline comments
 
@@ -212,13 +212,13 @@ struct GameOptionsWindow : Window {
 

	
 
				/* Add non-custom currencies; sorted naturally */
 
				for (uint i = 0; i < CURRENCY_END; items++, i++) {
 
					if (i == CURRENCY_CUSTOM) continue;
 
					*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
 
				}
 
				QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
 
				QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
 

	
 
				/* Append custom currency at the end */
 
				*list->Append() = new DropDownListItem(-1, false); // separator line
 
				*list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM));
 
				break;
 
			}
 
@@ -250,26 +250,26 @@ struct GameOptionsWindow : Window {
 

	
 
				/* Add and sort newgrf townnames generators */
 
				for (int i = 0; i < _nb_grf_names; i++) {
 
					int result = _nb_orig_names + i;
 
					*list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0);
 
				}
 
				QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
 
				QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
 

	
 
				int newgrf_size = list->Length();
 
				int newgrf_size = list->size();
 
				/* Insert newgrf_names at the top of the list */
 
				if (newgrf_size > 0) {
 
					*list->Append() = new DropDownListItem(-1, false); // separator line
 
					newgrf_size++;
 
				}
 

	
 
				/* Add and sort original townnames generators */
 
				for (int i = 0; i < _nb_orig_names; i++) {
 
					*list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0);
 
				}
 
				QSortT(list->Begin() + newgrf_size, list->Length() - newgrf_size, DropDownListStringItem::NatSortFunc);
 
				QSortT(list->Begin() + newgrf_size, list->size() - newgrf_size, DropDownListStringItem::NatSortFunc);
 
				break;
 
			}
 

	
 
			case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
 
				list = new DropDownList();
 
				*selected_index = _settings_client.gui.autosave;
 
@@ -279,17 +279,17 @@ struct GameOptionsWindow : Window {
 
				}
 
				break;
 
			}
 

	
 
			case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
 
				list = new DropDownList();
 
				for (uint i = 0; i < _languages.Length(); i++) {
 
				for (uint i = 0; i < _languages.size(); i++) {
 
					if (&_languages[i] == _current_language) *selected_index = i;
 
					*list->Append() = new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false);
 
				}
 
				QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
 
				QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
 
				break;
 
			}
 

	
 
			case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
 
				if (_num_resolutions == 0) break;
 

	
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -113,13 +113,13 @@ public:
 
	 */
 
	void Add(const char *text, int length = 0)
 
	{
 
		if (length == 0) length = strlen(text);
 

	
 
		if (length > 0 && this->BufferHasRoom()) {
 
			int stored_size = this->output_buffer[this->output_buffer.Length() - 1].Add(text, length);
 
			int stored_size = this->output_buffer[this->output_buffer.size() - 1].Add(text, length);
 
			length -= stored_size;
 
			text += stored_size;
 
		}
 
		while (length > 0) {
 
			OutputBuffer *block = this->output_buffer.Append();
 
			block->Clear(); // Initialize the new block.
 
@@ -144,13 +144,13 @@ private:
 
	/**
 
	 * Does the buffer have room without adding a new #OutputBuffer block?
 
	 * @return \c true if room is available, else \c false.
 
	 */
 
	bool BufferHasRoom() const
 
	{
 
		uint num_blocks = this->output_buffer.Length();
 
		uint num_blocks = this->output_buffer.size();
 
		return num_blocks > 0 && this->output_buffer[num_blocks - 1].HasRoom();
 
	}
 

	
 
	typedef SmallVector<OutputBuffer, 2> OutputBufferVector; ///< Vector type for output buffers.
 
	OutputBufferVector output_buffer; ///< Vector of blocks containing the stored output.
 
};
src/signs_gui.cpp
Show inline comments
 
@@ -243,13 +243,13 @@ struct SignListWindow : Window, SignList
 
				const Sign *si = this->signs[id_v];
 
				ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
 
				break;
 
			}
 

	
 
			case WID_SIL_FILTER_ENTER_BTN:
 
				if (this->signs.Length() >= 1) {
 
				if (this->signs.size() >= 1) {
 
					const Sign *si = this->signs[0];
 
					ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
 
				}
 
				break;
 

	
 
			case WID_SIL_FILTER_MATCH_CASE_BTN:
 
@@ -307,13 +307,13 @@ struct SignListWindow : Window, SignList
 
	}
 

	
 
	void BuildSortSignList()
 
	{
 
		if (this->signs.NeedRebuild()) {
 
			this->BuildSignsList();
 
			this->vscroll->SetCount(this->signs.Length());
 
			this->vscroll->SetCount(this->signs.size());
 
			this->SetWidgetDirty(WID_SIL_CAPTION);
 
		}
 
		this->SortSignsList();
 
	}
 

	
 
	void OnHundredthTick() override
 
@@ -468,21 +468,21 @@ struct SignWindow : Window, SignList {
 
		this->BuildSignsList();
 
		this->SortSignsList();
 

	
 
		/* Search through the list for the current sign, excluding
 
		 * - the first sign if we want the previous sign or
 
		 * - the last sign if we want the next sign */
 
		uint end = this->signs.Length() - (next ? 1 : 0);
 
		uint end = this->signs.size() - (next ? 1 : 0);
 
		for (uint i = next ? 0 : 1; i < end; i++) {
 
			if (this->cur_sign == this->signs[i]->index) {
 
				/* We've found the current sign, so return the sign before/after it */
 
				return this->signs[i + (next ? 1 : -1)];
 
			}
 
		}
 
		/* If we haven't found the current sign by now, return the last/first sign */
 
		return this->signs[next ? 0 : this->signs.Length() - 1];
 
		return next ? this->signs.front() : this->signs.back();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_QES_CAPTION:
src/station_cmd.cpp
Show inline comments
 
@@ -1433,13 +1433,13 @@ CommandCost CmdBuildRailStation(TileInde
 
			} while (--w);
 
			AddTrackToSignalBuffer(tile_track, track, _current_company);
 
			YapfNotifyTrackLayoutChange(tile_track, track);
 
			tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
 
		} while (--numtracks);
 

	
 
		for (uint i = 0; i < affected_vehicles.Length(); ++i) {
 
		for (uint i = 0; i < affected_vehicles.size(); ++i) {
 
			/* Restore reservations of trains. */
 
			RestoreTrainReservation(affected_vehicles[i]);
 
		}
 

	
 
		/* Check whether we need to expand the reservation of trains already on the station. */
 
		TileArea update_reservation_area;
src/station_gui.cpp
Show inline comments
 
@@ -202,13 +202,13 @@ protected:
 
			}
 
		}
 

	
 
		this->stations.shrink_to_fit();
 
		this->stations.RebuildDone();
 

	
 
		this->vscroll->SetCount(this->stations.Length()); // Update the scrollbar
 
		this->vscroll->SetCount(this->stations.size()); // Update the scrollbar
 
	}
 

	
 
	/** Sort stations by their name */
 
	static int CDECL StationNameSorter(const Station * const *a, const Station * const *b)
 
	{
 
		static char buf_cache[64];
 
@@ -408,13 +408,13 @@ public:
 
				/* draw arrow pointing up/down for ascending/descending sorting */
 
				this->DrawSortButtonState(WID_STL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
			case WID_STL_LIST: {
 
				bool rtl = _current_text_dir == TD_RTL;
 
				int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length());
 
				int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
 
					const Station *st = this->stations[i];
 
					assert(st->xy != INVALID_TILE);
 

	
 
					/* Do not do the complex check HasStationInUse here, it may be even false
 
@@ -495,13 +495,13 @@ public:
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
 
		switch (widget) {
 
			case WID_STL_LIST: {
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
 
				if (id_v >= this->stations.Length()) return; // click out of list bound
 
				if (id_v >= this->stations.size()) return; // click out of list bound
 

	
 
				const Station *st = this->stations[id_v];
 
				/* do not check HasStationInUse - it is slow and may be invalid */
 
				assert(st->owner == (Owner)this->window_number || st->owner == OWNER_NONE);
 

	
 
				if (_ctrl_pressed) {
 
@@ -2129,13 +2129,13 @@ static SmallVector<StationID, 8> _statio
 
template <class T>
 
static bool AddNearbyStation(TileIndex tile, void *user_data)
 
{
 
	TileArea *ctx = (TileArea *)user_data;
 

	
 
	/* First check if there were deleted stations here */
 
	for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
 
	for (uint i = 0; i < _deleted_stations_nearby.size(); i++) {
 
		TileAndStation *ts = _deleted_stations_nearby.Get(i);
 
		if (ts->tile == tile) {
 
			*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
 
			_deleted_stations_nearby.Erase(ts);
 
			i--;
 
		}
 
@@ -2252,13 +2252,13 @@ struct SelectStationWindow : Window {
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		if (widget != WID_JS_PANEL) return;
 

	
 
		/* Determine the widest string */
 
		Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
 
		for (uint i = 0; i < _stations_nearby_list.Length(); i++) {
 
		for (uint i = 0; i < _stations_nearby_list.size(); i++) {
 
			const T *st = T::Get(_stations_nearby_list[i]);
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
			d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION));
 
		}
 

	
 
@@ -2276,13 +2276,13 @@ struct SelectStationWindow : Window {
 
		uint y = r.top + WD_FRAMERECT_TOP;
 
		if (this->vscroll->GetPosition() == 0) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
 
			y += this->resize.step_height;
 
		}
 

	
 
		for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += this->resize.step_height) {
 
		for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) {
 
			/* Don't draw anything if it extends past the end of the window. */
 
			if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
 

	
 
			const T *st = T::Get(_stations_nearby_list[i - 1]);
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
@@ -2295,13 +2295,13 @@ struct SelectStationWindow : Window {
 
		if (widget != WID_JS_PANEL) return;
 

	
 
		uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WD_FRAMERECT_TOP);
 
		bool distant_join = (st_index > 0);
 
		if (distant_join) st_index--;
 

	
 
		if (distant_join && st_index >= _stations_nearby_list.Length()) return;
 
		if (distant_join && st_index >= _stations_nearby_list.size()) return;
 

	
 
		/* Insert station to be joined into stored command */
 
		SB(this->select_station_cmd.p2, 16, 16,
 
		   (distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
 

	
 
		/* Execute stored Command */
 
@@ -2330,13 +2330,13 @@ struct SelectStationWindow : Window {
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
	{
 
		if (!gui_scope) return;
 
		FindStationsNearby<T>(this->area, true);
 
		this->vscroll->SetCount(_stations_nearby_list.Length() + 1);
 
		this->vscroll->SetCount(_stations_nearby_list.size() + 1);
 
		this->SetDirty();
 
	}
 
};
 

	
 
static WindowDesc _select_station_desc(
 
	WDP_AUTO, "build_station_join", 200, 180,
 
@@ -2375,13 +2375,13 @@ static bool StationJoinerNeeded(const Co
 
	if (DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))).Failed()) return false;
 

	
 
	/* Test for adjacent station or station below selection.
 
	 * If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
 
	 * but join the other station immediately. */
 
	const T *st = FindStationsNearby<T>(ta, false);
 
	return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0);
 
	return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.size() == 0);
 
}
 

	
 
/**
 
 * Show the station selection window when needed. If not, build the station.
 
 * @param cmd Command to build the station.
 
 * @param ta Area to build the station in
src/story_gui.cpp
Show inline comments
 
@@ -156,13 +156,13 @@ protected:
 
	 */
 
	bool IsLastPageSelected()
 
	{
 
		/* Verify that the selected page exist. */
 
		if (!_story_page_pool.IsValidID(this->selected_page_id)) return false;
 

	
 
		if (this->story_pages.Length() <= 1) return true;
 
		if (this->story_pages.size() <= 1) return true;
 
		const StoryPage *last = *(this->story_pages.End() - 1);
 
		return last->index == this->selected_page_id;
 
	}
 

	
 
	/**
 
	 * Updates the content of selected page.
 
@@ -250,13 +250,13 @@ protected:
 

	
 
			*list->Append() = item;
 
			page_num++;
 
		}
 

	
 
		/* Check if list is empty. */
 
		if (list->Length() == 0) {
 
		if (list->size() == 0) {
 
			delete list;
 
			list = NULL;
 
		}
 

	
 
		return list;
 
	}
 
@@ -441,14 +441,14 @@ public:
 

	
 
	/**
 
	 * Updates the disabled state of the prev/next buttons.
 
	 */
 
	void UpdatePrevNextDisabledState()
 
	{
 
		this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.Length() == 0 || this->IsFirstPageSelected());
 
		this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.Length() == 0 || this->IsLastPageSelected());
 
		this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.size() == 0 || this->IsFirstPageSelected());
 
		this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.size() == 0 || this->IsLastPageSelected());
 
		this->SetWidgetDirty(WID_SB_PREV_PAGE);
 
		this->SetWidgetDirty(WID_SB_NEXT_PAGE);
 
	}
 

	
 
	/**
 
	 * Sets the selected page.
 
@@ -572,13 +572,13 @@ public:
 
		d.width = 0;
 

	
 
		switch (widget) {
 
			case WID_SB_SEL_PAGE: {
 

	
 
				/* Get max title width. */
 
				for (uint16 i = 0; i < this->story_pages.Length(); i++) {
 
				for (uint16 i = 0; i < this->story_pages.size(); i++) {
 
					const StoryPage *s = this->story_pages[i];
 

	
 
					if (s->title != NULL) {
 
						SetDParamStr(0, s->title);
 
					} else {
 
						SetDParamStr(0, this->selected_generic_title);
 
@@ -617,13 +617,13 @@ public:
 
		switch (widget) {
 
			case WID_SB_SEL_PAGE: {
 
				DropDownList *list = this->BuildDropDownList();
 
				if (list != NULL) {
 
					/* Get the index of selected page. */
 
					int selected = 0;
 
					for (uint16 i = 0; i < this->story_pages.Length(); i++) {
 
					for (uint16 i = 0; i < this->story_pages.size(); i++) {
 
						const StoryPage *p = this->story_pages[i];
 
						if (p->index == this->selected_page_id) break;
 
						selected++;
 
					}
 

	
 
					ShowDropDownList(this, list, selected, widget);
 
@@ -691,28 +691,28 @@ public:
 
		 */
 
		if (data == -1) {
 
			this->story_pages.ForceRebuild();
 
			this->BuildStoryPageList();
 

	
 
			/* Was the last page removed? */
 
			if (this->story_pages.Length() == 0) {
 
			if (this->story_pages.size() == 0) {
 
				this->selected_generic_title[0] = '\0';
 
			}
 

	
 
			/* Verify page selection. */
 
			if (!_story_page_pool.IsValidID(this->selected_page_id)) {
 
				this->selected_page_id = INVALID_STORY_PAGE;
 
			}
 
			if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.Length() > 0) {
 
			if (this->selected_page_id == INVALID_STORY_PAGE && this->story_pages.size() > 0) {
 
				/* No page is selected, but there exist at least one available.
 
				 * => Select first page.
 
				 */
 
				this->SetSelectedPage(this->story_pages[0]->index);
 
			}
 

	
 
			this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.Length() == 0);
 
			this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.size() == 0);
 
			this->SetWidgetDirty(WID_SB_SEL_PAGE);
 
			this->UpdatePrevNextDisabledState();
 
		} else if (data >= 0 && this->selected_page_id == data) {
 
			this->RefreshSelectedPage();
 
		}
 
	}
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -1026,27 +1026,27 @@ void LanguageWriter::WriteLang(const Str
 
				buffer.AppendByte(num);
 

	
 
				/* Write each case */
 
				for (c = casep; c != NULL; c = c->next) {
 
					buffer.AppendByte(c->caseidx);
 
					/* Make some space for the 16-bit length */
 
					uint pos = buffer.Length();
 
					uint pos = buffer.size();
 
					buffer.AppendByte(0);
 
					buffer.AppendByte(0);
 
					/* Write string */
 
					PutCommandString(&buffer, c->string);
 
					buffer.AppendByte(0); // terminate with a zero
 
					/* Fill in the length */
 
					uint size = buffer.Length() - (pos + 2);
 
					uint size = buffer.size() - (pos + 2);
 
					buffer[pos + 0] = GB(size, 8, 8);
 
					buffer[pos + 1] = GB(size, 0, 8);
 
				}
 
			}
 

	
 
			if (cmdp != NULL) PutCommandString(&buffer, cmdp);
 

	
 
			this->WriteLength(buffer.Length());
 
			this->Write(buffer.Begin(), buffer.Length());
 
			this->WriteLength(buffer.size());
 
			this->Write(buffer.Begin(), buffer.size());
 
			buffer.clear();
 
		}
 
	}
 
}
src/string.cpp
Show inline comments
 
@@ -671,24 +671,24 @@ public:
 
		}
 
		*this->utf16_str.Append() = '\0';
 
		*this->utf16_to_utf8.Append() = s - string_base;
 

	
 
		UText text = UTEXT_INITIALIZER;
 
		UErrorCode status = U_ZERO_ERROR;
 
		utext_openUChars(&text, this->utf16_str.Begin(), this->utf16_str.Length() - 1, &status);
 
		utext_openUChars(&text, this->utf16_str.Begin(), this->utf16_str.size() - 1, &status);
 
		this->char_itr->setText(&text, status);
 
		this->word_itr->setText(&text, status);
 
		this->char_itr->first();
 
		this->word_itr->first();
 
	}
 

	
 
	virtual size_t SetCurPosition(size_t pos)
 
	{
 
		/* Convert incoming position to an UTF-16 string index. */
 
		uint utf16_pos = 0;
 
		for (uint i = 0; i < this->utf16_to_utf8.Length(); i++) {
 
		for (uint i = 0; i < this->utf16_to_utf8.size(); i++) {
 
			if (this->utf16_to_utf8[i] == pos) {
 
				utf16_pos = i;
 
				break;
 
			}
 
		}
 

	
src/stringfilter_type.h
Show inline comments
 
@@ -55,20 +55,20 @@ public:
 
	void SetFilterTerm(const char *str);
 

	
 
	/**
 
	 * Check whether any filter words were entered.
 
	 * @return true if no words were entered.
 
	 */
 
	bool IsEmpty() const { return this->word_index.Length() == 0; }
 
	bool IsEmpty() const { return this->word_index.size() == 0; }
 

	
 
	void ResetState();
 
	void AddLine(const char *str);
 
	void AddLine(StringID str);
 

	
 
	/**
 
	 * Get the matching state of the current item.
 
	 * @return true if matched.
 
	 */
 
	bool GetState() const { return this->word_matches == this->word_index.Length(); }
 
	bool GetState() const { return this->word_matches == this->word_index.size(); }
 
};
 

	
 
#endif /* STRINGFILTER_TYPE_H */
src/strings.cpp
Show inline comments
 
@@ -1949,13 +1949,13 @@ void InitializeLanguagePacks()
 

	
 
	FOR_ALL_SEARCHPATHS(sp) {
 
		char path[MAX_PATH];
 
		FioAppendDirectory(path, lastof(path), sp, LANG_DIR);
 
		GetLanguageList(path);
 
	}
 
	if (_languages.Length() == 0) usererror("No available language packs (invalid versions?)");
 
	if (_languages.size() == 0) usererror("No available language packs (invalid versions?)");
 

	
 
	/* Acquire the locale of the current system */
 
	const char *lang = GetCurrentLocale("LC_MESSAGES");
 
	if (lang == NULL) lang = "en_GB";
 

	
 
	const LanguageMetadata *chosen_language   = NULL; ///< Matching the language in the configuration file or the current locale
src/texteff.cpp
Show inline comments
 
@@ -42,16 +42,16 @@ static SmallVector<struct TextEffect, 32
 
/* Text Effects */
 
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
 
{
 
	if (_game_mode == GM_MENU) return INVALID_TE_ID;
 

	
 
	TextEffectID i;
 
	for (i = 0; i < _text_effects.Length(); i++) {
 
	for (i = 0; i < _text_effects.size(); i++) {
 
		if (_text_effects[i].string_id == INVALID_STRING_ID) break;
 
	}
 
	if (i == _text_effects.Length()) _text_effects.Append();
 
	if (i == _text_effects.size()) _text_effects.Append();
 

	
 
	TextEffect *te = _text_effects.Get(i);
 

	
 
	/* Start defining this object */
 
	te->string_id = msg;
 
	te->duration = duration;
src/textfile_gui.cpp
Show inline comments
 
@@ -83,13 +83,13 @@ TextfileWindow::TextfileWindow(TextfileT
 
 */
 
uint TextfileWindow::GetContentHeight()
 
{
 
	int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
 

	
 
	uint height = 0;
 
	for (uint i = 0; i < this->lines.Length(); i++) {
 
	for (uint i = 0; i < this->lines.size(); i++) {
 
		height += GetStringHeight(this->lines[i], max_width, FS_MONO);
 
	}
 

	
 
	return height;
 
}
 

	
 
@@ -110,16 +110,16 @@ void TextfileWindow::SetupScrollbars()
 
{
 
	if (IsWidgetLowered(WID_TF_WRAPTEXT)) {
 
		this->vscroll->SetCount(this->GetContentHeight());
 
		this->hscroll->SetCount(0);
 
	} else {
 
		uint max_length = 0;
 
		for (uint i = 0; i < this->lines.Length(); i++) {
 
		for (uint i = 0; i < this->lines.size(); i++) {
 
			max_length = max(max_length, GetStringBoundingBox(this->lines[i], FS_MONO).width);
 
		}
 
		this->vscroll->SetCount(this->lines.Length() * FONT_HEIGHT_MONO);
 
		this->vscroll->SetCount(this->lines.size() * FONT_HEIGHT_MONO);
 
		this->hscroll->SetCount(max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
 
	}
 

	
 
	this->SetWidgetDisabledState(WID_TF_HSCROLLBAR, IsWidgetLowered(WID_TF_WRAPTEXT));
 
}
 

	
 
@@ -149,13 +149,13 @@ void TextfileWindow::SetupScrollbars()
 
	_cur_dpi = &new_dpi;
 

	
 
	/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
 
	int line_height = FONT_HEIGHT_MONO;
 
	int y_offset = -this->vscroll->GetPosition();
 

	
 
	for (uint i = 0; i < this->lines.Length(); i++) {
 
	for (uint i = 0; i < this->lines.size(); i++) {
 
		if (IsWidgetLowered(WID_TF_WRAPTEXT)) {
 
			y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
		} else {
 
			DrawString(-this->hscroll->GetPosition(), right - x, y_offset, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
 
			y_offset += line_height; // margin to previous element
 
		}
 
@@ -181,13 +181,13 @@ void TextfileWindow::SetupScrollbars()
 
{
 
	return FS_MONO;
 
}
 

	
 
/* virtual */ const char *TextfileWindow::NextString()
 
{
 
	if (this->search_iterator >= this->lines.Length()) return NULL;
 
	if (this->search_iterator >= this->lines.size()) return NULL;
 

	
 
	return this->lines[this->search_iterator++];
 
}
 

	
 
/* virtual */ bool TextfileWindow::Monospace()
 
{
src/timetable_cmd.cpp
Show inline comments
 
@@ -289,16 +289,16 @@ CommandCost CmdSetTimetableStart(TileInd
 
			}
 
		} else {
 
			*vehs.Append() = v;
 
		}
 

	
 
		int total_duration = v->orders.list->GetTimetableTotalDuration();
 
		int num_vehs = vehs.Length();
 
		int num_vehs = vehs.size();
 

	
 
		if (num_vehs >= 2) {
 
			QSortT(vehs.Begin(), vehs.Length(), &VehicleTimetableSorter);
 
			QSortT(vehs.Begin(), vehs.size(), &VehicleTimetableSorter);
 
		}
 

	
 
		int base = vehs.FindIndex(v);
 

	
 
		for (Vehicle **viter = vehs.Begin(); viter != vehs.End(); viter++) {
 
			int idx = (viter - vehs.Begin()) - base;
src/town_gui.cpp
Show inline comments
 
@@ -656,13 +656,13 @@ private:
 
			FOR_ALL_TOWNS(t) {
 
				*this->towns.Append() = t;
 
			}
 

	
 
			this->towns.shrink_to_fit();
 
			this->towns.RebuildDone();
 
			this->vscroll->SetCount(this->towns.Length()); // Update scrollbar as well.
 
			this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well.
 
		}
 
		/* Always sort the towns. */
 
		this->last_town = NULL;
 
		this->towns.Sort();
 
		this->SetWidgetDirty(WID_TD_LIST); // Force repaint of the displayed towns.
 
	}
 
@@ -763,25 +763,25 @@ public:
 
				this->DrawSortButtonState(widget, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 

	
 
			case WID_TD_LIST: {
 
				int n = 0;
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				if (this->towns.Length() == 0) { // No towns available.
 
				if (this->towns.size() == 0) { // No towns available.
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
 
					break;
 
				}
 

	
 
				/* At least one town available. */
 
				bool rtl = _current_text_dir == TD_RTL;
 
				Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
 
				int text_left  = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
 
				int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
 
				int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
 

	
 
				for (uint i = this->vscroll->GetPosition(); i < this->towns.Length(); i++) {
 
				for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) {
 
					const Town *t = this->towns[i];
 
					assert(t->xy != INVALID_TILE);
 

	
 
					/* Draw rating icon. */
 
					if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
 
						DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
 
@@ -823,13 +823,13 @@ public:
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
			case WID_TD_LIST: {
 
				Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE);
 
				for (uint i = 0; i < this->towns.Length(); i++) {
 
				for (uint i = 0; i < this->towns.size(); i++) {
 
					const Town *t = this->towns[i];
 

	
 
					assert(t != NULL);
 

	
 
					SetDParam(0, t->index);
 
					SetDParamMaxDigits(1, 8);
 
@@ -876,13 +876,13 @@ public:
 
			case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown
 
				ShowDropDownMenu(this, TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0);
 
				break;
 

	
 
			case WID_TD_LIST: { // Click on Town Matrix
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
 
				if (id_v >= this->towns.Length()) return; // click out of town bounds
 
				if (id_v >= this->towns.size()) return; // click out of town bounds
 

	
 
				const Town *t = this->towns[id_v];
 
				assert(t != NULL);
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(t->xy);
 
				} else {
src/train_cmd.cpp
Show inline comments
 
@@ -830,13 +830,13 @@ static void MakeTrainBackup(TrainList &l
 
 * Restore the train from the backup list.
 
 * @param list the train to restore.
 
 */
 
static void RestoreTrainBackup(TrainList &list)
 
{
 
	/* No train, nothing to do. */
 
	if (list.Length() == 0) return;
 
	if (list.size() == 0) return;
 

	
 
	Train *prev = NULL;
 
	/* Iterate over the list and rebuild it. */
 
	for (Train **iter = list.Begin(); iter != list.End(); iter++) {
 
		Train *t = *iter;
 
		if (prev != NULL) {
src/train_gui.cpp
Show inline comments
 
@@ -329,13 +329,13 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
			if (max_cargo[i] > 0) num++; // only count carriages that the train has
 
		}
 
		num++; // needs one more because first line is description string
 
	} else {
 
		for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
 
			GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
 
			num += max(1u, _cargo_summary.Length());
 
			num += max(1u, (unsigned)_cargo_summary.size());
 

	
 
			uint length = GetLengthOfArticulatedVehicle(v);
 
			if (length > TRAIN_DETAILS_MAX_INDENT) num++;
 
		}
 
	}
 

	
 
@@ -397,37 +397,37 @@ void DrawTrainDetails(const Train *v, in
 
			bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
 
			if (separate_sprite_row) {
 
				vscroll_pos--;
 
				dx = 0;
 
			}
 

	
 
			uint num_lines = max(1u, _cargo_summary.Length());
 
			uint num_lines = max(1u, (unsigned)_cargo_summary.size());
 
			for (uint i = 0; i < num_lines; i++) {
 
				int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
 
				int data_left  = left + (rtl ? 0 : sprite_width);
 
				int data_right = right - (rtl ? sprite_width : 0);
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					int py = y - line_height * vscroll_pos + text_y_offset;
 
					if (i > 0 || separate_sprite_row) {
 
						if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
 
					}
 
					switch (det_tab) {
 
						case TDW_TAB_CARGO:
 
							if (i < _cargo_summary.Length()) {
 
							if (i < _cargo_summary.size()) {
 
								TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
 
							} else {
 
								DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
 
							}
 
							break;
 

	
 
						case TDW_TAB_INFO:
 
							if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
 
							break;
 

	
 
						case TDW_TAB_CAPACITY:
 
							if (i < _cargo_summary.Length()) {
 
							if (i < _cargo_summary.size()) {
 
								TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
 
							} else {
 
								SetDParam(0, STR_EMPTY);
 
								DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
 
							}
 
							break;
src/vehicle_cmd.cpp
Show inline comments
 
@@ -649,13 +649,13 @@ CommandCost CmdMassStartStopVehicle(Tile
 
		if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR;
 
	} else {
 
		/* Get the list of vehicles in the depot */
 
		BuildDepotVehicleList(vli.vtype, tile, &list, NULL);
 
	}
 

	
 
	for (uint i = 0; i < list.Length(); i++) {
 
	for (uint i = 0; i < list.size(); i++) {
 
		const Vehicle *v = list[i];
 

	
 
		if (!!(v->vehstatus & VS_STOPPED) != do_start) continue;
 

	
 
		if (!vehicle_list_window && !v->IsChainInDepot()) continue;
 

	
 
@@ -688,13 +688,13 @@ CommandCost CmdDepotSellAllVehicles(Tile
 

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

	
 
	CommandCost last_error = CMD_ERROR;
 
	bool had_success = false;
 
	for (uint i = 0; i < list.Length(); i++) {
 
	for (uint i = 0; i < list.size(); i++) {
 
		CommandCost ret = DoCommand(tile, list[i]->index | (1 << 20), 0, flags, sell_command);
 
		if (ret.Succeeded()) {
 
			cost.AddCost(ret);
 
			had_success = true;
 
		} else {
 
			last_error = ret;
 
@@ -722,13 +722,13 @@ CommandCost CmdDepotMassAutoReplace(Tile
 
	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 */
 
	BuildDepotVehicleList(vehicle_type, tile, &list, &list, true);
 

	
 
	for (uint i = 0; i < list.Length(); i++) {
 
	for (uint i = 0; i < list.size(); i++) {
 
		const Vehicle *v = list[i];
 

	
 
		/* Ensure that the vehicle completely in the depot */
 
		if (!v->IsChainInDepot()) continue;
 

	
 
		CommandCost ret = DoCommand(0, v->index, 0, flags, CMD_AUTOREPLACE_VEHICLE);
 
@@ -1000,13 +1000,13 @@ static CommandCost SendAllVehiclesToDepo
 
	VehicleList list;
 

	
 
	if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR;
 

	
 
	/* Send all the vehicles to a depot */
 
	bool had_success = false;
 
	for (uint i = 0; i < list.Length(); i++) {
 
	for (uint i = 0; i < list.size(); i++) {
 
		const Vehicle *v = list[i];
 
		CommandCost ret = DoCommand(v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0, flags, GetCmdSendToDepot(vli.vtype));
 

	
 
		if (ret.Succeeded()) {
 
			had_success = true;
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -130,13 +130,13 @@ void BaseVehicleListWindow::BuildVehicle
 

	
 
	GenerateVehicleSortList(&this->vehicles, this->vli);
 

	
 
	this->unitnumber_digits = GetUnitNumberDigits(this->vehicles);
 

	
 
	this->vehicles.RebuildDone();
 
	this->vscroll->SetCount(this->vehicles.Length());
 
	this->vscroll->SetCount(this->vehicles.size());
 
}
 

	
 
/**
 
 * Compute the size for the Action dropdown.
 
 * @param show_autoreplace If true include the autoreplace item.
 
 * @param show_group If true include group-related stuff.
 
@@ -190,14 +190,14 @@ void BaseVehicleListWindow::SortVehicleL
 
	/* invalidate cached values for name sorter - vehicle names could change */
 
	_last_vehicle[0] = _last_vehicle[1] = NULL;
 
}
 

	
 
void DepotSortList(VehicleList *list)
 
{
 
	if (list->Length() < 2) return;
 
	QSortT(list->Begin(), list->Length(), &VehicleNumberSorter);
 
	if (list->size() < 2) return;
 
	QSortT(list->Begin(), list->size(), &VehicleNumberSorter);
 
}
 

	
 
/** draw the vehicle profit button in the vehicle list window. */
 
static void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
 
{
 
	SpriteID spr;
 
@@ -240,13 +240,13 @@ byte GetBestFittingSubType(Vehicle *v_fr
 
		if (!e_from->CanCarryCargo() || !HasBit(e_from->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue;
 
		subtypes.Include(GetCargoSubtypeText(v_from));
 
	}
 

	
 
	byte ret_refit_cyc = 0;
 
	bool success = false;
 
	if (subtypes.Length() > 0) {
 
	if (subtypes.size() > 0) {
 
		/* Check whether any articulated part is refittable to 'dest_cargo_type' with a subtype listed in 'subtypes' */
 
		for (Vehicle *v = v_for; v != NULL; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL) {
 
			const Engine *e = v->GetEngine();
 
			if (!e->CanCarryCargo() || !HasBit(e->info.callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) continue;
 
			if (!HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type) continue;
 

	
 
@@ -344,29 +344,29 @@ static void DrawVehicleRefitWindow(const
 

	
 
	int textleft   = r.left  + WD_MATRIX_LEFT  + (rtl ? 0 : iconwidth + 4);
 
	int textright  = r.right - WD_MATRIX_RIGHT - (rtl ? iconwidth + 4 : 0);
 

	
 
	/* Draw the list of subtypes for each cargo, and find the selected refit option (by its position). */
 
	for (uint i = 0; current < pos + rows && i < NUM_CARGO; i++) {
 
		for (uint j = 0; current < pos + rows && j < list[i].Length(); j++) {
 
		for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
 
			const RefitOption &refit = list[i][j];
 

	
 
			/* Hide subtypes if sel[0] does not match */
 
			if (sel[0] != (int)i && refit.subtype != 0xFF) continue;
 

	
 
			/* Refit options with a position smaller than pos don't have to be drawn. */
 
			if (current < pos) {
 
				current++;
 
				continue;
 
			}
 

	
 
			if (list[i].Length() > 1) {
 
			if (list[i].size() > 1) {
 
				if (refit.subtype != 0xFF) {
 
					/* Draw tree lines */
 
					int ycenter = y + FONT_HEIGHT_NORMAL / 2;
 
					GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].Length() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
 
					GfxDrawLine(iconcenter, y - WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y - WD_MATRIX_TOP + delta - 1, linecolour);
 
					GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
 
				} else {
 
					/* Draw expand/collapse icon */
 
					DrawSprite(sel[0] == (int)i ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, y + (FONT_HEIGHT_NORMAL - iconheight) / 2);
 
				}
 
			}
 
@@ -432,13 +432,13 @@ struct RefitWindow : public Window {
 
				/* Skip cargo type if it's not listed */
 
				if (!HasBit(cmask, cid)) {
 
					current_index++;
 
					continue;
 
				}
 

	
 
				bool first_vehicle = this->list[current_index].Length() == 0;
 
				bool first_vehicle = this->list[current_index].size() == 0;
 
				if (first_vehicle) {
 
					/* Keeping the current subtype is always an option. It also serves as the option in case of no subtypes */
 
					RefitOption *option = this->list[current_index].Append();
 
					option->cargo   = cid;
 
					option->subtype = 0xFF;
 
					option->string  = STR_EMPTY;
 
@@ -477,25 +477,25 @@ struct RefitWindow : public Window {
 
						} else {
 
							/* Intersect the subtypes of earlier vehicles with the subtypes of this vehicle */
 
							if (subtype == STR_EMPTY) {
 
								/* No more subtypes for this vehicle, delete all subtypes >= refit_cyc */
 
								SubtypeList &l = this->list[current_index];
 
								/* 0xFF item is in front, other subtypes are sorted. So just truncate the list in the right spot */
 
								for (uint i = 1; i < l.Length(); i++) {
 
								for (uint i = 1; i < l.size(); i++) {
 
									if (l[i].subtype >= refit_cyc) {
 
										l.Resize(i);
 
										break;
 
									}
 
								}
 
								break;
 
							} else {
 
								/* Check whether the subtype matches with the subtype of earlier vehicles. */
 
								uint pos = 1;
 
								SubtypeList &l = this->list[current_index];
 
								while (pos < l.Length() && l[pos].subtype != refit_cyc) pos++;
 
								if (pos < l.Length() && l[pos].string != subtype) {
 
								while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
 
								if (pos < l.size() && l[pos].string != subtype) {
 
									/* String mismatch, remove item keeping the order */
 
									l.ErasePreservingOrder(pos);
 
								}
 
							}
 
						}
 
					}
 
@@ -519,13 +519,13 @@ struct RefitWindow : public Window {
 
	void RefreshScrollbar()
 
	{
 
		uint scroll_row = 0;
 
		uint row = 0;
 

	
 
		for (uint i = 0; i < NUM_CARGO; i++) {
 
			for (uint j = 0; j < this->list[i].Length(); j++) {
 
			for (uint j = 0; j < this->list[i].size(); j++) {
 
				const RefitOption &refit = this->list[i][j];
 

	
 
				/* Hide subtypes if sel[0] does not match */
 
				if (this->sel[0] != (int)i && refit.subtype != 0xFF) continue;
 

	
 
				if (this->sel[0] == (int)i && (uint)this->sel[1] == j) scroll_row = row;
 
@@ -544,13 +544,13 @@ struct RefitWindow : public Window {
 
	 */
 
	void SetSelection(uint click_row)
 
	{
 
		uint row = 0;
 

	
 
		for (uint i = 0; i < NUM_CARGO; i++) {
 
			for (uint j = 0; j < this->list[i].Length(); j++) {
 
			for (uint j = 0; j < this->list[i].size(); j++) {
 
				const RefitOption &refit = this->list[i][j];
 

	
 
				/* Hide subtypes if sel[0] does not match */
 
				if (this->sel[0] != (int)i && refit.subtype != 0xFF) continue;
 

	
 
				if (row == click_row) {
 
@@ -573,13 +573,13 @@ struct RefitWindow : public Window {
 
	 */
 
	RefitOption *GetRefitOption()
 
	{
 
		if (this->sel[0] < 0) return NULL;
 

	
 
		SubtypeList &l = this->list[this->sel[0]];
 
		if ((uint)this->sel[1] >= l.Length()) return NULL;
 
		if ((uint)this->sel[1] >= l.size()) return NULL;
 

	
 
		return &l[this->sel[1]];
 
	}
 

	
 
	RefitWindow(WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window(desc)
 
	{
 
@@ -614,13 +614,13 @@ struct RefitWindow : public Window {
 
			/* Rebuild the refit list */
 
			this->BuildRefitList();
 
			this->sel[0] = -1;
 
			this->sel[1] = 0;
 
			this->cargo = NULL;
 
			for (uint i = 0; this->cargo == NULL && i < NUM_CARGO; i++) {
 
				for (uint j = 0; j < list[i].Length(); j++) {
 
				for (uint j = 0; j < list[i].size(); j++) {
 
					if (list[i][j] == current_refit_option) {
 
						this->sel[0] = i;
 
						this->sel[1] = j;
 
						this->cargo = &list[i][j];
 
						break;
 
					}
 
@@ -827,13 +827,13 @@ struct RefitWindow : public Window {
 
				/* The vehicle width has changed too. */
 
				this->vehicle_width = GetVehicleWidth(Vehicle::Get(this->window_number), EIT_IN_DETAILS);
 
				uint max_width = 0;
 

	
 
				/* Check the width of all cargo information strings. */
 
				for (uint i = 0; i < NUM_CARGO; i++) {
 
					for (uint j = 0; j < this->list[i].Length(); j++) {
 
					for (uint j = 0; j < this->list[i].size(); j++) {
 
						StringID string = this->GetCapacityString(&list[i][j]);
 
						if (string != INVALID_STRING_ID) {
 
							Dimension dim = GetStringBoundingBox(string);
 
							max_width = max(dim.width, max_width);
 
						}
 
					}
 
@@ -1385,13 +1385,13 @@ void BaseVehicleListWindow::DrawVehicleL
 
	int image_left  = (rtl && show_orderlist) ? orderlist_right : text_left;
 
	int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
 

	
 
	int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
 

	
 
	int y = r.top;
 
	uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.Length());
 
	uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->vehicles.size());
 
	for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
 
		const Vehicle *v = this->vehicles[i];
 
		StringID str;
 

	
 
		SetDParam(0, v->GetDisplayProfitThisYear());
 
		SetDParam(1, v->GetDisplayProfitLastYear());
 
@@ -1529,13 +1529,13 @@ public:
 
				SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
 
				break;
 

	
 
			case WID_VL_CAPTION: {
 
				switch (this->vli.type) {
 
					case VL_SHARED_ORDERS: // Shared Orders
 
						if (this->vehicles.Length() == 0) {
 
						if (this->vehicles.size() == 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->GetCount());
 
						break;
 
@@ -1581,13 +1581,13 @@ public:
 

	
 
	void OnPaint() override
 
	{
 
		this->BuildVehicleList();
 
		this->SortVehicleList();
 

	
 
		if (this->vehicles.Length() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
 
		if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
 
			HideDropDownMenu(this);
 
		}
 

	
 
		/* Hide the widgets that we will not use in this window
 
		 * Some windows contains actions only fit for the owner */
 
		int plane_to_show = (this->owner == _local_company) ? BP_SHOW_BUTTONS : BP_HIDE_BUTTONS;
 
@@ -1595,13 +1595,13 @@ public:
 
		if (plane_to_show != nwi->shown_plane) {
 
			nwi->SetDisplayedPlane(plane_to_show);
 
			nwi->SetDirty(this);
 
		}
 
		if (this->owner == _local_company) {
 
			this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
 
			this->SetWidgetsDisabledState(this->vehicles.Length() == 0,
 
			this->SetWidgetsDisabledState(this->vehicles.size() == 0,
 
				WID_VL_MANAGE_VEHICLES_DROPDOWN,
 
				WID_VL_STOP_ALL,
 
				WID_VL_START_ALL,
 
				WIDGET_LIST_END);
 
		}
 

	
 
@@ -1623,13 +1623,13 @@ public:
 
				ShowDropDownMenu(this, this->vehicle_sorter_names, this->vehicles.SortType(), WID_VL_SORT_BY_PULLDOWN, 0,
 
						(this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10));
 
				return;
 

	
 
			case WID_VL_LIST: { // Matrix to show vehicles
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_VL_LIST);
 
				if (id_v >= this->vehicles.Length()) return; // click out of list bound
 
				if (id_v >= this->vehicles.size()) return; // click out of list bound
 

	
 
				const Vehicle *v = this->vehicles[id_v];
 
				if (!VehicleClicked(v)) ShowVehicleViewWindow(v);
 
				break;
 
			}
 

	
 
@@ -1654,13 +1654,13 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_VL_SORT_BY_PULLDOWN:
 
				this->vehicles.SetSortType(index);
 
				break;
 
			case WID_VL_MANAGE_VEHICLES_DROPDOWN:
 
				assert(this->vehicles.Length() != 0);
 
				assert(this->vehicles.size() != 0);
 

	
 
				switch (index) {
 
					case ADI_REPLACE: // Replace window
 
						ShowReplaceGroupVehicleWindow(ALL_GROUP, this->vli.vtype);
 
						break;
 
					case ADI_SERVICE: // Send for servicing
src/viewport.cpp
Show inline comments
 
@@ -595,13 +595,13 @@ void OffsetGroundSprite(int x, int y)
 
			_vd.foundation_part = FOUNDATION_PART_HALFTILE;
 
			break;
 
		default: NOT_REACHED();
 
	}
 

	
 
	/* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */
 
	if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.Length() - 1;
 
	if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.size() - 1;
 

	
 
	_vd.foundation_offset[_vd.foundation_part].x = x * ZOOM_LVL_BASE;
 
	_vd.foundation_offset[_vd.foundation_part].y = y * ZOOM_LVL_BASE;
 
	_vd.last_foundation_child[_vd.foundation_part] = _vd.last_child;
 
}
 

	
 
@@ -821,13 +821,13 @@ void AddChildSpriteScreen(SpriteID image
 
	/* make the sprites transparent with the right palette */
 
	if (transparent) {
 
		SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	*_vd.last_child = _vd.child_screen_sprites_to_draw.Length();
 
	*_vd.last_child = _vd.child_screen_sprites_to_draw.size();
 

	
 
	ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append();
 
	cs->image = image;
 
	cs->pal = pal;
 
	cs->sub = sub;
 
	cs->x = scale ? x * ZOOM_LVL_BASE : x;
 
@@ -1581,13 +1581,13 @@ void ViewportDoDraw(const ViewPort *vp, 
 
	ViewportAddVehicles(&_vd.dpi);
 

	
 
	ViewportAddKdtreeSigns(&_vd.dpi);
 

	
 
	DrawTextEffects(&_vd.dpi);
 

	
 
	if (_vd.tile_sprites_to_draw.Length() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
 
	if (_vd.tile_sprites_to_draw.size() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
 

	
 
	ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End();
 
	for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) {
 
		*_vd.parent_sprites_to_sort.Append() = it;
 
	}
 

	
 
@@ -1608,13 +1608,13 @@ void ViewportDoDraw(const ViewPort *vp, 
 
		/* translate to window coordinates */
 
		dp.left = x;
 
		dp.top = y;
 
		vp->overlay->Draw(&dp);
 
	}
 

	
 
	if (_vd.string_sprites_to_draw.Length() != 0) {
 
	if (_vd.string_sprites_to_draw.size() != 0) {
 
		/* translate to world coordinates */
 
		dp.left = UnScaleByZoom(_vd.dpi.left, zoom);
 
		dp.top = UnScaleByZoom(_vd.dpi.top, zoom);
 
		ViewportDrawStrings(zoom, &_vd.string_sprites_to_draw);
 
	}
 

	
src/widgets/dropdown.cpp
Show inline comments
 
@@ -148,13 +148,13 @@ struct DropdownWindow : Window {
 
	 * @param wi_colour     Colour of the parent widget.
 
	 * @param scroll        Dropdown menu has a scrollbar.
 
	 */
 
	DropdownWindow(Window *parent, const DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll)
 
			: Window(&_dropdown_desc)
 
	{
 
		assert(list->Length() > 0);
 
		assert(list->size() > 0);
 

	
 
		this->position = position;
 

	
 
		this->CreateNestedTree();
 

	
 
		this->vscroll = this->GetScrollbar(WID_DM_SCROLL);
 
@@ -177,14 +177,14 @@ struct DropdownWindow : Window {
 
		for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
 
			const DropDownListItem *item = *it;
 
			list_height += item->Height(items_width);
 
		}
 

	
 
		/* Capacity is the average number of items visible */
 
		this->vscroll->SetCapacity(size.height * (uint16)list->Length() / list_height);
 
		this->vscroll->SetCount((uint16)list->Length());
 
		this->vscroll->SetCapacity(size.height * (uint16)list->size() / list_height);
 
		this->vscroll->SetCount((uint16)list->size());
 

	
 
		this->parent_wnd_class = parent->window_class;
 
		this->parent_wnd_num   = parent->window_number;
 
		this->parent_button    = button;
 
		this->list             = list;
 
		this->selected_index   = selected;
 
@@ -415,13 +415,13 @@ void ShowDropDownListAt(Window *w, const
 
			available_height = available_height_above;
 
		}
 

	
 
		/* If the dropdown doesn't fully fit, we need a dropdown. */
 
		if (height > available_height) {
 
			scroll = true;
 
			uint avg_height = height / list->Length();
 
			uint avg_height = height / list->size();
 

	
 
			/* Check at least there is space for one item. */
 
			assert(available_height >= avg_height);
 

	
 
			/* Fit the list. */
 
			uint rows = available_height / avg_height;
 
@@ -511,13 +511,13 @@ void ShowDropDownMenu(Window *w, const S
 
		if (!HasBit(hidden_mask, i)) {
 
			*list->Append() = new DropDownListStringItem(strings[i], i, HasBit(disabled_mask, i));
 
		}
 
	}
 

	
 
	/* No entries in the list? */
 
	if (list->Length() == 0) {
 
	if (list->size() == 0) {
 
		delete list;
 
		return;
 
	}
 

	
 
	ShowDropDownList(w, list, selected, button, width);
 
}
src/window.cpp
Show inline comments
 
@@ -163,13 +163,13 @@ static int CDECL DescSorter(WindowDesc *
 
/**
 
 * Save all WindowDesc settings to _windows_file.
 
 */
 
void WindowDesc::SaveToConfig()
 
{
 
	/* Sort the stuff to get a nice ini file on first write */
 
	QSortT(_window_descs->Begin(), _window_descs->Length(), DescSorter);
 
	QSortT(_window_descs->Begin(), _window_descs->size(), DescSorter);
 

	
 
	IniFile *ini = new IniFile();
 
	ini->LoadFromDisk(_windows_file, NO_DIRECTORY);
 
	for (WindowDesc **it = _window_descs->Begin(); it != _window_descs->End(); ++it) {
 
		if ((*it)->ini_key == NULL) continue;
 
		IniSaveWindowSettings(ini, (*it)->ini_key, *it);
0 comments (0 inline, 0 general)