Changeset - r23532:dc91fcd293f5
[Not reviewed]
master
! ! !
Henry Wilson - 6 years ago 2019-02-18 22:39:06
m3henry@googlemail.com
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
79 files changed with 411 insertions and 412 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -478,13 +478,13 @@ struct AISettingsWindow : public Window 
 
						if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
 
							this->clicked_dropdown = true;
 
							this->closing_dropdown = false;
 

	
 
							DropDownList *list = new DropDownList();
 
							for (int i = config_item.min_value; i <= config_item.max_value; i++) {
 
								*list->Append() = new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false);
 
								list->push_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false));
 
							}
 

	
 
							ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true);
 
						}
 
					}
 
				} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
src/airport_gui.cpp
Show inline comments
 
@@ -216,13 +216,13 @@ class BuildAirportWindow : public Picker
 
	/** Build a dropdown list of available airport classes */
 
	static DropDownList *BuildAirportClassDropDown()
 
	{
 
		DropDownList *list = new DropDownList();
 

	
 
		for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
 
			*list->Append() = new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false);
 
			list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
 
		}
 

	
 
		return list;
 
	}
 

	
 
public:
src/autoreplace_gui.cpp
Show inline comments
 
@@ -137,13 +137,13 @@ class ReplaceVehicleWindow : public Wind
 
				/* Skip drawing the engines we don't have any of and haven't set for replacement */
 
				if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, this->sel_group) == INVALID_ENGINE) continue;
 
			} else {
 
				if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
 
			}
 

	
 
			*list->Append() = eid;
 
			list->push_back(eid);
 
			if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
 
		}
 
		this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
 
		if (draw_left) {
 
			EngList_Sort(list, &EngineNumberSorter);
 
		} else {
 
@@ -465,14 +465,14 @@ public:
 
			case WID_RV_SORT_DROPDOWN:
 
				DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
 
				break;
 

	
 
			case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
 
				DropDownList *list = new DropDownList();
 
				*list->Append() = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false);
 
				*list->Append() = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false);
 
				list->push_back(new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false));
 
				list->push_back(new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false));
 
				ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
 
				break;
 
			}
 

	
 
			case WID_RV_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu
 
				ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN);
src/bridge_gui.cpp
Show inline comments
 
@@ -413,18 +413,19 @@ void ShowBuildBridgeWindow(TileIndex sta
 
		}
 

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

	
 
	if (bl != NULL && bl->size() != 0) {
 
		new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1243,13 +1243,13 @@ struct BuildVehicleWindow : Window {
 
			if (this->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue;
 
			if (!IsEngineBuildable(eid, VEH_TRAIN, _local_company)) continue;
 

	
 
			/* Filter now! So num_engines and num_wagons is valid */
 
			if (!FilterSingleEngine(eid)) continue;
 

	
 
			*this->eng_list.Append() = eid;
 
			this->eng_list.push_back(eid);
 

	
 
			if (rvi->railveh_type != RAILVEH_WAGON) {
 
				num_engines++;
 
			} else {
 
				num_wagons++;
 
			}
 
@@ -1281,13 +1281,13 @@ struct BuildVehicleWindow : Window {
 
		const Engine *e;
 
		FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
 
			if (!this->show_hidden_engines && e->IsHidden(_local_company)) continue;
 
			EngineID eid = e->index;
 
			if (!IsEngineBuildable(eid, VEH_ROAD, _local_company)) continue;
 
			if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
 
			*this->eng_list.Append() = eid;
 
			this->eng_list.push_back(eid);
 

	
 
			if (eid == this->sel_engine) sel_id = eid;
 
		}
 
		this->SelectEngine(sel_id);
 
	}
 

	
 
@@ -1299,13 +1299,13 @@ struct BuildVehicleWindow : Window {
 

	
 
		const Engine *e;
 
		FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) {
 
			if (!this->show_hidden_engines && e->IsHidden(_local_company)) continue;
 
			EngineID eid = e->index;
 
			if (!IsEngineBuildable(eid, VEH_SHIP, _local_company)) continue;
 
			*this->eng_list.Append() = eid;
 
			this->eng_list.push_back(eid);
 

	
 
			if (eid == this->sel_engine) sel_id = eid;
 
		}
 
		this->SelectEngine(sel_id);
 
	}
 

	
 
@@ -1327,13 +1327,13 @@ struct BuildVehicleWindow : Window {
 
			if (!this->show_hidden_engines && e->IsHidden(_local_company)) continue;
 
			EngineID eid = e->index;
 
			if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_company)) continue;
 
			/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
 
			if (!this->listview_mode && !CanVehicleUseStation(eid, st)) continue;
 

	
 
			*this->eng_list.Append() = eid;
 
			this->eng_list.push_back(eid);
 
			if (eid == this->sel_engine) sel_id = eid;
 
		}
 

	
 
		this->SelectEngine(sel_id);
 
	}
 

	
src/company_gui.cpp
Show inline comments
 
@@ -603,16 +603,16 @@ private:
 
		}
 

	
 
		DropDownList *list = new DropDownList();
 
		if (default_livery != NULL) {
 
			/* Add COLOUR_END to put the colour out of range, but also allow us to show what the default is */
 
			default_col = (primary ? default_livery->colour1 : default_livery->colour2) + COLOUR_END;
 
			*list->Append() = new DropDownListColourItem(default_col, false);
 
			list->push_back(new DropDownListColourItem(default_col, false));
 
		}
 
		for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
 
			*list->Append() = new DropDownListColourItem(i, HasBit(used_colours, i));
 
			list->push_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
 
		}
 

	
 
		byte sel = (default_livery == NULL || HasBit(livery->in_use, primary ? 0 : 1)) ? (primary ? livery->colour1 : livery->colour2) : default_col;
 
		ShowDropDownList(this, list, sel, widget);
 
	}
 

	
 
@@ -639,14 +639,14 @@ private:
 
	}
 

	
 
	void AddChildren(GUIGroupList *source, GroupID parent, int indent)
 
	{
 
		for (const Group **g = source->Begin(); g != source->End(); g++) {
 
			if ((*g)->parent != parent) continue;
 
			*this->groups.Append() = *g;
 
			*this->indents.Append() = indent;
 
			this->groups.push_back(*g);
 
			this->indents.push_back(indent);
 
			AddChildren(source, (*g)->index, indent + 1);
 
		}
 
	}
 

	
 
	void BuildGroupList(CompanyID owner)
 
	{
 
@@ -659,13 +659,13 @@ private:
 
			GUIGroupList list;
 
			VehicleType vtype = (VehicleType)(this->livery_class - LC_GROUP_RAIL);
 

	
 
			const Group *g;
 
			FOR_ALL_GROUPS(g) {
 
				if (g->owner == owner && g->vehicle_type == vtype) {
 
					*list.Append() = g;
 
					list.push_back(g);
 
				}
 
			}
 

	
 
			list.ForceResort();
 
			list.Sort(&GroupNameSorter);
 

	
src/core/pool_type.hpp
Show inline comments
 
@@ -47,13 +47,13 @@ struct PoolBase {
 
	/**
 
	 * Constructor registers this object in the pool vector.
 
	 * @param pt type of this pool.
 
	 */
 
	PoolBase(PoolType pt) : type(pt)
 
	{
 
		*PoolBase::GetPools()->Append() = this;
 
		PoolBase::GetPools()->push_back(this);
 
	}
 

	
 
	virtual ~PoolBase();
 

	
 
	/**
 
	 * Virtual method that deletes all items in the pool.
src/core/smallmap_type.hpp
Show inline comments
 
@@ -140,15 +140,13 @@ struct SmallMap : SmallVector<SmallPair<
 
	 * @param data data
 
	 * @return true iff the key wasn't already present
 
	 */
 
	inline bool Insert(const T &key, const U &data)
 
	{
 
		if (this->Contains(key)) return false;
 
		Pair *n = this->Append();
 
		n->first = key;
 
		n->second = data;
 
		std::vector<Pair>::emplace_back(key, data);
 
		return true;
 
	}
 

	
 
	/**
 
	 * Returns data belonging to this key
 
	 * @param key key
 
@@ -157,15 +155,16 @@ struct SmallMap : SmallVector<SmallPair<
 
	 */
 
	inline U &operator[](const T &key)
 
	{
 
		for (uint i = 0; i < std::vector<Pair>::size(); i++) {
 
			if (key == std::vector<Pair>::operator[](i).first) return std::vector<Pair>::operator[](i).second;
 
		}
 
		Pair *n = this->Append();
 
		n->first = key;
 
		return n->second;
 
		/*C++17: Pair &n = */ std::vector<Pair>::emplace_back();
 
		Pair &n = std::vector<Pair>::back();
 
		n.first = key;
 
		return n.second;
 
	}
 

	
 
	inline void SortByKey()
 
	{
 
		QSortT(this->Begin(), std::vector<Pair>::size(), KeySorter);
 
	}
src/core/smallvec_type.hpp
Show inline comments
 
@@ -64,23 +64,12 @@ public:
 
		return *this;
 
	}
 

	
 
	~SmallVector() = default;
 

	
 
	/**
 
	 * Append an item and return it.
 
	 * @param to_add the number of items to append
 
	 * @return pointer to newly allocated item
 
	 */
 
	inline T *Append(uint to_add = 1)
 
	{
 
		std::vector<T>::resize(std::vector<T>::size() + to_add);
 
		return this->End() - to_add;
 
	}
 

	
 
	/**
 
	 * Insert a new item at a specific position into the vector, moving all following items.
 
	 * @param item Position at which the new item should be inserted
 
	 * @return pointer to the new item
 
	 */
 
	inline T *Insert(T *item)
 
	{
 
@@ -109,13 +98,13 @@ public:
 
	 * @param item Item to test for
 
	 * @return true iff the item is was already present
 
	 */
 
	inline bool Include(const T &item)
 
	{
 
		bool is_member = std::find(std::vector<T>::begin(), std::vector<T>::end(), item) != std::vector<T>::end();
 
		if (!is_member) *this->Append() = item;
 
		if (!is_member) std::vector<T>::emplace_back(item);
 
		return is_member;
 
	}
 

	
 
	/**
 
	 * Get the pointer to the first item (const)
 
	 *
 
@@ -154,12 +143,29 @@ public:
 
	inline T *End()
 
	{
 
		return std::vector<T>::data() + std::vector<T>::size();
 
	}
 
};
 

	
 
/**
 
 * Helper function to extend a vector by more than one element
 
 * Consider using std::back_inserter in new code
 
 *
 
 * @param vec A reference to the vector to be extended
 
 * @param num The number of elements to default-construct
 
 *
 
 * @return Pointer to the first new element
 
 */
 
template <typename T>
 
inline T* grow(std::vector<T>& vec, std::size_t num)
 
{
 
	const std::size_t pos = vec.size();
 
	vec.resize(pos + num);
 
	return vec.data() + pos;
 
}
 

	
 

	
 
/**
 
 * Simple vector template class, with automatic free.
 
 *
 
 * @note There are no asserts in the class so you have
 
 *       to care about that you grab an item which is
src/date_gui.cpp
Show inline comments
 
@@ -72,29 +72,29 @@ struct SetDateWindow : Window {
 

	
 
		switch (widget) {
 
			default: NOT_REACHED();
 

	
 
			case WID_SD_DAY:
 
				for (uint i = 0; i < 31; i++) {
 
					*list->Append() = new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false);
 
					list->push_back(new DropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1, false));
 
				}
 
				selected = this->date.day;
 
				break;
 

	
 
			case WID_SD_MONTH:
 
				for (uint i = 0; i < 12; i++) {
 
					*list->Append() = new DropDownListStringItem(STR_MONTH_JAN + i, i, false);
 
					list->push_back(new DropDownListStringItem(STR_MONTH_JAN + i, i, false));
 
				}
 
				selected = this->date.month;
 
				break;
 

	
 
			case WID_SD_YEAR:
 
				for (Year i = this->min_year; i <= this->max_year; i++) {
 
					DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
 
					item->SetParam(0, i);
 
					*list->Append() = item;
 
					list->push_back(item);
 
				}
 
				selected = this->date.year;
 
				break;
 
		}
 

	
 
		ShowDropDownList(this, list, selected, widget);
src/engine.cpp
Show inline comments
 
@@ -487,17 +487,18 @@ StringID Engine::GetAircraftTypeText() c
 
 */
 
void EngineOverrideManager::ResetToDefaultMapping()
 
{
 
	this->clear();
 
	for (VehicleType type = VEH_TRAIN; type <= VEH_AIRCRAFT; type++) {
 
		for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
 
			EngineIDMapping *eid = this->Append();
 
			eid->type            = type;
 
			eid->grfid           = INVALID_GRFID;
 
			eid->internal_id     = internal_id;
 
			eid->substitute_id   = internal_id;
 
			/*C++17: EngineIDMapping &eid = */ this->emplace_back();
 
			EngineIDMapping &eid = this->back();
 
			eid.type            = type;
 
			eid.grfid           = INVALID_GRFID;
 
			eid.internal_id     = internal_id;
 
			eid.substitute_id   = internal_id;
 
		}
 
	}
 
}
 

	
 
/**
 
 * Looks up an EngineID in the EngineOverrideManager
src/fios.h
Show inline comments
 
@@ -117,13 +117,14 @@ public:
 
	/**
 
	 * Construct a new entry in the file list.
 
	 * @return Pointer to the new items to be initialized.
 
	 */
 
	inline FiosItem *Append()
 
	{
 
		return this->files.Append();
 
		/*C++17: return &*/ this->files.emplace_back();
 
		return &this->files.back();
 
	}
 

	
 
	/**
 
	 * Get the number of files in the list.
 
	 * @return The number of files stored in the list.
 
	 */
src/game/game_text.cpp
Show inline comments
 
@@ -112,13 +112,13 @@ LanguageStrings *ReadRawLanguageStrings(
 

	
 
			/* Remove trailing spaces/newlines from the string. */
 
			size_t i = len;
 
			while (i > 0 && (buffer[i - 1] == '\r' || buffer[i - 1] == '\n' || buffer[i - 1] == ' ')) i--;
 
			buffer[i] = '\0';
 

	
 
			*ret->lines.Append() = stredup(buffer, buffer + to_read - 1);
 
			ret->lines.push_back(stredup(buffer, buffer + to_read - 1));
 

	
 
			if (len > to_read) {
 
				to_read = 0;
 
			} else {
 
				to_read -= len;
 
			}
 
@@ -191,13 +191,13 @@ struct TranslationWriter : LanguageWrite
 

	
 
	void Write(const byte *buffer, size_t length)
 
	{
 
		char *dest = MallocT<char>(length + 1);
 
		memcpy(dest, buffer, length);
 
		dest[length] = '\0';
 
		*this->strings->Append() = dest;
 
		this->strings->push_back(dest);
 
	}
 
};
 

	
 
/** Class for writing the string IDs. */
 
struct StringNameWriter : HeaderWriter {
 
	StringList *strings; ///< The string names.
 
@@ -209,13 +209,13 @@ struct StringNameWriter : HeaderWriter {
 
	StringNameWriter(StringList *strings) : strings(strings)
 
	{
 
	}
 

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

	
 
	void Finalise(const StringData &data)
 
	{
 
		/* Nothing to do. */
 
	}
 
@@ -243,13 +243,13 @@ public:
 
	}
 

	
 
	bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
 
	{
 
		if (strcmp(filename, exclude) == 0) return true;
 

	
 
		*gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
 
		gs->raw_strings.push_back(ReadRawLanguageStrings(filename));
 
		return true;
 
	}
 
};
 

	
 
/**
 
 * Load all translations that we know of.
 
@@ -266,13 +266,13 @@ GameStrings *LoadTranslations()
 

	
 
	strecpy(e, "lang" PATHSEP "english.txt", lastof(filename));
 
	if (!FioCheckFileExists(filename, GAME_DIR)) return NULL;
 

	
 
	GameStrings *gs = new GameStrings();
 
	try {
 
		*gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
 
		gs->raw_strings.push_back(ReadRawLanguageStrings(filename));
 

	
 
		/* Scan for other language files */
 
		LanguageScanner scanner(gs, filename);
 
		strecpy(e, "lang" PATHSEP, lastof(filename));
 
		size_t len = strlen(filename);
 

	
 
@@ -321,14 +321,14 @@ void GameStrings::Compile()
 
	for (LanguageStrings **p = this->raw_strings.Begin(); p != this->raw_strings.End(); p++) {
 
		data.FreeTranslation();
 
		StringListReader translation_reader(data, *p, false, strcmp((*p)->language, "english") != 0);
 
		translation_reader.ParseFile();
 
		if (_errors != 0) throw std::exception();
 

	
 
		LanguageStrings *compiled = *this->compiled_strings.Append() = new LanguageStrings((*p)->language);
 
		TranslationWriter writer(&compiled->lines);
 
		this->compiled_strings.push_back(new LanguageStrings((*p)->language));
 
		TranslationWriter writer(&this->compiled_strings.back()->lines);
 
		writer.WriteLang(data);
 
	}
 
}
 

	
 
/** The currently loaded game strings. */
 
GameStrings *_current_data = NULL;
src/genworld_gui.cpp
Show inline comments
 
@@ -286,13 +286,13 @@ static DropDownList *BuildMapsizeDropDow
 
{
 
	DropDownList *list = new DropDownList();
 

	
 
	for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
 
		DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
 
		item->SetParam(0, 1LL << i);
 
		*list->Append() = item;
 
		list->push_back(item);
 
	}
 

	
 
	return list;
 
}
 

	
 
static const StringID _elevations[]  = {STR_TERRAIN_TYPE_VERY_FLAT, STR_TERRAIN_TYPE_FLAT, STR_TERRAIN_TYPE_HILLY, STR_TERRAIN_TYPE_MOUNTAINOUS, STR_TERRAIN_TYPE_ALPINIST, INVALID_STRING_ID};
src/gfx_layout.cpp
Show inline comments
 
@@ -147,13 +147,13 @@ public:
 
		icu::ParagraphLayout::Line *l; ///< The actual ICU line.
 

	
 
	public:
 
		ICULine(icu::ParagraphLayout::Line *l) : l(l)
 
		{
 
			for (int i = 0; i < l->countRuns(); i++) {
 
				*this->Append() = new ICUVisualRun(l->getVisualRun(i));
 
				this->push_back(new ICUVisualRun(l->getVisualRun(i)));
 
			}
 
		}
 
		~ICULine() { delete l; }
 

	
 
		int GetLeading() const { return l->getLeading(); }
 
		int GetWidth() const   { return l->getWidth(); }
 
@@ -495,13 +495,13 @@ const ParagraphLayouter::Line *FallbackP
 

	
 
	FallbackLine *l = new FallbackLine();
 

	
 
	if (*this->buffer == '\0') {
 
		/* Only a newline. */
 
		this->buffer = NULL;
 
		*l->Append() = new FallbackVisualRun(this->runs.Begin()->second, this->buffer, 0, 0);
 
		l->push_back(new FallbackVisualRun(this->runs.Begin()->second, this->buffer, 0, 0));
 
		return l;
 
	}
 

	
 
	int offset = this->buffer - this->buffer_begin;
 
	FontMap::iterator iter = this->runs.Begin();
 
	while (iter->first <= offset) {
 
@@ -524,13 +524,13 @@ const ParagraphLayouter::Line *FallbackP
 
			this->buffer = NULL;
 
			break;
 
		}
 

	
 
		if (this->buffer == next_run) {
 
			int w = l->GetWidth();
 
			*l->Append() = new FallbackVisualRun(iter->second, begin, this->buffer - begin, w);
 
			l->push_back(new FallbackVisualRun(iter->second, begin, this->buffer - begin, w));
 
			iter++;
 
			assert(iter != this->runs.End());
 

	
 
			next_run = this->buffer_begin + iter->first;
 
			begin = this->buffer;
 

	
 
@@ -571,13 +571,13 @@ const ParagraphLayouter::Line *FallbackP
 

	
 
		this->buffer++;
 
	}
 

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

	
 
/**
 
 * Helper for getting a ParagraphLayouter of the given type.
 
@@ -717,13 +717,13 @@ Layouter::Layouter(const char *str, int 
 
			}
 
		}
 

	
 
		/* Copy all lines into a local cache so we can reuse them later on more easily. */
 
		const ParagraphLayouter::Line *l;
 
		while ((l = line.layout->NextLine(maxw)) != NULL) {
 
			*this->Append() = l;
 
			this->push_back(l);
 
		}
 

	
 
	} while (c != '\0');
 
}
 

	
 
/**
 
@@ -831,13 +831,13 @@ const char *Layouter::GetCharAtPosition(
 
Font *Layouter::GetFont(FontSize size, TextColour colour)
 
{
 
	FontColourMap::iterator it = fonts[size].Find(colour);
 
	if (it != fonts[size].End()) return it->second;
 

	
 
	Font *f = new Font(size, colour);
 
	*fonts[size].Append() = FontColourMap::Pair(colour, f);
 
	fonts[size].emplace_back(colour, f);
 
	return f;
 
}
 

	
 
/**
 
 * Reset cached font information.
 
 * @param size Font size to reset.
src/graph_gui.cpp
Show inline comments
 
@@ -1137,13 +1137,13 @@ private:
 
		if (!this->companies.NeedRebuild()) return;
 

	
 
		this->companies.clear();
 

	
 
		const Company *c;
 
		FOR_ALL_COMPANIES(c) {
 
			*this->companies.Append() = c;
 
			this->companies.push_back(c);
 
		}
 

	
 
		this->companies.shrink_to_fit();
 
		this->companies.RebuildDone();
 
	}
 

	
src/group_gui.cpp
Show inline comments
 
@@ -126,14 +126,14 @@ private:
 
	Dimension column_size[VGC_END]; ///< Size of the columns in the group list.
 

	
 
	void AddChildren(GUIGroupList *source, GroupID parent, int indent)
 
	{
 
		for (const Group **g = source->Begin(); g != source->End(); g++) {
 
			if ((*g)->parent != parent) continue;
 
			*this->groups.Append() = *g;
 
			*this->indents.Append() = indent;
 
			this->groups.push_back(*g);
 
			this->indents.push_back(indent);
 
			AddChildren(source, (*g)->index, indent + 1);
 
		}
 
	}
 

	
 
	/** Sort the groups by their name */
 
	static int CDECL GroupNameSorter(const Group * const *a, const Group * const *b)
 
@@ -172,13 +172,13 @@ private:
 

	
 
		GUIGroupList list;
 

	
 
		const Group *g;
 
		FOR_ALL_GROUPS(g) {
 
			if (g->owner == owner && g->vehicle_type == this->vli.vtype) {
 
				*list.Append() = g;
 
				list.push_back(g);
 
			}
 
		}
 

	
 
		list.ForceResort();
 
		list.Sort(&GroupNameSorter);
 

	
src/hotkeys.cpp
Show inline comments
 
@@ -252,13 +252,13 @@ void Hotkey::AddKeycode(uint16 keycode)
 
}
 

	
 
HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandlerFunc global_hotkey_handler) :
 
	global_hotkey_handler(global_hotkey_handler), ini_group(ini_group), items(items)
 
{
 
	if (_hotkey_lists == NULL) _hotkey_lists = new SmallVector<HotkeyList*, 16>();
 
	*_hotkey_lists->Append() = this;
 
	_hotkey_lists->push_back(this);
 
}
 

	
 
HotkeyList::~HotkeyList()
 
{
 
	_hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this));
 
}
src/industry_gui.cpp
Show inline comments
 
@@ -1203,13 +1203,13 @@ protected:
 
	{
 
		if (this->industries.NeedRebuild()) {
 
			this->industries.clear();
 

	
 
			const Industry *i;
 
			FOR_ALL_INDUSTRIES(i) {
 
				*this->industries.Append() = i;
 
				this->industries.push_back(i);
 
			}
 

	
 
			this->industries.shrink_to_fit();
 
			this->industries.RebuildDone();
 
			this->vscroll->SetCount(this->industries.size()); // Update scrollbar as well.
 
		}
 
@@ -2412,33 +2412,35 @@ struct IndustryCargoesWindow : public Wi
 
		this->GetWidget<NWidgetCore>(WID_IC_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION;
 
		this->ind_cargo = it;
 
		_displayed_industries.reset();
 
		_displayed_industries.set(it);
 

	
 
		this->fields.clear();
 
		CargoesRow *row = this->fields.Append();
 
		row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
 
		row->columns[1].MakeEmpty(CFT_SMALL_EMPTY);
 
		row->columns[2].MakeEmpty(CFT_SMALL_EMPTY);
 
		row->columns[3].MakeEmpty(CFT_SMALL_EMPTY);
 
		row->columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
 
		/*C++17: CargoesRow &row = */ this->fields.emplace_back();
 
		CargoesRow &row = this->fields.back();
 
		row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
 
		row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
 
		row.columns[2].MakeEmpty(CFT_SMALL_EMPTY);
 
		row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
 
		row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
 

	
 
		const IndustrySpec *central_sp = GetIndustrySpec(it);
 
		bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
 
		bool houses_accept = HousesCanAccept(central_sp->produced_cargo, lengthof(central_sp->produced_cargo));
 
		/* Make a field consisting of two cargo columns. */
 
		int num_supp = CountMatchingProducingIndustries(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)) + houses_supply;
 
		int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)) + houses_accept;
 
		int num_indrows = max(3, max(num_supp, num_cust)); // One is needed for the 'it' industry, and 2 for the cargo labels.
 
		for (int i = 0; i < num_indrows; i++) {
 
			CargoesRow *row = this->fields.Append();
 
			row->columns[0].MakeEmpty(CFT_EMPTY);
 
			row->columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
 
			row->columns[2].MakeEmpty(CFT_EMPTY);
 
			row->columns[3].MakeCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo));
 
			row->columns[4].MakeEmpty(CFT_EMPTY);
 
			/*C++17: CargoesRow &row = */ this->fields.emplace_back();
 
			CargoesRow &row = this->fields.back();
 
			row.columns[0].MakeEmpty(CFT_EMPTY);
 
			row.columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo));
 
			row.columns[2].MakeEmpty(CFT_EMPTY);
 
			row.columns[3].MakeCargo(central_sp->produced_cargo, lengthof(central_sp->produced_cargo));
 
			row.columns[4].MakeEmpty(CFT_EMPTY);
 
		}
 
		/* Add central industry. */
 
		int central_row = 1 + num_indrows / 2;
 
		this->fields[central_row].columns[2].MakeIndustry(it);
 
		this->fields[central_row].ConnectIndustryProduced(2);
 
		this->fields[central_row].ConnectIndustryAccepted(2);
 
@@ -2490,31 +2492,33 @@ struct IndustryCargoesWindow : public Wi
 
	{
 
		this->GetWidget<NWidgetCore>(WID_IC_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_CARGO_CAPTION;
 
		this->ind_cargo = cid + NUM_INDUSTRYTYPES;
 
		_displayed_industries.reset();
 

	
 
		this->fields.clear();
 
		CargoesRow *row = this->fields.Append();
 
		row->columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
 
		row->columns[1].MakeEmpty(CFT_SMALL_EMPTY);
 
		row->columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
 
		row->columns[3].MakeEmpty(CFT_SMALL_EMPTY);
 
		row->columns[4].MakeEmpty(CFT_SMALL_EMPTY);
 
		/*C++17: CargoesRow &row = */ this->fields.emplace_back();
 
		CargoesRow &row = this->fields.back();
 
		row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS);
 
		row.columns[1].MakeEmpty(CFT_SMALL_EMPTY);
 
		row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS);
 
		row.columns[3].MakeEmpty(CFT_SMALL_EMPTY);
 
		row.columns[4].MakeEmpty(CFT_SMALL_EMPTY);
 

	
 
		bool houses_supply = HousesCanSupply(&cid, 1);
 
		bool houses_accept = HousesCanAccept(&cid, 1);
 
		int num_supp = CountMatchingProducingIndustries(&cid, 1) + houses_supply + 1; // Ensure room for the cargo label.
 
		int num_cust = CountMatchingAcceptingIndustries(&cid, 1) + houses_accept;
 
		int num_indrows = max(num_supp, num_cust);
 
		for (int i = 0; i < num_indrows; i++) {
 
			CargoesRow *row = this->fields.Append();
 
			row->columns[0].MakeEmpty(CFT_EMPTY);
 
			row->columns[1].MakeCargo(&cid, 1);
 
			row->columns[2].MakeEmpty(CFT_EMPTY);
 
			row->columns[3].MakeEmpty(CFT_EMPTY);
 
			row->columns[4].MakeEmpty(CFT_EMPTY);
 
			/*C++17: CargoesRow &row = */ this->fields.emplace_back();
 
			CargoesRow &row = this->fields.back();
 
			row.columns[0].MakeEmpty(CFT_EMPTY);
 
			row.columns[1].MakeCargo(&cid, 1);
 
			row.columns[2].MakeEmpty(CFT_EMPTY);
 
			row.columns[3].MakeEmpty(CFT_EMPTY);
 
			row.columns[4].MakeEmpty(CFT_EMPTY);
 
		}
 

	
 
		this->fields[num_indrows].MakeCargoLabel(0, false); // Add cargo labels at the left bottom.
 

	
 
		/* Add suppliers and customers of the cargo. */
 
		int supp_count = 0;
 
@@ -2705,13 +2709,13 @@ struct IndustryCargoesWindow : public Wi
 
				break;
 

	
 
			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);
 
					lst->push_back(new DropDownListStringItem(cs->name, cs->Index(), false));
 
				}
 
				if (lst->size() == 0) {
 
					delete lst;
 
					break;
 
				}
 
				int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
 
@@ -2722,13 +2726,13 @@ struct IndustryCargoesWindow : public Wi
 
			case WID_IC_IND_DROPDOWN: {
 
				DropDownList *lst = new DropDownList;
 
				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);
 
					lst->push_back(new DropDownListStringItem(indsp->name, ind, false));
 
				}
 
				if (lst->size() == 0) {
 
					delete lst;
 
					break;
 
				}
 
				int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;
src/linkgraph/linkgraph.cpp
Show inline comments
 
@@ -156,13 +156,13 @@ void LinkGraph::RemoveNode(NodeID id)
 
 */
 
NodeID LinkGraph::AddNode(const Station *st)
 
{
 
	const GoodsEntry &good = st->goods[this->cargo];
 

	
 
	NodeID new_node = this->Size();
 
	this->nodes.Append();
 
	this->nodes.emplace_back();
 
	/* Avoid reducing the height of the matrix as that is expensive and we
 
	 * most likely will increase it again later which is again expensive. */
 
	this->edges.Resize(new_node + 1U,
 
			max(new_node + 1U, this->edges.Height()));
 

	
 
	this->nodes[new_node].Init(st->xy, st->index,
src/music/midifile.cpp
Show inline comments
 
@@ -18,13 +18,12 @@
 
#include "midi.h"
 
#include <algorithm>
 

	
 
#include "../console_func.h"
 
#include "../console_internal.h"
 

	
 

	
 
/* SMF reader based on description at: http://www.somascape.org/midi/tech/mfile.html */
 

	
 

	
 
static MidiFile *_midifile_instance = NULL;
 

	
 
/**
 
@@ -214,22 +213,22 @@ static bool ReadTrackChunk(FILE *file, M
 
				case MIDIST_NOTEOFF:
 
				case MIDIST_NOTEON:
 
				case MIDIST_POLYPRESS:
 
				case MIDIST_CONTROLLER:
 
				case MIDIST_PITCHBEND:
 
					/* 3 byte messages */
 
					data = block->data.Append(3);
 
					data = grow(block->data, 3);
 
					data[0] = status;
 
					if (!chunk.ReadBuffer(&data[1], 2)) {
 
						return false;
 
					}
 
					break;
 
				case MIDIST_PROGCHG:
 
				case MIDIST_CHANPRESS:
 
					/* 2 byte messages */
 
					data = block->data.Append(2);
 
					data = grow(block->data, 2);
 
					data[0] = status;
 
					if (!chunk.ReadByte(data[1])) {
 
						return false;
 
					}
 
					break;
 
				default:
 
@@ -264,31 +263,31 @@ static bool ReadTrackChunk(FILE *file, M
 
		} else if (status == MIDIST_SYSEX || (status == MIDIST_SMF_ESCAPE  && running_sysex)) {
 
			/* System exclusive message */
 
			uint32 length = 0;
 
			if (!chunk.ReadVariableLength(length)) {
 
				return false;
 
			}
 
			byte *data = block->data.Append(length + 1);
 
			byte *data = grow(block->data, length + 1);
 
			data[0] = 0xF0;
 
			if (!chunk.ReadBuffer(data + 1, length)) {
 
				return false;
 
			}
 
			if (data[length] != 0xF7) {
 
				/* Engage Casio weirdo mode - convert to normal sysex */
 
				running_sysex = true;
 
				*block->data.Append() = 0xF7;
 
				block->data.push_back(0xF7);
 
			} else {
 
				running_sysex = false;
 
			}
 
		} else if (status == MIDIST_SMF_ESCAPE) {
 
			/* Escape sequence */
 
			uint32 length = 0;
 
			if (!chunk.ReadVariableLength(length)) {
 
				return false;
 
			}
 
			byte *data = block->data.Append(length);
 
			byte *data = grow(block->data, length);
 
			if (!chunk.ReadBuffer(data, length)) {
 
				return false;
 
			}
 
		} else {
 
			/* Messages undefined in standard midi files:
 
			 * 0xF1 - MIDI time code quarter frame
 
@@ -333,13 +332,13 @@ static bool FixupMidiData(MidiFile &targ
 
		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.size());
 
			byte *datadest = grow(merged_blocks.back().data, block.data.size());
 
			memcpy(datadest, block.data.Begin(), block.data.size());
 
		}
 
	}
 
	std::swap(merged_blocks, target.blocks);
 

	
 
	/* Annotate blocks with real time */
 
@@ -505,20 +504,20 @@ struct MpsMachine {
 
		MPSMIDIST_SEGMENT_CALL   = 0xFE, ///< store current position of master track playback, and begin playback of a segment
 
		MPSMIDIST_ENDSONG        = 0xFF, ///< immediately end the song
 
	};
 

	
 
	static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2)
 
	{
 
		*block.data.Append() = b1;
 
		*block.data.Append() = b2;
 
		block.data.push_back(b1);
 
		block.data.push_back(b2);
 
	}
 
	static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2, byte b3)
 
	{
 
		*block.data.Append() = b1;
 
		*block.data.Append() = b2;
 
		*block.data.Append() = b3;
 
		block.data.push_back(b1);
 
		block.data.push_back(b2);
 
		block.data.push_back(b3);
 
	}
 

	
 
	/**
 
	 * Construct a TTD DOS music format decoder.
 
	 * @param data Buffer of song data from CAT file, ownership remains with caller
 
	 * @param length Length of the data buffer in bytes
src/network/core/host.cpp
Show inline comments
 
@@ -97,13 +97,13 @@ static void NetworkFindBroadcastIPsInter
 
	for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
 
		if (!(ifa->ifa_flags & IFF_BROADCAST)) continue;
 
		if (ifa->ifa_broadaddr == NULL) continue;
 
		if (ifa->ifa_broadaddr->sa_family != AF_INET) continue;
 

	
 
		NetworkAddress addr(ifa->ifa_broadaddr, sizeof(sockaddr));
 
		if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) *broadcast->Append() = addr;
 
		if (std::none_of(broadcast->begin(), broadcast->end(), [&addr](NetworkAddress const& elem) -> bool { return elem == addr; })) broadcast->push_back(addr);
 
	}
 
	freeifaddrs(ifap);
 
}
 

	
 
#elif defined(_WIN32)
 
static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // Win32 implementation
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -29,13 +29,13 @@ TCPConnecter::TCPConnecter(const Network
 
	connected(false),
 
	aborted(false),
 
	killed(false),
 
	sock(INVALID_SOCKET),
 
	address(address)
 
{
 
	*_tcp_connecters.Append() = this;
 
	_tcp_connecters.push_back(this);
 
	if (!ThreadObject::New(TCPConnecter::ThreadEntry, this, &this->thread, "ottd:tcp")) {
 
		this->Connect();
 
	}
 
}
 

	
 
/** The actual connection function */
src/network/core/tcp_http.cpp
Show inline comments
 
@@ -60,13 +60,13 @@ NetworkHTTPSocketHandler::NetworkHTTPSoc
 
		 * of information? Just fall back to the old system! */
 
		this->callback->OnFailure();
 
		delete this;
 
		return;
 
	}
 

	
 
	*_http_connections.Append() = this;
 
	_http_connections.push_back(this);
 
}
 

	
 
/** Free whatever needs to be freed. */
 
NetworkHTTPSocketHandler::~NetworkHTTPSocketHandler()
 
{
 
	this->CloseConnection();
src/network/core/udp.cpp
Show inline comments
 
@@ -23,20 +23,20 @@
 
 * @param bind the addresses to bind to.
 
 */
 
NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind)
 
{
 
	if (bind != NULL) {
 
		for (NetworkAddress *addr = bind->Begin(); addr != bind->End(); addr++) {
 
			*this->bind.Append() = *addr;
 
			this->bind.push_back(*addr);
 
		}
 
	} else {
 
		/* As hostname NULL and port 0/NULL don't go well when
 
		 * resolving it we need to add an address for each of
 
		 * the address families we support. */
 
		*this->bind.Append() = NetworkAddress(NULL, 0, AF_INET);
 
		*this->bind.Append() = NetworkAddress(NULL, 0, AF_INET6);
 
		this->bind.emplace_back(nullptr, 0, AF_INET);
 
		this->bind.emplace_back(nullptr, 0, AF_INET6);
 
	}
 
}
 

	
 

	
 
/**
 
 * Start listening on the given host and port.
src/network/network.cpp
Show inline comments
 
@@ -630,30 +630,30 @@ void NetworkAddServer(const char *b)
 
 * @param addresses the list to write to.
 
 * @param port the port to bind to.
 
 */
 
void GetBindAddresses(NetworkAddressList *addresses, uint16 port)
 
{
 
	for (char **iter = _network_bind_list.Begin(); iter != _network_bind_list.End(); iter++) {
 
		*addresses->Append() = NetworkAddress(*iter, port);
 
		addresses->emplace_back(*iter, port);
 
	}
 

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

	
 
/* Generates the list of manually added hosts from NetworkGameList and
 
 * dumps them into the array _network_host_list. This array is needed
 
 * by the function that generates the config file. */
 
void NetworkRebuildHostList()
 
{
 
	_network_host_list.Clear();
 

	
 
	for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
 
		if (item->manually) *_network_host_list.Append() = stredup(item->address.GetAddressAsString(false));
 
		if (item->manually) _network_host_list.push_back(stredup(item->address.GetAddressAsString(false)));
 
	}
 
}
 

	
 
/** Non blocking connection create to actually connect to servers */
 
class TCPClientConnecter : TCPConnecter {
 
public:
src/network/network_client.cpp
Show inline comments
 
@@ -74,13 +74,13 @@ struct PacketReader : LoadFilter {
 
		/* Did everything fit in the current chunk, then we're done. */
 
		if (to_write == in_packet) return;
 

	
 
		/* Allocate a new chunk and add the remaining data. */
 
		pbuf += to_write;
 
		to_write   = in_packet - to_write;
 
		this->buf  = *this->blocks.Append() = CallocT<byte>(CHUNK);
 
		this->blocks.push_back(this->buf = CallocT<byte>(CHUNK));
 
		this->bufe = this->buf + CHUNK;
 

	
 
		memcpy(this->buf, pbuf, to_write);
 
		this->buf += to_write;
 
	}
 

	
src/network/network_content.cpp
Show inline comments
 
@@ -162,13 +162,13 @@ bool ClientNetworkContentSocketHandler::
 
	/* Missing content info? Don't list it */
 
	if (ci->filesize == 0) {
 
		delete ci;
 
		return true;
 
	}
 

	
 
	*this->infos.Append() = ci;
 
	this->infos.push_back(ci);
 

	
 
	/* Incoming data means that we might need to reconsider dependencies */
 
	for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
 
		this->CheckDependencyState(*iter);
 
	}
 

	
 
@@ -275,13 +275,13 @@ void ClientNetworkContentSocketHandler::
 
					(!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) {
 
				found = true;
 
				break;
 
			}
 
		}
 
		if (!found) {
 
			*this->infos.Append() = ci;
 
			this->infos.push_back(ci);
 
		} else {
 
			delete ci;
 
		}
 
	}
 
}
 

	
 
@@ -297,13 +297,13 @@ void ClientNetworkContentSocketHandler::
 

	
 
	ContentIDList content;
 
	for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
 
		const ContentInfo *ci = *iter;
 
		if (!ci->IsSelected() || ci->state == ContentInfo::ALREADY_HERE) continue;
 

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

	
 
	files = content.size();
 

	
 
	/* If there's nothing to download, do nothing. */
 
@@ -576,17 +576,17 @@ void ClientNetworkContentSocketHandler::
 
	/* Ignore any latent data coming from a connection we closed. */
 
	if (this->http_response_index == -2) return;
 

	
 
	if (this->http_response_index == -1) {
 
		if (data != NULL) {
 
			/* Append the rest of the response. */
 
			memcpy(this->http_response.Append((uint)length), data, length);
 
			memcpy(grow(this->http_response, (uint)length), data, length);
 
			return;
 
		} else {
 
			/* Make sure the response is properly terminated. */
 
			*this->http_response.Append() = '\0';
 
			this->http_response.push_back('\0');
 

	
 
			/* And prepare for receiving the rest of the data. */
 
			this->http_response_index = 0;
 
		}
 
	}
 

	
 
@@ -902,13 +902,13 @@ void ClientNetworkContentSocketHandler::
 
	for (ConstContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) {
 
		const ContentInfo *ci = *iter;
 
		if (ci == child) continue;
 

	
 
		for (uint i = 0; i < ci->dependency_count; i++) {
 
			if (ci->dependencies[i] == child->id) {
 
				*parents.Append() = ci;
 
				parents.push_back(ci);
 
				break;
 
			}
 
		}
 
	}
 
}
 

	
 
@@ -916,13 +916,13 @@ void ClientNetworkContentSocketHandler::
 
 * Reverse lookup the dependencies of all parents over a given child.
 
 * @param tree  list to store all parents in (is not cleared)
 
 * @param child the child to search the parents' dependencies for
 
 */
 
void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const
 
{
 
	*tree.Append() = child;
 
	tree.push_back(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.size(); i++) {
src/network/network_content_gui.cpp
Show inline comments
 
@@ -388,13 +388,13 @@ class NetworkContentListWindow : public 
 
		this->content.clear();
 

	
 
		bool all_available = true;
 

	
 
		for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
 
			if ((*iter)->state == ContentInfo::DOES_NOT_EXIST) all_available = false;
 
			*this->content.Append() = *iter;
 
			this->content.push_back(*iter);
 
		}
 

	
 
		this->SetWidgetDisabledState(WID_NCL_SEARCH_EXTERNAL, this->auto_select && all_available);
 

	
 
		this->FilterContentList();
 
		this->content.shrink_to_fit();
src/network/network_gui.cpp
Show inline comments
 
@@ -250,13 +250,13 @@ protected:
 
		if (!this->servers.NeedRebuild()) return;
 

	
 
		/* Create temporary array of games to use for listing */
 
		this->servers.clear();
 

	
 
		for (NetworkGameList *ngl = _network_game_list; ngl != NULL; ngl = ngl->next) {
 
			*this->servers.Append() = ngl;
 
			this->servers.push_back(ngl);
 
		}
 

	
 
		/* Apply the filter condition immediately, if a search string has been provided. */
 
		StringFilter sf;
 
		sf.SetFilterTerm(this->filter_editbox.text.buf);
 

	
 
@@ -1734,15 +1734,13 @@ struct NetworkClientListPopupWindow : Wi
 
	 * Add an action to the list of actions to execute.
 
	 * @param name the name of the action
 
	 * @param proc the procedure to execute for the action
 
	 */
 
	inline void AddAction(StringID name, ClientList_Action_Proc *proc)
 
	{
 
		ClientListAction *action = this->actions.Append();
 
		action->name = name;
 
		action->proc = proc;
 
		this->actions.push_back({name, proc});
 
	}
 

	
 
	NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) :
 
			Window(desc),
 
			sel_index(0), client_id(client_id)
 
	{
src/network/network_server.cpp
Show inline comments
 
@@ -2098,13 +2098,13 @@ uint NetworkServerKickOrBanIP(const char
 
		for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
 
			if (strcmp(*iter, ip) == 0) {
 
				contains = true;
 
				break;
 
			}
 
		}
 
		if (!contains) *_network_ban_list.Append() = stredup(ip);
 
		if (!contains) _network_ban_list.push_back(stredup(ip));
 
	}
 

	
 
	uint n = 0;
 

	
 
	/* There can be multiple clients with the same IP, kick them all */
 
	NetworkClientSocket *cs;
src/newgrf.cpp
Show inline comments
 
@@ -469,16 +469,13 @@ static StringIDMappingVector _string_to_
 
 * @param source Source StringID (GRF local).
 
 * @param target Destination for the mapping result.
 
 */
 
static void AddStringForMapping(StringID source, StringID *target)
 
{
 
	*target = STR_UNDEFINED;
 
	StringIDMapping *item = _string_to_grf_mapping.Append();
 
	item->grfid = _cur.grffile->grfid;
 
	item->source = source;
 
	item->target = target;
 
	_string_to_grf_mapping.push_back({_cur.grffile->grfid, source, target});
 
}
 

	
 
/**
 
 * Perform a mapping from TTDPatch's string IDs to OpenTTD's
 
 * string IDs, but only for the ones we are aware off; the rest
 
 * like likely unused and will show a warning.
 
@@ -656,17 +653,18 @@ 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.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"
 
	_engine_mngr.push_back({
 
			scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation
 
			internal_id,
 
			{static_cast<byte>(type)},
 
			static_cast<uint8>(min(internal_id, _engine_counts[type])) // substitute_id == _engine_counts[subtype] means "no substitute"
 
	});
 

	
 
	if (engine_pool_size != Engine::GetPoolSize()) {
 
		/* Resize temporary engine data ... */
 
		_gted = ReallocT(_gted, Engine::GetPoolSize());
 

	
 
		/* and blank the new block. */
 
@@ -1906,24 +1904,25 @@ static ChangeInfoResult StationChangeInf
 
					if (_cur.skip_sprites < 0) return CIR_DISABLED;
 

	
 
					static SmallVector<DrawTileSeqStruct, 8> tmp_layout;
 
					tmp_layout.clear();
 
					for (;;) {
 
						/* no relative bounding box support */
 
						DrawTileSeqStruct *dtss = tmp_layout.Append();
 
						MemSetT(dtss, 0);
 

	
 
						dtss->delta_x = buf->ReadByte();
 
						if (dtss->IsTerminator()) break;
 
						dtss->delta_y = buf->ReadByte();
 
						dtss->delta_z = buf->ReadByte();
 
						dtss->size_x = buf->ReadByte();
 
						dtss->size_y = buf->ReadByte();
 
						dtss->size_z = buf->ReadByte();
 

	
 
						ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss->image);
 
						/*C++17: DrawTileSeqStruct &dtss = */ tmp_layout.emplace_back();
 
						DrawTileSeqStruct &dtss = tmp_layout.back();
 
						MemSetT(&dtss, 0);
 

	
 
						dtss.delta_x = buf->ReadByte();
 
						if (dtss.IsTerminator()) break;
 
						dtss.delta_y = buf->ReadByte();
 
						dtss.delta_z = buf->ReadByte();
 
						dtss.size_x = buf->ReadByte();
 
						dtss.size_y = buf->ReadByte();
 
						dtss.size_z = buf->ReadByte();
 

	
 
						ReadSpriteLayoutSprite(buf, false, true, false, GSF_STATIONS, &dtss.image);
 
						/* On error, bail out immediately. Temporary GRF data was already freed */
 
						if (_cur.skip_sprites < 0) return CIR_DISABLED;
 
					}
 
					dts->Clone(tmp_layout.Begin());
 
				}
 
				break;
 
@@ -2591,13 +2590,13 @@ static ChangeInfoResult LoadTranslationT
 
		return CIR_INVALID_ID;
 
	}
 

	
 
	translation_table.clear();
 
	for (int i = 0; i < numinfo; i++) {
 
		uint32 item = buf->ReadDWord();
 
		*translation_table.Append() = BSWAP32(item);
 
		translation_table.push_back(BSWAP32(item));
 
	}
 

	
 
	return CIR_SUCCESS;
 
}
 

	
 
/**
 
@@ -2796,20 +2795,20 @@ static ChangeInfoResult GlobalVarChangeI
 
					map.newgrf_id = newgrf_id;
 
					if (prop == 0x13) {
 
						map.openttd_id = lang->GetGenderIndex(name);
 
						if (map.openttd_id >= MAX_NUM_GENDERS) {
 
							grfmsg(1, "GlobalVarChangeInfo: Gender name %s is not known, ignoring", name);
 
						} else {
 
							*_cur.grffile->language_map[curidx].gender_map.Append() = map;
 
							_cur.grffile->language_map[curidx].gender_map.push_back(map);
 
						}
 
					} else {
 
						map.openttd_id = lang->GetCaseIndex(name);
 
						if (map.openttd_id >= MAX_NUM_CASES) {
 
							grfmsg(1, "GlobalVarChangeInfo: Case name %s is not known, ignoring", name);
 
						} else {
 
							*_cur.grffile->language_map[curidx].case_map.Append() = map;
 
							_cur.grffile->language_map[curidx].case_map.push_back(map);
 
						}
 
					}
 
					newgrf_id = buf->ReadByte();
 
				}
 
				break;
 
			}
 
@@ -4332,13 +4331,13 @@ static ChangeInfoResult RailTypeReserveI
 
				break;
 

	
 
			case 0x1D: // Alternate rail type label list
 
				if (_cur.grffile->railtype_map[id + i] != INVALID_RAILTYPE) {
 
					int n = buf->ReadByte();
 
					for (int j = 0; j != n; j++) {
 
						*_railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.Append() = BSWAP32(buf->ReadDWord());
 
						_railtypes[_cur.grffile->railtype_map[id + i]].alternate_labels.push_back(BSWAP32(buf->ReadDWord()));
 
					}
 
					break;
 
				}
 
				grfmsg(1, "RailTypeReserveInfo: Ignoring property 1D for rail type %u because no label was set", id + i);
 
				FALLTHROUGH;
 

	
 
@@ -4793,35 +4792,36 @@ static void NewSpriteGroup(ByteReader *b
 
			static SmallVector<DeterministicSpriteGroupAdjust, 16> adjusts;
 
			adjusts.clear();
 

	
 
			/* 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();
 
				/*C++17: DeterministicSpriteGroupAdjust &adjust = */ adjusts.emplace_back();
 
				DeterministicSpriteGroupAdjust &adjust = adjusts.back();
 

	
 
				/* The first var adjust doesn't have an operation specified, so we set it to add. */
 
				adjust->operation = adjusts.size() == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)buf->ReadByte();
 
				adjust->variable  = buf->ReadByte();
 
				if (adjust->variable == 0x7E) {
 
				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());
 
					adjust.subroutine = GetGroupFromGroupID(setid, type, buf->ReadByte());
 
				} else {
 
					adjust->parameter = IsInsideMM(adjust->variable, 0x60, 0x80) ? buf->ReadByte() : 0;
 
					adjust.parameter = IsInsideMM(adjust.variable, 0x60, 0x80) ? buf->ReadByte() : 0;
 
				}
 

	
 
				varadjust = buf->ReadByte();
 
				adjust->shift_num = GB(varadjust, 0, 5);
 
				adjust->type      = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2);
 
				adjust->and_mask  = buf->ReadVarSize(varsize);
 

	
 
				if (adjust->type != DSGA_TYPE_NONE) {
 
					adjust->add_val    = buf->ReadVarSize(varsize);
 
					adjust->divmod_val = buf->ReadVarSize(varsize);
 
				adjust.shift_num = GB(varadjust, 0, 5);
 
				adjust.type      = (DeterministicSpriteGroupAdjustType)GB(varadjust, 6, 2);
 
				adjust.and_mask  = buf->ReadVarSize(varsize);
 

	
 
				if (adjust.type != DSGA_TYPE_NONE) {
 
					adjust.add_val    = buf->ReadVarSize(varsize);
 
					adjust.divmod_val = buf->ReadVarSize(varsize);
 
				} else {
 
					adjust->add_val    = 0;
 
					adjust->divmod_val = 0;
 
					adjust.add_val    = 0;
 
					adjust.divmod_val = 0;
 
				}
 

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

	
 
			group->num_adjusts = adjusts.size();
 
@@ -7848,15 +7848,13 @@ static bool HandleParameterInfo(ByteRead
 
			if (!SkipUnknownInfo(buf, type)) return false;
 
			type = buf->ReadByte();
 
			continue;
 
		}
 

	
 
		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);
 
			_cur.grfconfig->param_info.resize(id + 1);
 
		}
 
		if (_cur.grfconfig->param_info[id] == NULL) {
 
			_cur.grfconfig->param_info[id] = new GRFParameterInfo(id);
 
		}
 
		_cur_parameter = _cur.grfconfig->param_info[id];
 
		/* Read all parameter-data and process each node. */
 
@@ -8402,13 +8400,13 @@ static void InitNewGRFFile(const GRFConf
 
		/* We already loaded it once. */
 
		_cur.grffile = newfile;
 
		return;
 
	}
 

	
 
	newfile = new GRFFile(config);
 
	*_grf_files.Append() = _cur.grffile = newfile;
 
	_grf_files.push_back(_cur.grffile = newfile);
 
}
 

	
 
/**
 
 * Constructor for GRFFile
 
 * @param config GRFConfig to copy name, grfid and parameters from.
 
 */
src/newgrf_commons.cpp
Show inline comments
 
@@ -663,24 +663,25 @@ uint32 NewGRFSpriteLayout::PrepareLayout
 
{
 
	result_seq.clear();
 
	uint32 var10_values = 0;
 

	
 
	/* Create a copy of the spritelayout, so we can modify some values.
 
	 * Also include the groundsprite into the sequence for easier processing. */
 
	DrawTileSeqStruct *result = result_seq.Append();
 
	/*C++17: DrawTileSeqStruct *result = &*/ result_seq.emplace_back();
 
	DrawTileSeqStruct *result = &result_seq.back();
 
	result->image = ground;
 
	result->delta_x = 0;
 
	result->delta_y = 0;
 
	result->delta_z = (int8)0x80;
 

	
 
	const DrawTileSeqStruct *dtss;
 
	foreach_draw_tile_seq(dtss, this->seq) {
 
		*result_seq.Append() = *dtss;
 
		result_seq.push_back(*dtss);
 
	}
 
	result_seq.Append()->MakeTerminator();
 

	
 
	result_seq.emplace_back() /*C++17: .MakeTerminator()*/;
 
	result_seq.back().MakeTerminator();
 
	/* Determine the var10 values the action-1-2-3 chains needs to be resolved for,
 
	 * and apply the default sprite offsets (unless disabled). */
 
	const TileLayoutRegisters *regs = this->registers;
 
	bool ground = true;
 
	foreach_draw_tile_seq(result, result_seq.Begin()) {
 
		TileLayoutFlags flags = TLF_NOTHING;
src/newgrf_config.cpp
Show inline comments
 
@@ -82,15 +82,15 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
	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.size(); i++) {
 
		if (config.param_info[i] == NULL) {
 
			*this->param_info.Append() = NULL;
 
			this->param_info.push_back(NULL);
 
		} else {
 
			*this->param_info.Append() = new GRFParameterInfo(*config.param_info[i]);
 
			this->param_info.push_back(new GRFParameterInfo(*config.param_info[i]));
 
		}
 
	}
 
}
 

	
 
/** Cleanup a GRFConfig object. */
 
GRFConfig::~GRFConfig()
 
@@ -608,15 +608,15 @@ compatible_grf:
 
				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.size(); i++) {
 
					if (f->param_info[i] == NULL) {
 
						*c->param_info.Append() = NULL;
 
						c->param_info.push_back(NULL);
 
					} else {
 
						*c->param_info.Append() = new GRFParameterInfo(*f->param_info[i]);
 
						c->param_info.push_back(new GRFParameterInfo(*f->param_info[i]));
 
					}
 
				}
 
			}
 
		}
 
	}
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -1193,15 +1193,13 @@ static SmallVector<ListOrderChange, 16> 
 
 * @param target Local engine ID to move \a engine in front of
 
 * @note All sorting is done later in CommitVehicleListOrderChanges
 
 */
 
void AlterVehicleListOrder(EngineID engine, uint target)
 
{
 
	/* Add the list order change to a queue */
 
	ListOrderChange *loc = _list_order_changes.Append();
 
	loc->engine = engine;
 
	loc->target = target;
 
	_list_order_changes.push_back({engine, target});
 
}
 

	
 
/**
 
 * Comparator function to sort engines via scope-GRFID and local ID.
 
 * @param a left side
 
 * @param b right side
 
@@ -1228,13 +1226,13 @@ static int CDECL EnginePreSort(const Eng
 
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;
 
		ordering.push_back(e->index);
 
	}
 
	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) {
src/newgrf_gui.cpp
Show inline comments
 
@@ -375,13 +375,13 @@ struct NewGRFParametersWindow : public W
 
						if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
 
							this->clicked_dropdown = true;
 
							this->closing_dropdown = false;
 

	
 
							DropDownList *list = new DropDownList();
 
							for (uint32 i = par_info->min_value; i <= par_info->max_value; i++) {
 
								*list->Append() = new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false);
 
								list->push_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false));
 
							}
 

	
 
							ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true);
 
						}
 
					}
 
				} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
 
@@ -924,17 +924,17 @@ struct NewGRFWindow : public Window, New
 

	
 
		switch (widget) {
 
			case WID_NS_PRESET_LIST: {
 
				DropDownList *list = new DropDownList();
 

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

	
 
				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);
 
						list->push_back(new DropDownListCharStringItem(_grf_preset_list[i], i, false));
 
					}
 
				}
 

	
 
				this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
 
				ShowDropDownList(this, list, this->preset, WID_NS_PRESET_LIST);
 
				break;
 
@@ -1461,24 +1461,24 @@ private:
 
		for (const GRFConfig *c = _all_grfs; c != NULL; c = c->next) {
 
			bool found = false;
 
			for (const GRFConfig *grf = this->actives; grf != NULL && !found; grf = grf->next) found = grf->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum);
 
			if (found) continue;
 

	
 
			if (_settings_client.gui.newgrf_show_old_versions) {
 
				*this->avails.Append() = c;
 
				this->avails.push_back(c);
 
			} else {
 
				const GRFConfig *best = FindGRFConfig(c->ident.grfid, HasBit(c->flags, GCF_INVALID) ? FGCM_NEWEST : FGCM_NEWEST_VALID);
 
				/*
 
				 * If the best version is 0, then all NewGRF with this GRF ID
 
				 * have version 0, so for backward compatibility reasons we
 
				 * want to show them all.
 
				 * If we are the best version, then we definitely want to
 
				 * show that NewGRF!.
 
				 */
 
				if (best->version == 0 || best->ident.HasGrfIdentifier(c->ident.grfid, c->ident.md5sum)) {
 
					*this->avails.Append() = c;
 
					this->avails.push_back(c);
 
				}
 
			}
 
		}
 

	
 
		this->avails.Filter(this->string_filter);
 
		this->avails.shrink_to_fit();
 
@@ -1555,13 +1555,13 @@ void ShowMissingContentWindow(const GRFC
 
		ContentInfo *ci = new ContentInfo();
 
		ci->type = CONTENT_TYPE_NEWGRF;
 
		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;
 
		cv.push_back(ci);
 
	}
 
	ShowNetworkContentListWindow(cv.size() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
}
 

	
 
Listing NewGRFWindow::last_sorting     = {false, 0};
 
Filtering NewGRFWindow::last_filtering = {false, 0};
src/newgrf_sound.cpp
Show inline comments
 
@@ -29,13 +29,13 @@ static SmallVector<SoundEntry, 8> _sound
 
 * Allocate sound slots.
 
 * @param num Number of slots to allocate.
 
 * @return First allocated slot.
 
 */
 
SoundEntry *AllocateSound(uint num)
 
{
 
	SoundEntry *sound = _sounds.Append(num);
 
	SoundEntry *sound = grow(_sounds, num);
 
	MemSetT(sound, 0, num);
 
	return sound;
 
}
 

	
 

	
 
void InitializeSoundPool()
src/object_cmd.cpp
Show inline comments
 
@@ -527,15 +527,13 @@ static CommandCost ClearTile_Object(Tile
 
			break;
 

	
 
		default:
 
			break;
 
	}
 

	
 
	ClearedObjectArea *cleared_area = _cleared_object_areas.Append();
 
	cleared_area->first_tile = tile;
 
	cleared_area->area = ta;
 
	_cleared_object_areas.push_back({tile, ta});
 

	
 
	if (flags & DC_EXEC) ReallyClearObjectTile(o);
 

	
 
	return cost;
 
}
 

	
src/openttd.cpp
Show inline comments
 
@@ -442,13 +442,13 @@ struct AfterNewGRFScan : NewGRFScanCallb
 

	
 
		if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
 
		if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 

	
 
		if (dedicated_host != NULL) {
 
			_network_bind_list.Clear();
 
			*_network_bind_list.Append() = stredup(dedicated_host);
 
			_network_bind_list.push_back(stredup(dedicated_host));
 
		}
 
		if (dedicated_port != 0) _settings_client.network.server_port = dedicated_port;
 

	
 
		/* initialize the ingame console */
 
		IConsoleInit();
 
		InitializeGUI();
 
@@ -1174,13 +1174,13 @@ static void CheckCaches()
 
	if (_debug_desync_level <= 1) return;
 

	
 
	/* Check the town caches. */
 
	SmallVector<TownCache, 4> old_town_caches;
 
	Town *t;
 
	FOR_ALL_TOWNS(t) {
 
		MemCpyT(old_town_caches.Append(), &t->cache);
 
		old_town_caches.push_back(t->cache);
 
	}
 

	
 
	extern void RebuildTownCaches();
 
	RebuildTownCaches();
 
	RebuildSubsidisedSourceAndDestinationCache();
 

	
 
@@ -1192,13 +1192,13 @@ static void CheckCaches()
 
		i++;
 
	}
 

	
 
	/* Check company infrastructure cache. */
 
	SmallVector<CompanyInfrastructure, 4> old_infrastructure;
 
	Company *c;
 
	FOR_ALL_COMPANIES(c) MemCpyT(old_infrastructure.Append(), &c->infrastructure);
 
	FOR_ALL_COMPANIES(c) old_infrastructure.push_back(c->infrastructure);
 

	
 
	extern void AfterLoadCompanyStats();
 
	AfterLoadCompanyStats();
 

	
 
	i = 0;
 
	FOR_ALL_COMPANIES(c) {
src/order_gui.cpp
Show inline comments
 
@@ -1294,13 +1294,13 @@ public:
 
				ShowTimetableWindow(this->vehicle);
 
				break;
 

	
 
			case WID_O_COND_VARIABLE: {
 
				DropDownList *list = new DropDownList();
 
				for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
 
					*list->Append() = new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false);
 
					list->push_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
 
				}
 
				ShowDropDownList(this, list, this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
 
				break;
 
			}
 

	
 
			case WID_O_COND_COMPARATOR: {
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -75,13 +75,13 @@ public:
 

	
 
				/* Extract font information for this run. */
 
				CFRange chars = CTRunGetStringRange(run);
 
				FontMap::const_iterator map = fontMapping.Begin();
 
				while (map < fontMapping.End() - 1 && map->first <= chars.location) map++;
 

	
 
				*this->Append() = new CoreTextVisualRun(run, map->second, buff);
 
				this->push_back(new CoreTextVisualRun(run, map->second, buff));
 
			}
 
			CFRelease(line);
 
		}
 

	
 
		virtual int GetLeading() const;
 
		virtual int GetWidth() const;
src/rail_cmd.cpp
Show inline comments
 
@@ -1620,13 +1620,13 @@ CommandCost CmdConvertRail(TileIndex til
 
				Track     track;
 
				while ((track = RemoveFirstTrack(&reserved)) != INVALID_TRACK) {
 
					Train *v = GetTrainForReservation(tile, track);
 
					if (v != NULL && !HasPowerOnRail(v->railtype, totype)) {
 
						/* No power on new rail type, reroute. */
 
						FreeTrainTrackReservation(v);
 
						*vehicles_affected.Append() = v;
 
						vehicles_affected.push_back(v);
 
					}
 
				}
 

	
 
				/* Update the company infrastructure counters. */
 
				if (!IsRailStationTile(tile) || !IsStationTileBlocked(tile)) {
 
					Company *c = Company::Get(GetTileOwner(tile));
 
@@ -1702,13 +1702,13 @@ CommandCost CmdConvertRail(TileIndex til
 
					Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile));
 
					if (HasTunnelBridgeReservation(tile)) {
 
						Train *v = GetTrainForReservation(tile, track);
 
						if (v != NULL && !HasPowerOnRail(v->railtype, totype)) {
 
							/* No power on new rail type, reroute. */
 
							FreeTrainTrackReservation(v);
 
							*vehicles_affected.Append() = v;
 
							vehicles_affected.push_back(v);
 
						}
 
					}
 

	
 
					/* Update the company infrastructure counters. */
 
					uint num_pieces = (GetTunnelBridgeLength(tile, endtile) + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
 
					Company *c = Company::Get(GetTileOwner(tile));
src/rail_gui.cpp
Show inline comments
 
@@ -2004,13 +2004,13 @@ DropDownList *GetRailTypeDropDownList(bo
 

	
 
	const Company *c = Company::Get(_local_company);
 
	DropDownList *list = new DropDownList();
 

	
 
	if (all_option) {
 
		DropDownListStringItem *item = new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false);
 
		*list->Append() = item;
 
		list->push_back(item);
 
	}
 

	
 
	Dimension d = { 0, 0 };
 
	RailType rt;
 
	/* Get largest icon size, to ensure text is aligned on each menu item. */
 
	if (!for_replacement) {
 
@@ -2035,10 +2035,10 @@ DropDownList *GetRailTypeDropDownList(bo
 
			DropDownListIconItem *iconitem = new DropDownListIconItem(rti->gui_sprites.build_x_rail, PAL_NONE, str, rt, !HasBit(c->avail_railtypes, rt));
 
			iconitem->SetDimension(d);
 
			item = iconitem;
 
		}
 
		item->SetParam(0, rti->strings.menu_text);
 
		item->SetParam(1, rti->max_speed);
 
		*list->Append() = item;
 
		list->push_back(item);
 
	}
 
	return list;
 
}
src/saveload/afterload.cpp
Show inline comments
 
@@ -2951,30 +2951,30 @@ bool AfterLoadGame()
 
					prev_tile_skip = cur_skip;
 
					prev_tile = u->tile;
 
				} else {
 
					cur_skip = prev_tile_skip;
 
				}
 

	
 
				uint *this_skip = skip_frames.Append();
 
				*this_skip = prev_tile_skip;
 
				/*C++17: uint &this_skip = */ skip_frames.push_back(prev_tile_skip);
 
				uint &this_skip = skip_frames.back();
 

	
 
				/* The following 3 curves now take longer than before */
 
				switch (u->state) {
 
					case 2:
 
						cur_skip++;
 
						if (u->frame <= (roadside ? 9 : 5)) *this_skip = cur_skip;
 
						if (u->frame <= (roadside ? 9 : 5)) this_skip = cur_skip;
 
						break;
 

	
 
					case 4:
 
						cur_skip++;
 
						if (u->frame <= (roadside ? 5 : 9)) *this_skip = cur_skip;
 
						if (u->frame <= (roadside ? 5 : 9)) this_skip = cur_skip;
 
						break;
 

	
 
					case 5:
 
						cur_skip++;
 
						if (u->frame <= (roadside ? 4 : 2)) *this_skip = cur_skip;
 
						if (u->frame <= (roadside ? 4 : 2)) this_skip = cur_skip;
 
						break;
 

	
 
					default:
 
						break;
 
				}
 
			}
src/saveload/animated_tile_sl.cpp
Show inline comments
 
@@ -39,20 +39,20 @@ static void Load_ANIT()
 
		/* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */
 
		TileIndex anim_list[256];
 
		SlArray(anim_list, 256, IsSavegameVersionBefore(SLV_6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32);
 

	
 
		for (int i = 0; i < 256; i++) {
 
			if (anim_list[i] == 0) break;
 
			*_animated_tiles.Append() = anim_list[i];
 
			_animated_tiles.push_back(anim_list[i]);
 
		}
 
		return;
 
	}
 

	
 
	uint count = (uint)SlGetFieldLength() / sizeof(*_animated_tiles.Begin());
 
	_animated_tiles.clear();
 
	_animated_tiles.Append(count);
 
	_animated_tiles.resize(_animated_tiles.size() + count);
 
	SlArray(_animated_tiles.Begin(), count, SLE_UINT32);
 
}
 

	
 
/**
 
 * "Definition" imported by the saveload code to be able to load and save
 
 * the animated tile table.
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -187,13 +187,14 @@ static void Save_EIDS()
 

	
 
static void Load_EIDS()
 
{
 
	_engine_mngr.clear();
 

	
 
	while (SlIterateArray() != -1) {
 
		EngineIDMapping *eid = _engine_mngr.Append();
 
		/*C++17: EngineIDMapping *eid = &*/ _engine_mngr.emplace_back();
 
		EngineIDMapping *eid = &_engine_mngr.back();
 
		SlObject(eid, _engine_id_mapping_desc);
 
	}
 
}
 

	
 
extern const ChunkHandler _engine_chunk_handlers[] = {
 
	{ 'EIDS', Save_EIDS, Load_EIDS, NULL, NULL, CH_ARRAY          },
src/saveload/game_sl.cpp
Show inline comments
 
@@ -150,16 +150,16 @@ static void Load_GSTR()
 
		_game_saveload_string = NULL;
 
		SlObject(NULL, _game_language_header);
 

	
 
		LanguageStrings *ls = new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : "");
 
		for (uint i = 0; i < _game_saveload_strings; i++) {
 
			SlObject(NULL, _game_language_string);
 
			*ls->lines.Append() = stredup(_game_saveload_string != NULL ? _game_saveload_string : "");
 
			ls->lines.push_back(stredup(_game_saveload_string != NULL ? _game_saveload_string : ""));
 
		}
 

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

	
 
	/* If there were no strings in the savegame, set GameStrings to NULL */
 
	if (_current_data->raw_strings.size() == 0) {
 
		delete _current_data;
 
		_current_data = NULL;
src/saveload/labelmaps_sl.cpp
Show inline comments
 
@@ -45,13 +45,13 @@ void AfterLoadLabelMaps()
 
		SmallVector<RailType, RAILTYPE_END> railtype_conversion_map;
 

	
 
		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;
 
			railtype_conversion_map.push_back(r);
 
		}
 

	
 
		for (TileIndex t = 0; t < MapSize(); t++) {
 
			switch (GetTileType(t)) {
 
				case MP_RAILWAY:
 
					SetRailType(t, railtype_conversion_map[GetRailType(t)]);
 
@@ -111,13 +111,13 @@ static void Load_RAIL()
 
	_railtype_list.clear();
 

	
 
	LabelObject lo;
 

	
 
	while (SlIterateArray() != -1) {
 
		SlObject(&lo, _label_object_desc);
 
		*_railtype_list.Append() = (RailTypeLabel)lo.label;
 
		_railtype_list.push_back((RailTypeLabel)lo.label);
 
	}
 
}
 

	
 
extern const ChunkHandler _labelmaps_chunk_handlers[] = {
 
	{ 'RAIL', Save_RAIL, Load_RAIL, NULL, NULL, CH_ARRAY | CH_LAST},
 
};
src/saveload/linkgraph_sl.cpp
Show inline comments
 
@@ -66,26 +66,26 @@ const SaveLoad *GetLinkGraphJobDesc()
 
		while (desc->save.cmd != SL_END) {
 
			if (desc->desc.name != NULL && strncmp(desc->desc.name, prefix, prefixlen) == 0) {
 
				SaveLoad sl = desc->save;
 
				char *&address = reinterpret_cast<char *&>(sl.address);
 
				address -= offset_gamesettings;
 
				address += offset_component;
 
				*(saveloads.Append()) = sl;
 
				saveloads.push_back(sl);
 
			}
 
			desc = GetSettingDescription(++setting);
 
		}
 

	
 
		const SaveLoad job_desc[] = {
 
			SLE_VAR(LinkGraphJob, join_date,        SLE_INT32),
 
			SLE_VAR(LinkGraphJob, link_graph.index, SLE_UINT16),
 
			SLE_END()
 
		};
 

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

	
 
	return &saveloads[0];
 
}
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -648,13 +648,13 @@ static bool LoadOldAnimTileList(Loadgame
 

	
 
	if (!LoadChunk(ls, NULL, anim_chunk)) return false;
 

	
 
	/* The first zero in the loaded array indicates the end of the list. */
 
	for (int i = 0; i < 256; i++) {
 
		if (anim_list[i] == 0) break;
 
		*_animated_tiles.Append() = anim_list[i];
 
		_animated_tiles.push_back(anim_list[i]);
 
	}
 

	
 
	return true;
 
}
 

	
 
static const OldChunks depot_chunk[] = {
src/saveload/saveload.cpp
Show inline comments
 
@@ -140,13 +140,13 @@ struct MemoryDumper {
 
	 */
 
	inline void WriteByte(byte b)
 
	{
 
		/* Are we at the end of this chunk? */
 
		if (this->buf == this->bufe) {
 
			this->buf = CallocT<byte>(MEMORY_CHUNK_SIZE);
 
			*this->blocks.Append() = this->buf;
 
			this->blocks.push_back(this->buf);
 
			this->bufe = this->buf + MEMORY_CHUNK_SIZE;
 
		}
 

	
 
		*this->buf++ = b;
 
	}
 

	
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -175,13 +175,14 @@ static void Load_WAYP()
 
	/* Precaution for when loading failed and it didn't get cleared */
 
	_old_waypoints.clear();
 

	
 
	int index;
 

	
 
	while ((index = SlIterateArray()) != -1) {
 
		OldWaypoint *wp = _old_waypoints.Append();
 
		/*C++17: OldWaypoint *wp = &*/ _old_waypoints.emplace_back();
 
		OldWaypoint *wp = &_old_waypoints.back();
 
		memset(wp, 0, sizeof(*wp));
 

	
 
		wp->index = index;
 
		SlObject(wp, _old_waypoint_desc);
 
	}
 
}
src/script/squirrel_helper.hpp
Show inline comments
 
@@ -114,13 +114,13 @@ namespace SQConvert {
 
		sq_tostring(vm, index);
 

	
 
		const SQChar *tmp;
 
		sq_getstring(vm, -1, &tmp);
 
		char *tmp_str = stredup(tmp);
 
		sq_poptop(vm);
 
		*ptr->Append() = (void *)tmp_str;
 
		ptr->push_back((void *)tmp_str);
 
		str_validate(tmp_str, tmp_str + strlen(tmp_str));
 
		return tmp_str;
 
	}
 

	
 
	template <> inline Array      *GetParam(ForceType<Array *>,      HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr)
 
	{
 
@@ -134,13 +134,13 @@ namespace SQConvert {
 

	
 
		SmallVector<int32, 2> data;
 

	
 
		while (SQ_SUCCEEDED(sq_next(vm, -2))) {
 
			SQInteger tmp;
 
			if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) {
 
				*data.Append() = (int32)tmp;
 
				data.push_back((int32)tmp);
 
			} else {
 
				sq_pop(vm, 4);
 
				throw sq_throwerror(vm, "a member of an array used as parameter to a function is not numeric");
 
			}
 

	
 
			sq_pop(vm, 2);
 
@@ -148,13 +148,13 @@ namespace SQConvert {
 
		sq_pop(vm, 2);
 

	
 
		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;
 
		ptr->push_back(arr);
 
		return arr;
 
	}
 

	
 
	/**
 
	 * Helper class to recognize the function type (retval type, args) and use the proper specialization
 
	 * for SQ callback. The partial specializations for the second arg (Tis_void_retval) are not possible
src/settings.cpp
Show inline comments
 
@@ -724,13 +724,13 @@ static void IniLoadSettingList(IniFile *
 

	
 
	if (group == NULL || list == NULL) return;
 

	
 
	list->Clear();
 

	
 
	for (const IniItem *item = group->item; item != NULL; item = item->next) {
 
		if (item->name != NULL) *list->Append() = stredup(item->name);
 
		if (item->name != NULL) list->push_back(stredup(item->name));
 
	}
 
}
 

	
 
/**
 
 * Saves all items from a list into the 'grpname' section
 
 * The list parameter can be a NULL pointer, in this case a callback function
 
@@ -1774,13 +1774,13 @@ void GetGRFPresetList(GRFPresetList *lis
 
	list->Clear();
 

	
 
	IniFile *ini = IniLoadConfig();
 
	IniGroup *group;
 
	for (group = ini->group; group != NULL; group = group->next) {
 
		if (strncmp(group->name, "preset-", 7) == 0) {
 
			*list->Append() = stredup(group->name + 7);
 
			list->push_back(stredup(group->name + 7));
 
		}
 
	}
 

	
 
	delete ini;
 
}
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -126,13 +126,13 @@ static DropDownList *BuildSetDropDownLis
 
{
 
	int n = T::GetNumSets();
 
	*selected_index = T::GetIndexOfUsedSet();
 

	
 
	DropDownList *list = new DropDownList();
 
	for (int i = 0; i < n; i++) {
 
		*list->Append() = new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i));
 
		list->push_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
 
	}
 

	
 
	return list;
 
}
 

	
 
DropDownList *BuildMusicSetDropDownList(int *selected_index)
 
@@ -210,19 +210,19 @@ struct GameOptionsWindow : Window {
 
				StringID *items = BuildCurrencyDropdown();
 
				uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
 

	
 
				/* 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));
 
					list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
 
				}
 
				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));
 
				list->push_back(new DropDownListItem(-1, false)); // separator line
 
				list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
 
				break;
 
			}
 

	
 
			case WID_GO_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
 
				list = new DropDownList();
 
				*selected_index = this->opt->vehicle.road_side;
 
@@ -234,13 +234,13 @@ struct GameOptionsWindow : Window {
 
				extern bool RoadVehiclesAreBuilt();
 
				if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
 
					disabled = ~(1 << this->opt->vehicle.road_side); // disable the other value
 
				}
 

	
 
				for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
 
					*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
 
					list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
 
				}
 
				break;
 
			}
 

	
 
			case WID_GO_TOWNNAME_DROPDOWN: { // Setup townname dropdown
 
				list = new DropDownList();
 
@@ -248,77 +248,77 @@ struct GameOptionsWindow : Window {
 

	
 
				int enabled_item = (_game_mode == GM_MENU || Town::GetNumItems() == 0) ? -1 : *selected_index;
 

	
 
				/* 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);
 
					list->push_back(new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0));
 
				}
 
				QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
 

	
 
				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
 
					list->push_back(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);
 
					list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0));
 
				}
 
				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;
 
				const StringID *items = _autosave_dropdown;
 
				for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
 
					*list->Append() = new DropDownListStringItem(*items, i, false);
 
					list->push_back(new DropDownListStringItem(*items, i, false));
 
				}
 
				break;
 
			}
 

	
 
			case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
 
				list = new DropDownList();
 
				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);
 
					list->push_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false));
 
				}
 
				QSortT(list->Begin(), list->size(), DropDownListStringItem::NatSortFunc);
 
				break;
 
			}
 

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

	
 
				list = new DropDownList();
 
				*selected_index = GetCurRes();
 
				for (int i = 0; i < _num_resolutions; i++) {
 
					*list->Append() = new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false);
 
					list->push_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
 
				}
 
				break;
 

	
 
			case WID_GO_GUI_ZOOM_DROPDOWN: {
 
				list = new DropDownList();
 
				*selected_index = ZOOM_LVL_OUT_4X - _gui_zoom;
 
				const StringID *items = _gui_zoom_dropdown;
 
				for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
 
					*list->Append() = new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i);
 
					list->push_back(new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i));
 
				}
 
				break;
 
			}
 

	
 
			case WID_GO_FONT_ZOOM_DROPDOWN: {
 
				list = new DropDownList();
 
				*selected_index = ZOOM_LVL_OUT_4X - _font_zoom;
 
				const StringID *items = _font_zoom_dropdown;
 
				for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
 
					*list->Append() = new DropDownListStringItem(*items, i, false);
 
					list->push_back(new DropDownListStringItem(*items, i, false));
 
				}
 
				break;
 
			}
 

	
 
			case WID_GO_BASE_GRF_DROPDOWN:
 
				list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
 
@@ -1961,22 +1961,22 @@ struct GameSettingsWindow : Window {
 

	
 
				for (int mode = 0; mode != RM_END; mode++) {
 
					/* If we are in adv. settings screen for the new game's settings,
 
					 * we don't want to allow comparing with new game's settings. */
 
					bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
 

	
 
					*list->Append() = new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled);
 
					list->push_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
 
				}
 
				break;
 

	
 
			case WID_GS_TYPE_DROPDOWN:
 
				list = new DropDownList();
 
				*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false);
 
				*list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false);
 
				*list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false);
 
				*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false);
 
				list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
 
				list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false));
 
				list->push_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false));
 
				list->push_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
 
				break;
 
		}
 
		return list;
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
@@ -2127,13 +2127,13 @@ struct GameSettingsWindow : Window {
 
				if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
 
					this->valuedropdown_entry = pe;
 
					this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
 

	
 
					DropDownList *list = new DropDownList();
 
					for (int i = sdb->min; i <= (int)sdb->max; i++) {
 
						*list->Append() = new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false);
 
						list->push_back(new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false));
 
					}
 

	
 
					ShowDropDownListAt(this, list, value, -1, wi_rect, COLOUR_ORANGE, true);
 
				}
 
			}
 
			this->SetDirty();
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -118,15 +118,16 @@ public:
 
		if (length > 0 && this->BufferHasRoom()) {
 
			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.
 
			int stored_size = block->Add(text, length);
 
			/*C++17: OutputBuffer &block =*/ this->output_buffer.emplace_back();
 
			OutputBuffer &block = this->output_buffer.back();
 
			block.Clear(); // Initialize the new block.
 
			int stored_size = block.Add(text, length);
 
			length -= stored_size;
 
			text += stored_size;
 
		}
 
	}
 

	
 
	/**
src/signs_gui.cpp
Show inline comments
 
@@ -60,13 +60,13 @@ struct SignList {
 

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

	
 
		this->signs.clear();
 

	
 
		const Sign *si;
 
		FOR_ALL_SIGNS(si) *this->signs.Append() = si;
 
		FOR_ALL_SIGNS(si) this->signs.push_back(si);
 

	
 
		this->signs.SetFilterState(true);
 
		this->FilterSignList();
 
		this->signs.shrink_to_fit();
 
		this->signs.RebuildDone();
 
	}
src/station_cmd.cpp
Show inline comments
 
@@ -939,13 +939,13 @@ static CommandCost CheckFlatLandRailStat
 

	
 
				if (tracks == TRACK_BIT_NONE && track == expected_track) {
 
					/* Check for trains having a reservation for this tile. */
 
					if (HasBit(GetRailReservationTrackBits(tile_cur), track)) {
 
						Train *v = GetTrainForReservation(tile_cur, track);
 
						if (v != NULL) {
 
							*affected_vehicles.Append() = v;
 
							affected_vehicles.push_back(v);
 
						}
 
					}
 
					CommandCost ret = DoCommand(tile_cur, 0, track, flags, CMD_REMOVE_SINGLE_RAIL);
 
					if (ret.Failed()) return ret;
 
					cost.AddCost(ret);
 
					/* With flags & ~DC_EXEC CmdLandscapeClear would fail since the rail still exists */
 
@@ -1383,13 +1383,13 @@ CommandCost CmdBuildRailStation(TileInde
 
			do {
 
				byte layout = *layout_ptr++;
 
				if (IsRailStationTile(tile) && HasStationReservation(tile)) {
 
					/* Check for trains having a reservation for this tile. */
 
					Train *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile)));
 
					if (v != NULL) {
 
						*affected_vehicles.Append() = v;
 
						affected_vehicles.push_back(v);
 
						FreeTrainReservation(v);
 
					}
 
				}
 

	
 
				/* Railtype can change when overbuilding. */
 
				if (IsRailStationTile(tile)) {
 
@@ -3535,13 +3535,13 @@ void DeleteStaleLinks(Station *from)
 
							} else if (order->GetDestination() == to->index) {
 
								found_to = true;
 
								if (found_from) break;
 
							}
 
						}
 
						if (!found_to || !found_from) continue;
 
						*(vehicles.Append()) = l->GetFirstSharedVehicle();
 
						vehicles.push_back(l->GetFirstSharedVehicle());
 
					}
 

	
 
					auto iter = vehicles.begin();
 
					while (iter != vehicles.end()) {
 
						Vehicle *v = *iter;
 

	
src/station_gui.cpp
Show inline comments
 
@@ -186,20 +186,20 @@ protected:
 
				if (this->facilities & st->facilities) { // only stations with selected facilities
 
					int num_waiting_cargo = 0;
 
					for (CargoID j = 0; j < NUM_CARGO; j++) {
 
						if (st->goods[j].HasRating()) {
 
							num_waiting_cargo++; // count number of waiting cargo
 
							if (HasBit(this->cargo_filter, j)) {
 
								*this->stations.Append() = st;
 
								this->stations.push_back(st);
 
								break;
 
							}
 
						}
 
					}
 
					/* stations without waiting cargo */
 
					if (num_waiting_cargo == 0 && this->include_empty) {
 
						*this->stations.Append() = st;
 
						this->stations.push_back(st);
 
					}
 
				}
 
			}
 
		}
 

	
 
		this->stations.shrink_to_fit();
 
@@ -2132,13 +2132,13 @@ static bool AddNearbyStation(TileIndex t
 
	TileArea *ctx = (TileArea *)user_data;
 

	
 
	/* First check if there were deleted stations here */
 
	for (uint i = 0; i < _deleted_stations_nearby.size(); i++) {
 
		auto ts = _deleted_stations_nearby.begin() + i;
 
		if (ts->tile == tile) {
 
			*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
 
			_stations_nearby_list.push_back(_deleted_stations_nearby[i].station);
 
			_deleted_stations_nearby.erase(ts);
 
			i--;
 
		}
 
	}
 

	
 
	/* Check if own station and if we stay within station spread */
 
@@ -2150,13 +2150,13 @@ static bool AddNearbyStation(TileIndex t
 
	if (!T::IsValidID(sid)) return false;
 

	
 
	T *st = T::Get(sid);
 
	if (st->owner != _local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end()) return false;
 

	
 
	if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST).Succeeded()) {
 
		*_stations_nearby_list.Append() = sid;
 
		_stations_nearby_list.push_back(sid);
 
	}
 

	
 
	return false; // We want to include *all* nearby stations
 
}
 

	
 
/**
 
@@ -2184,15 +2184,13 @@ static const T *FindStationsNearby(TileA
 
	/* Look for deleted stations */
 
	const BaseStation *st;
 
	FOR_ALL_BASE_STATIONS(st) {
 
		if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
 
			/* Include only within station spread (yes, it is strictly less than) */
 
			if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) {
 
				TileAndStation *ts = _deleted_stations_nearby.Append();
 
				ts->tile = st->xy;
 
				ts->station = st->index;
 
				_deleted_stations_nearby.push_back({st->xy, st->index});
 

	
 
				/* Add the station when it's within where we're going to build */
 
				if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
 
						IsInsideBS(TileY(st->xy), TileY(ctx.tile), ctx.h)) {
 
					AddNearbyStation<T>(st->xy, &ctx);
 
				}
src/story_gui.cpp
Show inline comments
 
@@ -54,13 +54,13 @@ protected:
 
		if (this->story_pages.NeedRebuild()) {
 
			this->story_pages.clear();
 

	
 
			const StoryPage *p;
 
			FOR_ALL_STORY_PAGES(p) {
 
				if (this->IsPageAvailable(p)) {
 
					*this->story_pages.Append() = p;
 
					this->story_pages.push_back(p);
 
				}
 
			}
 

	
 
			this->story_pages.shrink_to_fit();
 
			this->story_pages.RebuildDone();
 
		}
 
@@ -82,13 +82,13 @@ protected:
 

	
 
			const StoryPage *p = GetSelPage();
 
			if (p != NULL) {
 
				const StoryPageElement *pe;
 
				FOR_ALL_STORY_PAGE_ELEMENTS(pe) {
 
					if (pe->page == p->index) {
 
						*this->story_page_elements.Append() = pe;
 
						this->story_page_elements.push_back(pe);
 
					}
 
				}
 
			}
 

	
 
			this->story_page_elements.shrink_to_fit();
 
			this->story_page_elements.RebuildDone();
 
@@ -245,13 +245,13 @@ protected:
 
				DropDownListParamStringItem *str_item =
 
						new DropDownListParamStringItem(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index, current_page);
 
				str_item->SetParam(0, page_num);
 
				item = str_item;
 
			}
 

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

	
 
		/* Check if list is empty. */
 
		if (list->size() == 0) {
 
			delete list;
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -239,35 +239,35 @@ struct Buffer : SmallVector<byte, 256> {
 
	/**
 
	 * Convenience method for adding a byte.
 
	 * @param value The value to add.
 
	 */
 
	void AppendByte(byte value)
 
	{
 
		*this->Append() = value;
 
		this->push_back(value);
 
	}
 

	
 
	/**
 
	 * Add an Unicode character encoded in UTF-8 to the buffer.
 
	 * @param value The character to add.
 
	 */
 
	void AppendUtf8(uint32 value)
 
	{
 
		if (value < 0x80) {
 
			*this->Append() = value;
 
			this->push_back(value);
 
		} else if (value < 0x800) {
 
			*this->Append() = 0xC0 + GB(value,  6, 5);
 
			*this->Append() = 0x80 + GB(value,  0, 6);
 
			this->push_back(0xC0 + GB(value,  6, 5));
 
			this->push_back(0x80 + GB(value,  0, 6));
 
		} else if (value < 0x10000) {
 
			*this->Append() = 0xE0 + GB(value, 12, 4);
 
			*this->Append() = 0x80 + GB(value,  6, 6);
 
			*this->Append() = 0x80 + GB(value,  0, 6);
 
			this->push_back(0xE0 + GB(value, 12, 4));
 
			this->push_back(0x80 + GB(value,  6, 6));
 
			this->push_back(0x80 + GB(value,  0, 6));
 
		} else if (value < 0x110000) {
 
			*this->Append() = 0xF0 + GB(value, 18, 3);
 
			*this->Append() = 0x80 + GB(value, 12, 6);
 
			*this->Append() = 0x80 + GB(value,  6, 6);
 
			*this->Append() = 0x80 + GB(value,  0, 6);
 
			this->push_back(0xF0 + GB(value, 18, 3));
 
			this->push_back(0x80 + GB(value, 12, 6));
 
			this->push_back(0x80 + GB(value,  6, 6));
 
			this->push_back(0x80 + GB(value,  0, 6));
 
		} else {
 
			strgen_warning("Invalid unicode value U+0x%X", value);
 
		}
 
	}
 
};
 

	
src/string.cpp
Show inline comments
 
@@ -631,14 +631,14 @@ public:
 
	IcuStringIterator() : char_itr(NULL), word_itr(NULL)
 
	{
 
		UErrorCode status = U_ZERO_ERROR;
 
		this->char_itr = icu::BreakIterator::createCharacterInstance(icu::Locale(_current_language != NULL ? _current_language->isocode : "en"), status);
 
		this->word_itr = icu::BreakIterator::createWordInstance(icu::Locale(_current_language != NULL ? _current_language->isocode : "en"), status);
 

	
 
		*this->utf16_str.Append() = '\0';
 
		*this->utf16_to_utf8.Append() = 0;
 
		this->utf16_str.push_back('\0');
 
		this->utf16_to_utf8.push_back(0);
 
	}
 

	
 
	virtual ~IcuStringIterator()
 
	{
 
		delete this->char_itr;
 
		delete this->word_itr;
 
@@ -657,23 +657,23 @@ public:
 

	
 
		while (*s != '\0') {
 
			size_t idx = s - string_base;
 

	
 
			WChar c = Utf8Consume(&s);
 
			if (c < 0x10000) {
 
				*this->utf16_str.Append() = (UChar)c;
 
				this->utf16_str.push_back((UChar)c);
 
			} else {
 
				/* Make a surrogate pair. */
 
				*this->utf16_str.Append() = (UChar)(0xD800 + ((c - 0x10000) >> 10));
 
				*this->utf16_str.Append() = (UChar)(0xDC00 + ((c - 0x10000) & 0x3FF));
 
				*this->utf16_to_utf8.Append() = idx;
 
				this->utf16_str.push_back((UChar)(0xD800 + ((c - 0x10000) >> 10)));
 
				this->utf16_str.push_back((UChar)(0xDC00 + ((c - 0x10000) & 0x3FF)));
 
				this->utf16_to_utf8.push_back(idx);
 
			}
 
			*this->utf16_to_utf8.Append() = idx;
 
			this->utf16_to_utf8.push_back(idx);
 
		}
 
		*this->utf16_str.Append() = '\0';
 
		*this->utf16_to_utf8.Append() = s - string_base;
 
		this->utf16_str.push_back('\0');
 
		this->utf16_to_utf8.push_back(s - string_base);
 

	
 
		UText text = UTEXT_INITIALIZER;
 
		UErrorCode status = U_ZERO_ERROR;
 
		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);
src/stringfilter.cpp
Show inline comments
 
@@ -73,15 +73,14 @@ void StringFilter::SetFilterTerm(const c
 
				continue;
 
			}
 
		}
 

	
 
		/* Add to word */
 
		if (word == NULL) {
 
			word = this->word_index.Append();
 
			word->start = dest;
 
			word->match = false;
 
			/*C++17: word = &*/ this->word_index.push_back({dest, false});
 
			word = &this->word_index.back();
 
		}
 

	
 
		memcpy(dest, pos, len);
 
		dest += len;
 
	}
 
}
src/strings.cpp
Show inline comments
 
@@ -1929,13 +1929,13 @@ static void GetLanguageList(const char *
 
			/* Check whether the file is of the correct version */
 
			if (!GetLanguageFileHeader(lmd.file, &lmd)) {
 
				DEBUG(misc, 3, "%s is not a valid language file", lmd.file);
 
			} else if (GetLanguage(lmd.newgrflangid) != NULL) {
 
				DEBUG(misc, 3, "%s's language ID is already known", lmd.file);
 
			} else {
 
				*_languages.Append() = lmd;
 
				_languages.push_back(lmd);
 
			}
 
		}
 
		closedir(dir);
 
	}
 
}
 

	
src/texteff.cpp
Show inline comments
 
@@ -45,26 +45,26 @@ TextEffectID AddTextEffect(StringID msg,
 
	if (_game_mode == GM_MENU) return INVALID_TE_ID;
 

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

	
 
	TextEffect *te = _text_effects.data() + i;
 
	TextEffect &te = _text_effects[i];
 

	
 
	/* Start defining this object */
 
	te->string_id = msg;
 
	te->duration = duration;
 
	te->params_1 = GetDParam(0);
 
	te->params_2 = GetDParam(1);
 
	te->mode = mode;
 
	te.string_id = msg;
 
	te.duration = duration;
 
	te.params_1 = GetDParam(0);
 
	te.params_2 = GetDParam(1);
 
	te.mode = mode;
 

	
 
	/* Make sure we only dirty the new area */
 
	te->width_normal = 0;
 
	te->UpdatePosition(center, y, msg);
 
	te.width_normal = 0;
 
	te.UpdatePosition(center, y, msg);
 

	
 
	return i;
 
}
 

	
 
void UpdateTextEffect(TextEffectID te_id, StringID msg)
 
{
src/textfile_gui.cpp
Show inline comments
 
@@ -362,17 +362,17 @@ static void Xunzip(byte **bufp, size_t *
 
	char *p = this->text + (strncmp("\xEF\xBB\xBF", this->text, 3) == 0 ? 3 : 0);
 

	
 
	/* Make sure the string is a valid UTF-8 sequence. */
 
	str_validate(p, this->text + filesize, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);
 

	
 
	/* Split the string on newlines. */
 
	*this->lines.Append() = p;
 
	this->lines.push_back(p);
 
	for (; *p != '\0'; p++) {
 
		if (*p == '\n') {
 
			*p = '\0';
 
			*this->lines.Append() = p + 1;
 
			this->lines.push_back(p + 1);
 
		}
 
	}
 

	
 
	CheckForMissingGlyphs(true, this);
 
}
 

	
src/timetable_cmd.cpp
Show inline comments
 
@@ -282,16 +282,16 @@ CommandCost CmdSetTimetableStart(TileInd
 

	
 
	if (flags & DC_EXEC) {
 
		SmallVector<Vehicle *, 8> vehs;
 

	
 
		if (timetable_all) {
 
			for (Vehicle *w = v->orders.list->GetFirstSharedVehicle(); w != NULL; w = w->NextShared()) {
 
				*vehs.Append() = w;
 
				vehs.push_back(w);
 
			}
 
		} else {
 
			*vehs.Append() = v;
 
			vehs.push_back(v);
 
		}
 

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

	
 
		if (num_vehs >= 2) {
src/toolbar_gui.cpp
Show inline comments
 
@@ -195,13 +195,13 @@ static void PopupMainToolbMenu(Window *w
 
 * @param count Number of items in the menu
 
 */
 
static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count)
 
{
 
	DropDownList *list = new DropDownList();
 
	for (int i = 0; i < count; i++) {
 
		*list->Append() = new DropDownListStringItem(string + i, i, false);
 
		list->push_back(new DropDownListStringItem(string + i, i, false));
 
	}
 
	PopupMainToolbMenu(w, widget, list, 0);
 
}
 

	
 
/** Enum for the Company Toolbar's network related buttons */
 
static const int CTMN_CLIENT_LIST = -1; ///< Show the client list
 
@@ -221,33 +221,33 @@ static void PopupMainCompanyToolbMenu(Wi
 

	
 
	switch (widget) {
 
		case WID_TN_COMPANIES:
 
			if (!_networking) break;
 

	
 
			/* Add the client list button for the companies menu */
 
			*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false);
 
			list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
 

	
 
			if (_local_company == COMPANY_SPECTATOR) {
 
				*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached());
 
				list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
 
			} else {
 
				*list->Append() = new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached());
 
				list->push_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, NetworkMaxSpectatorsReached()));
 
			}
 
			break;
 

	
 
		case WID_TN_STORY:
 
			*list->Append() = new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false);
 
			list->push_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
 
			break;
 

	
 
		case WID_TN_GOAL:
 
			*list->Append() = new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false);
 
			list->push_back(new DropDownListStringItem(STR_GOALS_SPECTATOR, CTMN_SPECTATOR, false));
 
			break;
 
	}
 

	
 
	for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
		if (!Company::IsValidID(c)) continue;
 
		*list->Append() = new DropDownListCompanyItem(c, false, HasBit(grey, c));
 
		list->push_back(new DropDownListCompanyItem(c, false, HasBit(grey, c)));
 
	}
 

	
 
	PopupMainToolbMenu(w, widget, list, _local_company == COMPANY_SPECTATOR ? (widget == WID_TN_COMPANIES ? CTMN_CLIENT_LIST : CTMN_SPECTATOR) : (int)_local_company);
 
}
 

	
 

	
 
@@ -315,30 +315,30 @@ enum OptionMenuEntries {
 
 * @param w parent window the shown Drop down list is attached to.
 
 * @return #CBF_NONE
 
 */
 
static CallBackFunction ToolbarOptionsClick(Window *w)
 
{
 
	DropDownList *list = new DropDownList();
 
	*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS,             OME_GAMEOPTIONS, false);
 
	*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE,     OME_SETTINGS, false);
 
	list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_GAME_OPTIONS,             OME_GAMEOPTIONS, false));
 
	list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE,     OME_SETTINGS, false));
 
	/* Changes to the per-AI settings don't get send from the server to the clients. Clients get
 
	 * the settings once they join but never update it. As such don't show the window at all
 
	 * to network clients. */
 
	if (!_networking || _network_server) *list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false);
 
	*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS,          OME_NEWGRFSETTINGS, false);
 
	*list->Append() = new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS,     OME_TRANSPARENCIES, false);
 
	*list->Append() = new DropDownListItem(-1, false);
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED,    OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED,     OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED,         OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS,   OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION,          OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL,             OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS,   OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES));
 
	*list->Append() = new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS,       OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS));
 
	if (!_networking || _network_server) list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_SCRIPT_SETTINGS, OME_SCRIPT_SETTINGS, false));
 
	list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_NEWGRF_SETTINGS,          OME_NEWGRFSETTINGS, false));
 
	list->push_back(new DropDownListStringItem(STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS,     OME_TRANSPARENCIES, false));
 
	list->push_back(new DropDownListItem(-1, false));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED,    OME_SHOW_TOWNNAMES, false, HasBit(_display_opt, DO_SHOW_TOWN_NAMES)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES, false, HasBit(_display_opt, DO_SHOW_STATION_NAMES)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED,     OME_SHOW_WAYPOINTNAMES, false, HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SIGNS_DISPLAYED,         OME_SHOW_SIGNS, false, HasBit(_display_opt, DO_SHOW_SIGNS)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS,   OME_SHOW_COMPETITOR_SIGNS, false, HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_ANIMATION,          OME_FULL_ANIMATION, false, HasBit(_display_opt, DO_FULL_ANIMATION)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_FULL_DETAIL,             OME_FULL_DETAILS, false, HasBit(_display_opt, DO_FULL_DETAIL)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS,   OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES)));
 
	list->push_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS,       OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS)));
 

	
 
	ShowDropDownList(w, list, 0, WID_TN_SETTINGS, 140, true, true);
 
	if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
	return CBF_NONE;
 
}
 

	
 
@@ -461,28 +461,28 @@ enum MapMenuEntries {
 
	MME_SHOW_INDUSTRYDIRECTORY,
 
};
 

	
 
static CallBackFunction ToolbarMapClick(Window *w)
 
{
 
	DropDownList *list = new DropDownList();
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD,            MME_SHOW_SMALLMAP,          false);
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT,         MME_SHOW_EXTRAVIEWPORTS,    false);
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND,         MME_SHOW_LINKGRAPH,         false);
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST,               MME_SHOW_SIGNLISTS,         false);
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD,            MME_SHOW_SMALLMAP,          false));
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT,         MME_SHOW_EXTRAVIEWPORTS,    false));
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_LINGRAPH_LEGEND,         MME_SHOW_LINKGRAPH,         false));
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST,               MME_SHOW_SIGNLISTS,         false));
 
	PopupMainToolbMenu(w, WID_TN_SMALL_MAP, list, 0);
 
	return CBF_NONE;
 
}
 

	
 
static CallBackFunction ToolbarScenMapTownDir(Window *w)
 
{
 
	DropDownList *list = new DropDownList();
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD,            MME_SHOW_SMALLMAP,          false);
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT,         MME_SHOW_EXTRAVIEWPORTS,    false);
 
	*list->Append() = new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST,               MME_SHOW_SIGNLISTS,         false);
 
	*list->Append() = new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY,         MME_SHOW_TOWNDIRECTORY,     false);
 
	*list->Append() = new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false);
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_MAP_OF_WORLD,            MME_SHOW_SMALLMAP,          false));
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_EXTRA_VIEW_PORT,         MME_SHOW_EXTRAVIEWPORTS,    false));
 
	list->push_back(new DropDownListStringItem(STR_MAP_MENU_SIGN_LIST,               MME_SHOW_SIGNLISTS,         false));
 
	list->push_back(new DropDownListStringItem(STR_TOWN_MENU_TOWN_DIRECTORY,         MME_SHOW_TOWNDIRECTORY,     false));
 
	list->push_back(new DropDownListStringItem(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false));
 
	PopupMainToolbMenu(w, WID_TE_SMALL_MAP, list, 0);
 
	return CBF_NONE;
 
}
 

	
 
/**
 
 * Handle click on one of the entries in the Map menu.
 
@@ -894,21 +894,21 @@ static CallBackFunction MenuClickBuildRa
 
static CallBackFunction ToolbarBuildRoadClick(Window *w)
 
{
 
	const Company *c = Company::Get(_local_company);
 
	DropDownList *list = new DropDownList();
 

	
 
	/* Road is always visible and available. */
 
	*list->Append() = new DropDownListIconItem(SPR_IMG_ROAD_X_DIR, PAL_NONE, STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false);
 
	list->push_back(new DropDownListIconItem(SPR_IMG_ROAD_X_DIR, PAL_NONE, STR_ROAD_MENU_ROAD_CONSTRUCTION, ROADTYPE_ROAD, false));
 

	
 
	/* Tram is only visible when there will be a tram, and available when that has been introduced. */
 
	Engine *e;
 
	FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
 
		if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
 
		if (!HasBit(e->info.misc_flags, EF_ROAD_TRAM)) continue;
 

	
 
		*list->Append() = new DropDownListIconItem(SPR_IMG_TRAMWAY_X_DIR, PAL_NONE, STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM));
 
		list->push_back(new DropDownListIconItem(SPR_IMG_TRAMWAY_X_DIR, PAL_NONE, STR_ROAD_MENU_TRAM_CONSTRUCTION, ROADTYPE_TRAM, !HasBit(c->avail_roadtypes, ROADTYPE_TRAM)));
 
		break;
 
	}
 
	ShowDropDownList(w, list, _last_built_roadtype, WID_TN_ROADS, 140, true, true);
 
	if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
 
	return CBF_NONE;
 
}
src/town_gui.cpp
Show inline comments
 
@@ -651,13 +651,13 @@ private:
 
	{
 
		if (this->towns.NeedRebuild()) {
 
			this->towns.clear();
 

	
 
			const Town *t;
 
			FOR_ALL_TOWNS(t) {
 
				*this->towns.Append() = t;
 
				this->towns.push_back(t);
 
			}
 

	
 
			this->towns.shrink_to_fit();
 
			this->towns.RebuildDone();
 
			this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well.
 
		}
src/train_cmd.cpp
Show inline comments
 
@@ -820,13 +820,13 @@ typedef SmallVector<Train *, 16> TrainLi
 
 * Make a backup of a train into a train list.
 
 * @param list to make the backup in
 
 * @param t    the train to make the backup of
 
 */
 
static void MakeTrainBackup(TrainList &list, Train *t)
 
{
 
	for (; t != NULL; t = t->Next()) *list.Append() = t;
 
	for (; t != NULL; t = t->Next()) list.push_back(t);
 
}
 

	
 
/**
 
 * Restore the train from the backup list.
 
 * @param list the train to restore.
 
 */
src/train_gui.cpp
Show inline comments
 
@@ -277,13 +277,14 @@ static void GetCargoSummaryOfArticulated
 
		new_item.cargo = v->cargo_cap > 0 ? v->cargo_type : INVALID_CARGO;
 
		new_item.subtype = GetCargoSubtypeText(v);
 
		if (new_item.cargo == INVALID_CARGO && new_item.subtype == STR_EMPTY) continue;
 

	
 
		CargoSummaryItem *item = &*std::find(summary->begin(), summary->end(), new_item);
 
		if (item == summary->End()) {
 
			item = summary->Append();
 
			/*C++17: item = &*/ summary->emplace_back();
 
			item = &summary->back();
 
			item->cargo = new_item.cargo;
 
			item->subtype = new_item.subtype;
 
			item->capacity = 0;
 
			item->amount = 0;
 
			item->source = INVALID_STATION;
 
		}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -678,15 +678,14 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
	/* slope of end tile must be complementary to the slope of the start tile */
 
	if (end_tileh != ComplementSlope(start_tileh)) {
 
		/* Mark the tile as already cleared for the terraform command.
 
		 * Do this for all tiles (like trees), not only objects. */
 
		ClearedObjectArea *coa = FindClearedObject(end_tile);
 
		if (coa == NULL) {
 
			coa = _cleared_object_areas.Append();
 
			coa->first_tile = end_tile;
 
			coa->area = TileArea(end_tile, 1, 1);
 
			/*C++17: coa = &*/ _cleared_object_areas.push_back({end_tile, TileArea(end_tile, 1, 1)});
 
			coa = &_cleared_object_areas.back();
 
		}
 

	
 
		/* Hide the tile from the terraforming command */
 
		TileIndex old_first_tile = coa->first_tile;
 
		coa->first_tile = INVALID_TILE;
 

	
src/vehicle.cpp
Show inline comments
 
@@ -2280,15 +2280,13 @@ void Vehicle::HandleLoading(bool mode)
 
void Vehicle::GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const
 
{
 
	for (const Vehicle *v = this; v != NULL; v = v->Next()) {
 
		if (v->cargo_cap == 0) continue;
 
		SmallPair<CargoID, uint> *pair = capacities.Find(v->cargo_type);
 
		if (pair == capacities.End()) {
 
			pair = capacities.Append();
 
			pair->first = v->cargo_type;
 
			pair->second = v->cargo_cap - v->cargo.StoredCount();
 
			capacities.push_back({v->cargo_type, v->cargo_cap - v->cargo.StoredCount()});
 
		} else {
 
			pair->second += v->cargo_cap - v->cargo.StoredCount();
 
		}
 
	}
 
}
 

	
src/vehicle_cmd.cpp
Show inline comments
 
@@ -414,17 +414,13 @@ static CommandCost RefitVehicle(Vehicle 
 
		 * Note:
 
		 *  - If the capacity of vehicles depends on other vehicles in the chain, the actual capacity is
 
		 *    set after RefitVehicle() via ConsistChanged() and friends. The estimation via _returned_refit_capacity will be wrong.
 
		 *  - We have to call the refit cost callback with the pre-refit configuration of the chain because we want refit and
 
		 *    autorefit to behave the same, and we need its result for auto_refit_allowed.
 
		 */
 
		RefitResult *result = refit_result.Append();
 
		result->v = v;
 
		result->capacity = amount;
 
		result->mail_capacity = mail_capacity;
 
		result->subtype = actual_subtype;
 
		refit_result.push_back({v, amount, mail_capacity, actual_subtype});
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* Store the result */
 
		for (RefitResult *result = refit_result.Begin(); result != refit_result.End(); result++) {
 
			Vehicle *u = result->v;
src/vehicle_gui.cpp
Show inline comments
 
@@ -165,19 +165,19 @@ Dimension BaseVehicleListWindow::GetActi
 
 * @return Itemlist for dropdown
 
 */
 
DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
 
{
 
	DropDownList *list = new DropDownList();
 

	
 
	if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false);
 
	*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, false);
 
	*list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, false);
 
	if (show_autoreplace) list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false));
 
	list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, false));
 
	list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, false));
 

	
 
	if (show_group) {
 
		*list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, false);
 
		*list->Append() = new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, false);
 
		list->push_back(new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, false));
 
		list->push_back(new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, false));
 
	}
 

	
 
	return list;
 
}
 

	
 
/* cached values for VehicleNameSorter to spare many GetString() calls */
 
@@ -435,16 +435,13 @@ struct RefitWindow : public Window {
 
					continue;
 
				}
 

	
 
				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;
 
					this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
 
				}
 

	
 
				/* Check the vehicle's callback mask for cargo suffixes.
 
				 * This is not supported for ordered refits, since subtypes only have a meaning
 
				 * for a specific vehicle at a specific point in time, which conflicts with shared orders,
 
				 * autoreplace, autorenew, clone, order restoration, ... */
src/vehiclelist.cpp
Show inline comments
 
@@ -82,26 +82,26 @@ void BuildDepotVehicleList(VehicleType t
 
		switch (type) {
 
			case VEH_TRAIN: {
 
				const Train *t = Train::From(v);
 
				if (t->IsArticulatedPart() || t->IsRearDualheaded()) continue;
 
				if (t->track != TRACK_BIT_DEPOT) continue;
 
				if (wagons != NULL && t->First()->IsFreeWagon()) {
 
					if (individual_wagons || t->IsFreeWagon()) *wagons->Append() = t;
 
					if (individual_wagons || t->IsFreeWagon()) wagons->push_back(t);
 
					continue;
 
				}
 
				break;
 
			}
 

	
 
			default:
 
				if (!v->IsInDepot()) continue;
 
				break;
 
		}
 

	
 
		if (!v->IsPrimaryVehicle()) continue;
 

	
 
		*engines->Append() = v;
 
		engines->push_back(v);
 
	}
 

	
 
	/* Ensure the lists are not wasting too much space. If the lists are fresh
 
	 * (i.e. built within a command) then this will actually do nothing. */
 
	engines->shrink_to_fit();
 
	if (wagons != NULL && wagons != engines) wagons->shrink_to_fit();
 
@@ -125,13 +125,13 @@ bool GenerateVehicleSortList(VehicleList
 
				if (v->type == vli.vtype && v->IsPrimaryVehicle()) {
 
					const Order *order;
 

	
 
					FOR_VEHICLE_ORDERS(v, order) {
 
						if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT))
 
								&& order->GetDestination() == vli.index) {
 
							*list->Append() = v;
 
							list->push_back(v);
 
							break;
 
						}
 
					}
 
				}
 
			}
 
			break;
 
@@ -139,44 +139,44 @@ bool GenerateVehicleSortList(VehicleList
 
		case VL_SHARED_ORDERS:
 
			/* Add all vehicles from this vehicle's shared order list */
 
			v = Vehicle::GetIfValid(vli.index);
 
			if (v == NULL || v->type != vli.vtype || !v->IsPrimaryVehicle()) return false;
 

	
 
			for (; v != NULL; v = v->NextShared()) {
 
				*list->Append() = v;
 
				list->push_back(v);
 
			}
 
			break;
 

	
 
		case VL_GROUP_LIST:
 
			if (vli.index != ALL_GROUP) {
 
				FOR_ALL_VEHICLES(v) {
 
					if (v->type == vli.vtype && v->IsPrimaryVehicle() &&
 
							v->owner == vli.company && GroupIsInGroup(v->group_id, vli.index)) {
 
						*list->Append() = v;
 
						list->push_back(v);
 
					}
 
				}
 
				break;
 
			}
 
			FALLTHROUGH;
 

	
 
		case VL_STANDARD:
 
			FOR_ALL_VEHICLES(v) {
 
				if (v->type == vli.vtype && v->owner == vli.company && v->IsPrimaryVehicle()) {
 
					*list->Append() = v;
 
					list->push_back(v);
 
				}
 
			}
 
			break;
 

	
 
		case VL_DEPOT_LIST:
 
			FOR_ALL_VEHICLES(v) {
 
				if (v->type == vli.vtype && v->IsPrimaryVehicle()) {
 
					const Order *order;
 

	
 
					FOR_VEHICLE_ORDERS(v, order) {
 
						if (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) && order->GetDestination() == vli.index) {
 
							*list->Append() = v;
 
							list->push_back(v);
 
							break;
 
						}
 
					}
 
				}
 
			}
 
			break;
src/viewport.cpp
Show inline comments
 
@@ -496,19 +496,20 @@ void HandleZoomMessage(Window *w, const 
 
 * @param extra_offs_y Pixel Y offset for the sprite position.
 
 */
 
static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0)
 
{
 
	assert((image & SPRITE_MASK) < MAX_SPRITES);
 

	
 
	TileSpriteToDraw *ts = _vd.tile_sprites_to_draw.Append();
 
	ts->image = image;
 
	ts->pal = pal;
 
	ts->sub = sub;
 
	/*C++17: TileSpriteToDraw &ts = */ _vd.tile_sprites_to_draw.emplace_back();
 
	TileSpriteToDraw &ts = _vd.tile_sprites_to_draw.back();
 
	ts.image = image;
 
	ts.pal = pal;
 
	ts.sub = sub;
 
	Point pt = RemapCoords(x, y, z);
 
	ts->x = pt.x + extra_offs_x;
 
	ts->y = pt.y + extra_offs_y;
 
	ts.x = pt.x + extra_offs_x;
 
	ts.y = pt.y + extra_offs_y;
 
}
 

	
 
/**
 
 * Adds a child sprite to the active foundation.
 
 *
 
 * The pixel offset of the sprite relative to the ParentSprite is the sum of the offset passed to OffsetGroundSprite() and extra_offs_?.
 
@@ -705,35 +706,36 @@ void AddSortableSpriteToDraw(SpriteID im
 
	    right  <= _vd.dpi.left                 ||
 
	    top    >= _vd.dpi.top + _vd.dpi.height ||
 
	    bottom <= _vd.dpi.top) {
 
		return;
 
	}
 

	
 
	ParentSpriteToDraw *ps = _vd.parent_sprites_to_draw.Append();
 
	ps->x = tmp_x;
 
	ps->y = tmp_y;
 

	
 
	ps->left = tmp_left;
 
	ps->top  = tmp_top;
 

	
 
	ps->image = image;
 
	ps->pal = pal;
 
	ps->sub = sub;
 
	ps->xmin = x + bb_offset_x;
 
	ps->xmax = x + max(bb_offset_x, w) - 1;
 

	
 
	ps->ymin = y + bb_offset_y;
 
	ps->ymax = y + max(bb_offset_y, h) - 1;
 

	
 
	ps->zmin = z + bb_offset_z;
 
	ps->zmax = z + max(bb_offset_z, dz) - 1;
 

	
 
	ps->comparison_done = false;
 
	ps->first_child = -1;
 

	
 
	_vd.last_child = &ps->first_child;
 
	/*C++17: ParentSpriteToDraw &ps = */ _vd.parent_sprites_to_draw.emplace_back();
 
	ParentSpriteToDraw &ps = _vd.parent_sprites_to_draw.back();
 
	ps.x = tmp_x;
 
	ps.y = tmp_y;
 

	
 
	ps.left = tmp_left;
 
	ps.top  = tmp_top;
 

	
 
	ps.image = image;
 
	ps.pal = pal;
 
	ps.sub = sub;
 
	ps.xmin = x + bb_offset_x;
 
	ps.xmax = x + max(bb_offset_x, w) - 1;
 

	
 
	ps.ymin = y + bb_offset_y;
 
	ps.ymax = y + max(bb_offset_y, h) - 1;
 

	
 
	ps.zmin = z + bb_offset_z;
 
	ps.zmax = z + max(bb_offset_z, dz) - 1;
 

	
 
	ps.comparison_done = false;
 
	ps.first_child = -1;
 

	
 
	_vd.last_child = &ps.first_child;
 

	
 
	if (_vd.combine_sprites == SPRITE_COMBINE_PENDING) _vd.combine_sprites = SPRITE_COMBINE_ACTIVE;
 
}
 

	
 
/**
 
 * Starts a block of sprites, which are "combined" into a single bounding box.
 
@@ -823,39 +825,41 @@ void AddChildSpriteScreen(SpriteID image
 
		SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
 
		pal = PALETTE_TO_TRANSPARENT;
 
	}
 

	
 
	*_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;
 
	cs->y = scale ? y * ZOOM_LVL_BASE : y;
 
	cs->next = -1;
 
	/*C++17: ChildScreenSpriteToDraw &cs = */ _vd.child_screen_sprites_to_draw.emplace_back();
 
	ChildScreenSpriteToDraw &cs = _vd.child_screen_sprites_to_draw.back();
 
	cs.image = image;
 
	cs.pal = pal;
 
	cs.sub = sub;
 
	cs.x = scale ? x * ZOOM_LVL_BASE : x;
 
	cs.y = scale ? y * ZOOM_LVL_BASE : y;
 
	cs.next = -1;
 

	
 
	/* Append the sprite to the active ChildSprite list.
 
	 * If the active ParentSprite is a foundation, update last_foundation_child as well.
 
	 * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */
 
	if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs->next;
 
	if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs->next;
 
	_vd.last_child = &cs->next;
 
	if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs.next;
 
	if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs.next;
 
	_vd.last_child = &cs.next;
 
}
 

	
 
static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width)
 
{
 
	assert(width != 0);
 
	StringSpriteToDraw *ss = _vd.string_sprites_to_draw.Append();
 
	ss->string = string;
 
	ss->x = x;
 
	ss->y = y;
 
	ss->params[0] = params_1;
 
	ss->params[1] = params_2;
 
	ss->width = width;
 
	ss->colour = colour;
 
	/*C++17: StringSpriteToDraw &ss = */ _vd.string_sprites_to_draw.emplace_back();
 
	StringSpriteToDraw &ss = _vd.string_sprites_to_draw.back();
 
	ss.string = string;
 
	ss.x = x;
 
	ss.y = y;
 
	ss.params[0] = params_1;
 
	ss.params[1] = params_2;
 
	ss.width = width;
 
	ss.colour = colour;
 
}
 

	
 

	
 
/**
 
 * Draws sprites between ground sprite and everything above.
 
 *
 
@@ -1585,13 +1589,13 @@ void ViewportDoDraw(const ViewPort *vp, 
 
	DrawTextEffects(&_vd.dpi);
 

	
 
	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;
 
		_vd.parent_sprites_to_sort.push_back(it);
 
	}
 

	
 
	_vp_sprite_sorter(&_vd.parent_sprites_to_sort);
 
	ViewportDrawParentSprites(&_vd.parent_sprites_to_sort, &_vd.child_screen_sprites_to_draw);
 

	
 
	if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(&_vd.parent_sprites_to_sort);
src/widgets/dropdown.cpp
Show inline comments
 
@@ -506,13 +506,13 @@ void ShowDropDownList(Window *w, const D
 
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
 
{
 
	DropDownList *list = new DropDownList();
 

	
 
	for (uint i = 0; strings[i] != INVALID_STRING_ID; i++) {
 
		if (!HasBit(hidden_mask, i)) {
 
			*list->Append() = new DropDownListStringItem(strings[i], i, HasBit(disabled_mask, i));
 
			list->push_back(new DropDownListStringItem(strings[i], i, HasBit(disabled_mask, i)));
 
		}
 
	}
 

	
 
	/* No entries in the list? */
 
	if (list->size() == 0) {
 
		delete list;
src/window.cpp
Show inline comments
 
@@ -106,13 +106,13 @@ WindowDesc::WindowDesc(WindowPosition de
 
	pref_width(0),
 
	pref_height(0),
 
	default_width_trad(def_width_trad),
 
	default_height_trad(def_height_trad)
 
{
 
	if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
 
	*_window_descs->Append() = this;
 
	_window_descs->push_back(this);
 
}
 

	
 
WindowDesc::~WindowDesc()
 
{
 
	_window_descs->erase(std::find(_window_descs->begin(), _window_descs->end(), this));
 
}
 
@@ -3239,13 +3239,13 @@ void SetWindowClassesDirty(WindowClass c
 
 */
 
void Window::InvalidateData(int data, bool gui_scope)
 
{
 
	this->SetDirty();
 
	if (!gui_scope) {
 
		/* Schedule GUI-scope invalidation for next redraw. */
 
		*this->scheduled_invalidation_data.Append() = data;
 
		this->scheduled_invalidation_data.push_back(data);
 
	}
 
	this->OnInvalidateData(data, gui_scope);
 
}
 

	
 
/**
 
 * Process all scheduled invalidations.
0 comments (0 inline, 0 general)