summaryrefslogtreecommitdiff
path: root/src/saveload
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/saveload
parentca2f33c6d025c0c45fb4bc472493290445312de5 (diff)
downloadopenttd-a0f36a50e6324f570985f5010eb0543ec0673aeb.tar.xz
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
Diffstat (limited to 'src/saveload')
-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
9 files changed, 19 insertions, 17 deletions
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;