summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-02-18 22:39:06 +0000
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commita0f36a50e6324f570985f5010eb0543ec0673aeb (patch)
tree09f9c9abd097acc244f80366da42cb8702c7ed19 /src
parentca2f33c6d025c0c45fb4bc472493290445312de5 (diff)
downloadopenttd-a0f36a50e6324f570985f5010eb0543ec0673aeb.tar.xz
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/airport_gui.cpp2
-rw-r--r--src/autoreplace_gui.cpp6
-rw-r--r--src/bridge_gui.cpp9
-rw-r--r--src/build_vehicle_gui.cpp8
-rw-r--r--src/company_gui.cpp10
-rw-r--r--src/core/pool_type.hpp2
-rw-r--r--src/core/smallmap_type.hpp11
-rw-r--r--src/core/smallvec_type.hpp30
-rw-r--r--src/date_gui.cpp6
-rw-r--r--src/engine.cpp11
-rw-r--r--src/fios.h3
-rw-r--r--src/game/game_text.cpp14
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/gfx_layout.cpp12
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/group_gui.cpp6
-rw-r--r--src/hotkeys.cpp2
-rw-r--r--src/industry_gui.cpp58
-rw-r--r--src/linkgraph/linkgraph.cpp2
-rw-r--r--src/music/midifile.cpp23
-rw-r--r--src/network/core/host.cpp2
-rw-r--r--src/network/core/tcp_connect.cpp2
-rw-r--r--src/network/core/tcp_http.cpp2
-rw-r--r--src/network/core/udp.cpp6
-rw-r--r--src/network/network.cpp6
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_content.cpp14
-rw-r--r--src/network/network_content_gui.cpp2
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/network/network_server.cpp2
-rw-r--r--src/newgrf.cpp84
-rw-r--r--src/newgrf_commons.cpp9
-rw-r--r--src/newgrf_config.cpp8
-rw-r--r--src/newgrf_engine.cpp6
-rw-r--r--src/newgrf_gui.cpp12
-rw-r--r--src/newgrf_sound.cpp2
-rw-r--r--src/object_cmd.cpp4
-rw-r--r--src/openttd.cpp6
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/os/macosx/string_osx.cpp2
-rw-r--r--src/rail_cmd.cpp4
-rw-r--r--src/rail_gui.cpp4
-rw-r--r--src/saveload/afterload.cpp10
-rw-r--r--src/saveload/animated_tile_sl.cpp4
-rw-r--r--src/saveload/engine_sl.cpp3
-rw-r--r--src/saveload/game_sl.cpp4
-rw-r--r--src/saveload/labelmaps_sl.cpp4
-rw-r--r--src/saveload/linkgraph_sl.cpp4
-rw-r--r--src/saveload/oldloader_sl.cpp2
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/saveload/waypoint_sl.cpp3
-rw-r--r--src/script/squirrel_helper.hpp6
-rw-r--r--src/settings.cpp4
-rw-r--r--src/settings_gui.cpp38
-rw-r--r--src/settingsgen/settingsgen.cpp7
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/station_gui.cpp12
-rw-r--r--src/story_gui.cpp6
-rw-r--r--src/strgen/strgen_base.cpp22
-rw-r--r--src/string.cpp18
-rw-r--r--src/stringfilter.cpp5
-rw-r--r--src/strings.cpp2
-rw-r--r--src/texteff.cpp18
-rw-r--r--src/textfile_gui.cpp4
-rw-r--r--src/timetable_cmd.cpp4
-rw-r--r--src/toolbar_gui.cpp66
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/train_cmd.cpp2
-rw-r--r--src/train_gui.cpp3
-rw-r--r--src/tunnelbridge_cmd.cpp5
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/vehicle_cmd.cpp6
-rw-r--r--src/vehicle_gui.cpp15
-rw-r--r--src/vehiclelist.cpp14
-rw-r--r--src/viewport.cpp88
-rw-r--r--src/widgets/dropdown.cpp2
-rw-r--r--src/window.cpp4
79 files changed, 404 insertions, 405 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 0609696e1..8b00de988 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -481,7 +481,7 @@ struct AISettingsWindow : public Window {
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);
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 353e08080..7e1671789 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -219,7 +219,7 @@ class BuildAirportWindow : public PickerWindowBase {
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;
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 1286dc5a7..5b6976e67 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -140,7 +140,7 @@ class ReplaceVehicleWindow : public Window {
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)
@@ -468,8 +468,8 @@ public:
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;
}
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index bbb54551e..94b709c63 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -416,12 +416,13 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
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;
}
}
}
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index a118b1c99..c3d8743a2 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1246,7 +1246,7 @@ struct BuildVehicleWindow : Window {
/* 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++;
@@ -1284,7 +1284,7 @@ struct BuildVehicleWindow : Window {
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;
}
@@ -1302,7 +1302,7 @@ struct BuildVehicleWindow : Window {
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;
}
@@ -1330,7 +1330,7 @@ struct BuildVehicleWindow : Window {
/* 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;
}
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index b34862f69..a705687b0 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -606,10 +606,10 @@ private:
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;
@@ -642,8 +642,8 @@ private:
{
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);
}
}
@@ -662,7 +662,7 @@ private:
const Group *g;
FOR_ALL_GROUPS(g) {
if (g->owner == owner && g->vehicle_type == vtype) {
- *list.Append() = g;
+ list.push_back(g);
}
}
diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp
index 4d20ed1ab..a6f7e4fe8 100644
--- a/src/core/pool_type.hpp
+++ b/src/core/pool_type.hpp
@@ -50,7 +50,7 @@ struct PoolBase {
*/
PoolBase(PoolType pt) : type(pt)
{
- *PoolBase::GetPools()->Append() = this;
+ PoolBase::GetPools()->push_back(this);
}
virtual ~PoolBase();
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp
index 0bd9bd296..0917c5423 100644
--- a/src/core/smallmap_type.hpp
+++ b/src/core/smallmap_type.hpp
@@ -143,9 +143,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
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;
}
@@ -160,9 +158,10 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
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()
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index b989d44c5..5961a9698 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -67,17 +67,6 @@ public:
~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
@@ -112,7 +101,7 @@ public:
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;
}
@@ -157,6 +146,23 @@ public:
}
};
+/**
+ * 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.
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index 53e0cf735..d55e7e2b3 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -75,14 +75,14 @@ struct SetDateWindow : Window {
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;
@@ -91,7 +91,7 @@ struct SetDateWindow : Window {
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;
diff --git a/src/engine.cpp b/src/engine.cpp
index b7be293af..7412ec639 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -490,11 +490,12 @@ 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;
}
}
}
diff --git a/src/fios.h b/src/fios.h
index 85b6b0dd6..b1d260f84 100644
--- a/src/fios.h
+++ b/src/fios.h
@@ -120,7 +120,8 @@ public:
*/
inline FiosItem *Append()
{
- return this->files.Append();
+ /*C++17: return &*/ this->files.emplace_back();
+ return &this->files.back();
}
/**
diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp
index 781d0daba..4d67b6955 100644
--- a/src/game/game_text.cpp
+++ b/src/game/game_text.cpp
@@ -115,7 +115,7 @@ LanguageStrings *ReadRawLanguageStrings(const char *file)
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;
@@ -194,7 +194,7 @@ struct TranslationWriter : LanguageWriter {
char *dest = MallocT<char>(length + 1);
memcpy(dest, buffer, length);
dest[length] = '\0';
- *this->strings->Append() = dest;
+ this->strings->push_back(dest);
}
};
@@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter {
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)
@@ -246,7 +246,7 @@ public:
{
if (strcmp(filename, exclude) == 0) return true;
- *gs->raw_strings.Append() = ReadRawLanguageStrings(filename);
+ gs->raw_strings.push_back(ReadRawLanguageStrings(filename));
return true;
}
};
@@ -269,7 +269,7 @@ GameStrings *LoadTranslations()
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);
@@ -324,8 +324,8 @@ void GameStrings::Compile()
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);
}
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 4631d02ee..d4aad6221 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -289,7 +289,7 @@ static DropDownList *BuildMapsizeDropDown()
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;
diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp
index 786e07408..ee0ba1533 100644
--- a/src/gfx_layout.cpp
+++ b/src/gfx_layout.cpp
@@ -150,7 +150,7 @@ 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; }
@@ -498,7 +498,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
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;
}
@@ -527,7 +527,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
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());
@@ -574,7 +574,7 @@ const ParagraphLayouter::Line *FallbackParagraphLayout::NextLine(int max_width)
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;
}
@@ -720,7 +720,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
/* 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');
@@ -834,7 +834,7 @@ Font *Layouter::GetFont(FontSize size, TextColour 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;
}
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 1acf7728c..69bdb3b1f 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -1140,7 +1140,7 @@ private:
const Company *c;
FOR_ALL_COMPANIES(c) {
- *this->companies.Append() = c;
+ this->companies.push_back(c);
}
this->companies.shrink_to_fit();
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index d64f9c51b..eb7aac0b7 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -129,8 +129,8 @@ private:
{
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);
}
}
@@ -175,7 +175,7 @@ private:
const Group *g;
FOR_ALL_GROUPS(g) {
if (g->owner == owner && g->vehicle_type == this->vli.vtype) {
- *list.Append() = g;
+ list.push_back(g);
}
}
diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp
index 24e6b6c41..8bec7e400 100644
--- a/src/hotkeys.cpp
+++ b/src/hotkeys.cpp
@@ -255,7 +255,7 @@ HotkeyList::HotkeyList(const char *ini_group, Hotkey *items, GlobalHotkeyHandler
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()
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 32c62bfa3..5bcc03bdb 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1206,7 +1206,7 @@ protected:
const Industry *i;
FOR_ALL_INDUSTRIES(i) {
- *this->industries.Append() = i;
+ this->industries.push_back(i);
}
this->industries.shrink_to_fit();
@@ -2415,12 +2415,13 @@ struct IndustryCargoesWindow : public Window {
_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));
@@ -2430,12 +2431,13 @@ struct IndustryCargoesWindow : public Window {
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;
@@ -2493,12 +2495,13 @@ struct IndustryCargoesWindow : public Window {
_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);
@@ -2506,12 +2509,13 @@ struct IndustryCargoesWindow : public Window {
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.
@@ -2708,7 +2712,7 @@ struct IndustryCargoesWindow : public Window {
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;
@@ -2725,7 +2729,7 @@ struct IndustryCargoesWindow : public Window {
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;
diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp
index 532792e7c..d8cbf9b50 100644
--- a/src/linkgraph/linkgraph.cpp
+++ b/src/linkgraph/linkgraph.cpp
@@ -159,7 +159,7 @@ 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,
diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp
index fb3c187c0..82649679f 100644
--- a/src/music/midifile.cpp
+++ b/src/music/midifile.cpp
@@ -21,7 +21,6 @@
#include "../console_func.h"
#include "../console_internal.h"
-
/* SMF reader based on description at: http://www.somascape.org/midi/tech/mfile.html */
@@ -217,7 +216,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
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;
@@ -226,7 +225,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
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;
@@ -267,7 +266,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
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;
@@ -275,7 +274,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
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;
}
@@ -285,7 +284,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
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;
}
@@ -336,7 +335,7 @@ static bool FixupMidiData(MidiFile &target)
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());
}
}
@@ -508,14 +507,14 @@ struct MpsMachine {
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);
}
/**
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index c0365742b..1ea5389d4 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -100,7 +100,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // GE
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);
}
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index 470d97e68..f3dc2cb9a 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -32,7 +32,7 @@ TCPConnecter::TCPConnecter(const NetworkAddress &address) :
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();
}
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index 2d3e89b4e..abec3fbc8 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -63,7 +63,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
return;
}
- *_http_connections.Append() = this;
+ _http_connections.push_back(this);
}
/** Free whatever needs to be freed. */
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index db655c0cf..7babf78d6 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -26,14 +26,14 @@ 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);
}
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 3780258bd..1ddd7478c 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -633,12 +633,12 @@ void NetworkAddServer(const char *b)
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);
}
}
@@ -650,7 +650,7 @@ 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)));
}
}
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index a99a5069a..fff4dd328 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -77,7 +77,7 @@ struct PacketReader : LoadFilter {
/* 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);
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index 54798f4b7..fe7905de8 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -165,7 +165,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
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++) {
@@ -278,7 +278,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
}
}
if (!found) {
- *this->infos.Append() = ci;
+ this->infos.push_back(ci);
} else {
delete ci;
}
@@ -300,7 +300,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
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;
}
@@ -579,11 +579,11 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l
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;
@@ -905,7 +905,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
for (uint i = 0; i < ci->dependency_count; i++) {
if (ci->dependencies[i] == child->id) {
- *parents.Append() = ci;
+ parents.push_back(ci);
break;
}
}
@@ -919,7 +919,7 @@ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVect
*/
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
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 109e63c95..19c075258 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -391,7 +391,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
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);
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index e3c4555bf..7b65f6b0c 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -253,7 +253,7 @@ protected:
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. */
@@ -1737,9 +1737,7 @@ struct NetworkClientListPopupWindow : Window {
*/
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) :
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 67f4c6fd9..8a1e75d2f 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -2101,7 +2101,7 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
break;
}
}
- if (!contains) *_network_ban_list.Append() = stredup(ip);
+ if (!contains) _network_ban_list.push_back(stredup(ip));
}
uint n = 0;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 6ff991441..63296593d 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -472,10 +472,7 @@ static StringIDMappingVector _string_to_grf_mapping;
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});
}
/**
@@ -659,11 +656,12 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
/* 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 ... */
@@ -1909,18 +1907,19 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte
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;
}
@@ -2594,7 +2593,7 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader
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;
@@ -2799,14 +2798,14 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By
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();
@@ -4335,7 +4334,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, Byte
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;
}
@@ -4796,29 +4795,30 @@ static void NewSpriteGroup(ByteReader *buf)
/* 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);
+ 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);
+ 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. */
@@ -7851,9 +7851,7 @@ static bool HandleParameterInfo(ByteReader *buf)
}
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);
@@ -8405,7 +8403,7 @@ static void InitNewGRFFile(const GRFConfig *config)
}
newfile = new GRFFile(config);
- *_grf_files.Append() = _cur.grffile = newfile;
+ _grf_files.push_back(_cur.grffile = newfile);
}
/**
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index e25f6d085..e201ca736 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -666,7 +666,8 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
/* 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;
@@ -674,10 +675,10 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun
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;
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 730207c6b..698084115 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -85,9 +85,9 @@ GRFConfig::GRFConfig(const GRFConfig &config) :
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]));
}
}
}
@@ -611,9 +611,9 @@ compatible_grf:
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]));
}
}
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 07e0f8af7..b2dd4d1a3 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -1196,9 +1196,7 @@ static SmallVector<ListOrderChange, 16> _list_order_changes;
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});
}
/**
@@ -1231,7 +1229,7 @@ void CommitVehicleListOrderChanges()
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);
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index fb712700c..0db38e297 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -378,7 +378,7 @@ struct NewGRFParametersWindow : public Window {
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);
@@ -927,11 +927,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
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));
}
}
@@ -1464,7 +1464,7 @@ private:
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);
/*
@@ -1475,7 +1475,7 @@ private:
* 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);
}
}
}
@@ -1558,7 +1558,7 @@ void ShowMissingContentWindow(const GRFConfig *list)
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);
}
diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp
index dfe7e403e..e9f1163c6 100644
--- a/src/newgrf_sound.cpp
+++ b/src/newgrf_sound.cpp
@@ -32,7 +32,7 @@ static SmallVector<SoundEntry, 8> _sounds;
*/
SoundEntry *AllocateSound(uint num)
{
- SoundEntry *sound = _sounds.Append(num);
+ SoundEntry *sound = grow(_sounds, num);
MemSetT(sound, 0, num);
return sound;
}
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 0b18dd4b1..287a146f3 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -530,9 +530,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
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);
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 5478ec5a2..5c7af2dfc 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -445,7 +445,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
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;
@@ -1177,7 +1177,7 @@ static void CheckCaches()
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();
@@ -1195,7 +1195,7 @@ static void CheckCaches()
/* 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();
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 612c1ba81..0b1ee2ae6 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -1297,7 +1297,7 @@ public:
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;
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp
index 261885187..136542cc1 100644
--- a/src/os/macosx/string_osx.cpp
+++ b/src/os/macosx/string_osx.cpp
@@ -78,7 +78,7 @@ public:
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);
}
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 17df27fc5..3a24fb65f 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1623,7 +1623,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
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);
}
}
@@ -1705,7 +1705,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
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);
}
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index a26cc9902..827f24456 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -2007,7 +2007,7 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option)
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 };
@@ -2038,7 +2038,7 @@ DropDownList *GetRailTypeDropDownList(bool for_replacement, bool all_option)
}
item->SetParam(0, rti->strings.menu_text);
item->SetParam(1, rti->max_speed);
- *list->Append() = item;
+ list->push_back(item);
}
return list;
}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 851eb6a78..43a415c20 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2954,24 +2954,24 @@ bool AfterLoadGame()
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:
diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp
index 36571c418..5b9185263 100644
--- a/src/saveload/animated_tile_sl.cpp
+++ b/src/saveload/animated_tile_sl.cpp
@@ -42,14 +42,14 @@ static void Load_ANIT()
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);
}
diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp
index 87b18336c..03a086a15 100644
--- a/src/saveload/engine_sl.cpp
+++ b/src/saveload/engine_sl.cpp
@@ -190,7 +190,8 @@ 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);
}
}
diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp
index ff48ab135..cffff5018 100644
--- a/src/saveload/game_sl.cpp
+++ b/src/saveload/game_sl.cpp
@@ -153,10 +153,10 @@ static void Load_GSTR()
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 */
diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp
index a25abe722..3d930e768 100644
--- a/src/saveload/labelmaps_sl.cpp
+++ b/src/saveload/labelmaps_sl.cpp
@@ -48,7 +48,7 @@ void AfterLoadLabelMaps()
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++) {
@@ -114,7 +114,7 @@ static void Load_RAIL()
while (SlIterateArray() != -1) {
SlObject(&lo, _label_object_desc);
- *_railtype_list.Append() = (RailTypeLabel)lo.label;
+ _railtype_list.push_back((RailTypeLabel)lo.label);
}
}
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 1ff247042..842ad6d42 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -69,7 +69,7 @@ const SaveLoad *GetLinkGraphJobDesc()
char *&address = reinterpret_cast<char *&>(sl.address);
address -= offset_gamesettings;
address += offset_component;
- *(saveloads.Append()) = sl;
+ saveloads.push_back(sl);
}
desc = GetSettingDescription(++setting);
}
@@ -82,7 +82,7 @@ const SaveLoad *GetLinkGraphJobDesc()
int i = 0;
do {
- *(saveloads.Append()) = job_desc[i++];
+ saveloads.push_back(job_desc[i++]);
} while (saveloads[saveloads.size() - 1].cmd != SL_END);
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 1974bb31f..7b445858e 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -651,7 +651,7 @@ static bool LoadOldAnimTileList(LoadgameState *ls, int num)
/* 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;
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 2aa19af81..ee4876fd5 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -143,7 +143,7 @@ struct MemoryDumper {
/* 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;
}
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index 47d0c5ab3..9e5d16396 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -178,7 +178,8 @@ static void Load_WAYP()
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;
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp
index 8d1ee29fc..c362601eb 100644
--- a/src/script/squirrel_helper.hpp
+++ b/src/script/squirrel_helper.hpp
@@ -117,7 +117,7 @@ namespace SQConvert {
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;
}
@@ -137,7 +137,7 @@ namespace SQConvert {
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");
@@ -151,7 +151,7 @@ namespace SQConvert {
arr->size = data.size();
memcpy(arr->array, data.Begin(), sizeof(int32) * data.size());
- *ptr->Append() = arr;
+ ptr->push_back(arr);
return arr;
}
diff --git a/src/settings.cpp b/src/settings.cpp
index 8f57b6bda..2c9fc305e 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -727,7 +727,7 @@ static void IniLoadSettingList(IniFile *ini, const char *grpname, StringList *li
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));
}
}
@@ -1777,7 +1777,7 @@ void GetGRFPresetList(GRFPresetList *list)
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));
}
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 8b20bb9f2..da4989e85 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -129,7 +129,7 @@ static DropDownList *BuildSetDropDownList(int *selected_index, bool allow_select
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;
@@ -213,13 +213,13 @@ struct GameOptionsWindow : Window {
/* Add non-custom currencies; sorted naturally */
for (uint i = 0; i < CURRENCY_END; items++, i++) {
if (i == CURRENCY_CUSTOM) continue;
- *list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
+ 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;
}
@@ -237,7 +237,7 @@ struct GameOptionsWindow : Window {
}
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;
}
@@ -251,20 +251,20 @@ struct GameOptionsWindow : Window {
/* Add and sort newgrf townnames generators */
for (int i = 0; i < _nb_grf_names; i++) {
int result = _nb_orig_names + i;
- *list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0);
+ 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;
@@ -275,7 +275,7 @@ struct GameOptionsWindow : Window {
*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;
}
@@ -284,7 +284,7 @@ struct GameOptionsWindow : Window {
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;
@@ -296,7 +296,7 @@ struct GameOptionsWindow : Window {
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;
@@ -305,7 +305,7 @@ struct GameOptionsWindow : Window {
*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;
}
@@ -315,7 +315,7 @@ struct GameOptionsWindow : Window {
*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;
}
@@ -1964,16 +1964,16 @@ struct GameSettingsWindow : Window {
* 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;
@@ -2130,7 +2130,7 @@ struct GameSettingsWindow : Window {
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);
diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp
index 64901a89f..1847bedff 100644
--- a/src/settingsgen/settingsgen.cpp
+++ b/src/settingsgen/settingsgen.cpp
@@ -121,9 +121,10 @@ public:
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;
}
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 0a1f0dd5d..cab19c22f 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -63,7 +63,7 @@ struct SignList {
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();
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 2dee09fe8..fcbf514bc 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -942,7 +942,7 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl
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);
@@ -1386,7 +1386,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
/* 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);
}
}
@@ -3538,7 +3538,7 @@ void DeleteStaleLinks(Station *from)
}
}
if (!found_to || !found_from) continue;
- *(vehicles.Append()) = l->GetFirstSharedVehicle();
+ vehicles.push_back(l->GetFirstSharedVehicle());
}
auto iter = vehicles.begin();
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index e1f5daa69..98ac80df4 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -189,14 +189,14 @@ protected:
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);
}
}
}
@@ -2135,7 +2135,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
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--;
}
@@ -2153,7 +2153,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
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
@@ -2187,9 +2187,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join)
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) &&
diff --git a/src/story_gui.cpp b/src/story_gui.cpp
index 78c8b9793..aed00358d 100644
--- a/src/story_gui.cpp
+++ b/src/story_gui.cpp
@@ -57,7 +57,7 @@ protected:
const StoryPage *p;
FOR_ALL_STORY_PAGES(p) {
if (this->IsPageAvailable(p)) {
- *this->story_pages.Append() = p;
+ this->story_pages.push_back(p);
}
}
@@ -85,7 +85,7 @@ protected:
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);
}
}
}
@@ -248,7 +248,7 @@ protected:
item = str_item;
}
- *list->Append() = item;
+ list->push_back(item);
page_num++;
}
diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp
index 0e75537fb..12d993844 100644
--- a/src/strgen/strgen_base.cpp
+++ b/src/strgen/strgen_base.cpp
@@ -242,7 +242,7 @@ struct Buffer : SmallVector<byte, 256> {
*/
void AppendByte(byte value)
{
- *this->Append() = value;
+ this->push_back(value);
}
/**
@@ -252,19 +252,19 @@ struct Buffer : SmallVector<byte, 256> {
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);
}
diff --git a/src/string.cpp b/src/string.cpp
index 5246f7827..c23202acb 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -634,8 +634,8 @@ public:
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()
@@ -660,17 +660,17 @@ public:
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;
diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp
index b12abff7f..e546a4186 100644
--- a/src/stringfilter.cpp
+++ b/src/stringfilter.cpp
@@ -76,9 +76,8 @@ void StringFilter::SetFilterTerm(const char *str)
/* 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);
diff --git a/src/strings.cpp b/src/strings.cpp
index 61a5098ab..c3f306183 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1932,7 +1932,7 @@ static void GetLanguageList(const char *path)
} 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);
diff --git a/src/texteff.cpp b/src/texteff.cpp
index 92c201704..c81d9a95d 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -48,20 +48,20 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
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;
}
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index e9706c752..b4911a968 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -365,11 +365,11 @@ static void Xunzip(byte **bufp, size_t *sizep)
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);
}
}
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index dec4f7d44..8107fc3d2 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -285,10 +285,10 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
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();
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 7052dc4e2..eac99f249 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -198,7 +198,7 @@ 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);
}
@@ -224,27 +224,27 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
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);
@@ -318,24 +318,24 @@ enum OptionMenuEntries {
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);
@@ -464,10 +464,10 @@ enum MapMenuEntries {
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;
}
@@ -475,11 +475,11 @@ static CallBackFunction ToolbarMapClick(Window *w)
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;
}
@@ -897,7 +897,7 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
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;
@@ -905,7 +905,7 @@ static CallBackFunction ToolbarBuildRoadClick(Window *w)
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);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index bf8fb4b87..55f65e320 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -654,7 +654,7 @@ private:
const Town *t;
FOR_ALL_TOWNS(t) {
- *this->towns.Append() = t;
+ this->towns.push_back(t);
}
this->towns.shrink_to_fit();
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index db3773f96..0d4df42f4 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -823,7 +823,7 @@ typedef SmallVector<Train *, 16> TrainList;
*/
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);
}
/**
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index eab6a33e3..3036096c8 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -280,7 +280,8 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su
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;
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 06dc24e84..764551d81 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -681,9 +681,8 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
* 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 */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 0e05d68f2..f1b727971 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2283,9 +2283,7 @@ void Vehicle::GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) cons
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();
}
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 636aadb49..8e578cd68 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -417,11 +417,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
* - 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) {
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 4a42d746d..9fcebd4e6 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -168,13 +168,13 @@ DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autorepla
{
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;
@@ -438,10 +438,7 @@ struct RefitWindow : public Window {
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.
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 39ec90e8b..c98797573 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -85,7 +85,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
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;
@@ -98,7 +98,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
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
@@ -128,7 +128,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
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;
}
}
@@ -142,7 +142,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
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;
@@ -151,7 +151,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
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;
@@ -161,7 +161,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
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;
@@ -173,7 +173,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli
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;
}
}
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 5d6f58268..929616ba5 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -499,13 +499,14 @@ static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y,
{
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;
}
/**
@@ -708,29 +709,30 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
return;
}
- ParentSpriteToDraw *ps = _vd.parent_sprites_to_draw.Append();
- ps->x = tmp_x;
- ps->y = tmp_y;
+ /*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.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.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.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.zmin = z + bb_offset_z;
+ ps.zmax = z + max(bb_offset_z, dz) - 1;
- ps->comparison_done = false;
- ps->first_child = -1;
+ ps.comparison_done = false;
+ ps.first_child = -1;
- _vd.last_child = &ps->first_child;
+ _vd.last_child = &ps.first_child;
if (_vd.combine_sprites == SPRITE_COMBINE_PENDING) _vd.combine_sprites = SPRITE_COMBINE_ACTIVE;
}
@@ -826,33 +828,35 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran
*_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;
}
@@ -1588,7 +1592,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
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);
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 6acbd79c2..33d59effc 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -509,7 +509,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
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)));
}
}
diff --git a/src/window.cpp b/src/window.cpp
index 471ac08a2..a8d1ce75e 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -109,7 +109,7 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi
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()
@@ -3242,7 +3242,7 @@ 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);
}