summaryrefslogtreecommitdiff
path: root/src/saveload/station_sl.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-05-31 22:26:44 +0200
committerGitHub <noreply@github.com>2021-05-31 22:26:44 +0200
commit9fff00ba205260ee5e11b50f87a3edee9b7e76a3 (patch)
tree2c6ee1eb6f0df2539c9ed17a2ae05541518a7dc9 /src/saveload/station_sl.cpp
parent956d761e3ef1968c6470a9e78597c5531ed7c332 (diff)
downloadopenttd-9fff00ba205260ee5e11b50f87a3edee9b7e76a3.tar.xz
Codechange: C++-ify lists for SaveLoad (#9323)
Basically, this changes "SaveLoad *" to either: 1) "SaveLoadTable" if a list of SaveLoads was meant 2) "SaveLoad &" if a single entry was meant As added bonus, this removes SL_END / SLE_END / SLEG_END. This also adds core/span.hpp, a "std::span"-lite.
Diffstat (limited to 'src/saveload/station_sl.cpp')
-rw-r--r--src/saveload/station_sl.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 74f3a5fb9..cd1b93138 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -154,8 +154,6 @@ static const SaveLoad _roadstop_desc[] = {
SLE_CONDNULL(4, SL_MIN_VERSION, SLV_25),
SLE_CONDNULL(1, SLV_25, SLV_26),
-
- SLE_END()
};
static const SaveLoad _old_station_desc[] = {
@@ -213,8 +211,6 @@ static const SaveLoad _old_station_desc[] = {
/* reserve extra space in savegame here. (currently 32 bytes) */
SLE_CONDNULL(32, SLV_2, SL_MAX_VERSION),
-
- SLE_END()
};
static uint16 _waiting_acceptance;
@@ -227,8 +223,6 @@ static Money _cargo_feeder_share;
static const SaveLoad _station_speclist_desc[] = {
SLE_CONDVAR(StationSpecList, grfid, SLE_UINT32, SLV_27, SL_MAX_VERSION),
SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8, SLV_27, SL_MAX_VERSION),
-
- SLE_END()
};
std::list<CargoPacket *> _packets;
@@ -247,7 +241,6 @@ static const SaveLoad _flow_desc[] = {
SLE_VAR(FlowSaveLoad, via, SLE_UINT16),
SLE_VAR(FlowSaveLoad, share, SLE_UINT32),
SLE_CONDVAR(FlowSaveLoad, restricted, SLE_BOOL, SLV_187, SL_MAX_VERSION),
- SLE_END()
};
/**
@@ -255,7 +248,7 @@ static const SaveLoad _flow_desc[] = {
* some of the variables itself are private.
* @return the saveload description for GoodsEntry.
*/
-const SaveLoad *GetGoodsDesc()
+SaveLoadTable GetGoodsDesc()
{
static const SaveLoad goods_desc[] = {
SLEG_CONDVAR( _waiting_acceptance, SLE_UINT16, SL_MIN_VERSION, SLV_68),
@@ -279,7 +272,6 @@ const SaveLoad *GetGoodsDesc()
SLE_CONDVAR(GoodsEntry, node, SLE_UINT16, SLV_183, SL_MAX_VERSION),
SLEG_CONDVAR( _num_flows, SLE_UINT32, SLV_183, SL_MAX_VERSION),
SLE_CONDVAR(GoodsEntry, max_waiting_cargo, SLE_UINT32, SLV_183, SL_MAX_VERSION),
- SLE_END()
};
return goods_desc;
@@ -290,7 +282,6 @@ typedef std::pair<const StationID, std::list<CargoPacket *> > StationCargoPair;
static const SaveLoad _cargo_list_desc[] = {
SLE_VAR(StationCargoPair, first, SLE_UINT16),
SLE_LST(StationCargoPair, second, REF_CARGO_PACKET),
- SLE_END()
};
/**
@@ -398,8 +389,6 @@ static const SaveLoad _base_station_desc[] = {
SLE_VAR(BaseStation, random_bits, SLE_UINT16),
SLE_VAR(BaseStation, waiting_triggers, SLE_UINT8),
SLE_VAR(BaseStation, num_specs, SLE_UINT8),
-
- SLE_END()
};
static OldPersistentStorage _old_st_persistent_storage;
@@ -440,8 +429,6 @@ static const SaveLoad _station_desc[] = {
SLE_LST(Station, loading_vehicles, REF_VEHICLE),
SLE_CONDVAR(Station, always_accepted, SLE_FILE_U32 | SLE_VAR_U64, SLV_127, SLV_EXTEND_CARGOTYPES),
SLE_CONDVAR(Station, always_accepted, SLE_UINT64, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION),
-
- SLE_END()
};
static const SaveLoad _waypoint_desc[] = {
@@ -453,15 +440,13 @@ static const SaveLoad _waypoint_desc[] = {
SLE_CONDVAR(Waypoint, train_station.tile, SLE_UINT32, SLV_124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.w, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
SLE_CONDVAR(Waypoint, train_station.h, SLE_FILE_U8 | SLE_VAR_U16, SLV_124, SL_MAX_VERSION),
-
- SLE_END()
};
/**
* Get the base station description to be used for SL_ST_INCLUDE
* @return the base station description.
*/
-const SaveLoad *GetBaseStationDescription()
+SaveLoadTable GetBaseStationDescription()
{
return _base_station_desc;
}
@@ -469,7 +454,7 @@ const SaveLoad *GetBaseStationDescription()
static void RealSave_STNN(BaseStation *bst)
{
bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0;
- SlObject(bst, waypoint ? _waypoint_desc : _station_desc);
+ SlObject(bst, waypoint ? SaveLoadTable(_waypoint_desc) : SaveLoadTable(_station_desc));
if (!waypoint) {
Station *st = Station::From(bst);
@@ -524,7 +509,7 @@ static void Load_STNN()
bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0;
BaseStation *bst = waypoint ? (BaseStation *)new (index) Waypoint() : new (index) Station();
- SlObject(bst, waypoint ? _waypoint_desc : _station_desc);
+ SlObject(bst, waypoint ? SaveLoadTable(_waypoint_desc) : SaveLoadTable(_station_desc));
if (!waypoint) {
Station *st = Station::From(bst);