diff options
author | Patric Stout <truebrain@openttd.org> | 2021-05-31 22:26:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 22:26:44 +0200 |
commit | 9fff00ba205260ee5e11b50f87a3edee9b7e76a3 (patch) | |
tree | 2c6ee1eb6f0df2539c9ed17a2ae05541518a7dc9 /src/saveload | |
parent | 956d761e3ef1968c6470a9e78597c5531ed7c332 (diff) | |
download | openttd-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')
31 files changed, 85 insertions, 195 deletions
diff --git a/src/saveload/ai_sl.cpp b/src/saveload/ai_sl.cpp index 3bc1d0f87..fcb78f2ed 100644 --- a/src/saveload/ai_sl.cpp +++ b/src/saveload/ai_sl.cpp @@ -30,7 +30,6 @@ static const SaveLoad _ai_company[] = { SLEG_SSTR(_ai_saveload_settings, SLE_STR), SLEG_CONDVAR(_ai_saveload_version, SLE_UINT32, SLV_108, SL_MAX_VERSION), SLEG_CONDVAR(_ai_saveload_is_random, SLE_BOOL, SLV_136, SL_MAX_VERSION), - SLE_END() }; static void SaveReal_AIPL(int *index_ptr) diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp index 88f925cc5..ef343fc17 100644 --- a/src/saveload/autoreplace_sl.cpp +++ b/src/saveload/autoreplace_sl.cpp @@ -21,7 +21,6 @@ static const SaveLoad _engine_renew_desc[] = { SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS), SLE_CONDVAR(EngineRenew, group_id, SLE_UINT16, SLV_60, SL_MAX_VERSION), SLE_CONDVAR(EngineRenew, replace_when_old, SLE_BOOL, SLV_175, SL_MAX_VERSION), - SLE_END() }; static void Save_ERNW() diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp index 75f081eb2..3ca64d77e 100644 --- a/src/saveload/cargomonitor_sl.cpp +++ b/src/saveload/cargomonitor_sl.cpp @@ -24,7 +24,6 @@ struct TempStorage { static const SaveLoad _cargomonitor_pair_desc[] = { SLE_VAR(TempStorage, number, SLE_UINT32), SLE_VAR(TempStorage, amount, SLE_UINT32), - SLE_END() }; static CargoMonitorID FixupCargoMonitor(CargoMonitorID number) diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp index e9476fd4b..1b9bb5cb9 100644 --- a/src/saveload/cargopacket_sl.cpp +++ b/src/saveload/cargopacket_sl.cpp @@ -83,7 +83,7 @@ * some of the variables itself are private. * @return the saveload description for CargoPackets. */ -const SaveLoad *GetCargoPacketDesc() +SaveLoadTable GetCargoPacketDesc() { static const SaveLoad _cargopacket_desc[] = { SLE_VAR(CargoPacket, source, SLE_UINT16), @@ -97,8 +97,6 @@ const SaveLoad *GetCargoPacketDesc() /* Used to be paid_for, but that got changed. */ SLE_CONDNULL(1, SL_MIN_VERSION, SLV_121), - - SLE_END() }; return _cargopacket_desc; } diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 5770f9791..21d02121b 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -293,8 +293,6 @@ static const SaveLoad _company_desc[] = { SLE_CONDVAR(CompanyProperties, terraform_limit, SLE_UINT32, SLV_156, SL_MAX_VERSION), SLE_CONDVAR(CompanyProperties, clear_limit, SLE_UINT32, SLV_156, SL_MAX_VERSION), SLE_CONDVAR(CompanyProperties, tree_limit, SLE_UINT32, SLV_175, SL_MAX_VERSION), - - SLE_END() }; static const SaveLoad _company_settings_desc[] = { @@ -314,8 +312,6 @@ static const SaveLoad _company_settings_desc[] = { SLE_CONDVAR(Company, settings.vehicle.servint_ships, SLE_UINT16, SLV_120, SL_MAX_VERSION), SLE_CONDNULL(63, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _company_settings_skip_desc[] = { @@ -336,8 +332,6 @@ static const SaveLoad _company_settings_skip_desc[] = { SLE_CONDNULL(2, SLV_120, SL_MAX_VERSION), // settings.vehicle.servint_ships SLE_CONDNULL(63, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _company_economy_desc[] = { @@ -353,8 +347,6 @@ static const SaveLoad _company_economy_desc[] = { SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, 32, SLV_170, SLV_EXTEND_CARGOTYPES), SLE_CONDARR(CompanyEconomyEntry, delivered_cargo, SLE_UINT32, NUM_CARGO, SLV_EXTEND_CARGOTYPES, SL_MAX_VERSION), SLE_VAR(CompanyEconomyEntry, performance_history, SLE_INT32), - - SLE_END() }; /* We do need to read this single value, as the bigger it gets, the more data is stored */ @@ -390,7 +382,6 @@ static const SaveLoad _company_ai_desc[] = { SLE_CONDNULL(32, SL_MIN_VERSION, SLV_107), SLE_CONDNULL(64, SLV_2, SLV_107), - SLE_END() }; static const SaveLoad _company_ai_build_rec_desc[] = { @@ -399,14 +390,12 @@ static const SaveLoad _company_ai_build_rec_desc[] = { SLE_CONDNULL(2, SL_MIN_VERSION, SLV_6), SLE_CONDNULL(4, SLV_6, SLV_107), SLE_CONDNULL(8, SL_MIN_VERSION, SLV_107), - SLE_END() }; static const SaveLoad _company_livery_desc[] = { SLE_CONDVAR(Livery, in_use, SLE_UINT8, SLV_34, SL_MAX_VERSION), SLE_CONDVAR(Livery, colour1, SLE_UINT8, SLV_34, SL_MAX_VERSION), SLE_CONDVAR(Livery, colour2, SLE_UINT8, SLV_34, SL_MAX_VERSION), - SLE_END() }; static void SaveLoad_PLYR_common(Company *c, CompanyProperties *cprops) diff --git a/src/saveload/depot_sl.cpp b/src/saveload/depot_sl.cpp index bd84faefc..fb8944dba 100644 --- a/src/saveload/depot_sl.cpp +++ b/src/saveload/depot_sl.cpp @@ -25,7 +25,6 @@ static const SaveLoad _depot_desc[] = { SLE_CONDVAR(Depot, town_cn, SLE_UINT16, SLV_141, SL_MAX_VERSION), SLE_CONDSSTR(Depot, name, SLE_STR, SLV_141, SL_MAX_VERSION), SLE_CONDVAR(Depot, build_date, SLE_INT32, SLV_142, SL_MAX_VERSION), - SLE_END() }; static void Save_DEPT() diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index a7d181946..2c785d554 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -46,7 +46,6 @@ static const SaveLoad _economy_desc[] = { SLE_VAR(Economy, infl_amount, SLE_UINT8), SLE_VAR(Economy, infl_amount_pr, SLE_UINT8), SLE_CONDVAR(Economy, industry_daily_change_counter, SLE_UINT32, SLV_102, SL_MAX_VERSION), - SLE_END() }; /** Economy variables */ @@ -67,7 +66,6 @@ static const SaveLoad _cargopayment_desc[] = { SLE_VAR(CargoPayment, route_profit, SLE_INT64), SLE_VAR(CargoPayment, visual_profit, SLE_INT64), SLE_CONDVAR(CargoPayment, visual_transfer, SLE_INT64, SLV_181, SL_MAX_VERSION), - SLE_END() }; static void Save_CAPY() diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index b0b9d02d4..eea3a0bcf 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -42,8 +42,6 @@ static const SaveLoad _engine_desc[] = { SLE_CONDSSTR(Engine, name, SLE_STR, SLV_84, SL_MAX_VERSION), SLE_CONDNULL(16, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static std::vector<Engine*> _temp_engine; @@ -173,7 +171,6 @@ static const SaveLoad _engine_id_mapping_desc[] = { SLE_VAR(EngineIDMapping, internal_id, SLE_UINT16), SLE_VAR(EngineIDMapping, type, SLE_UINT8), SLE_VAR(EngineIDMapping, substitute_id, SLE_UINT8), - SLE_END() }; static void Save_EIDS() diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 00ca6d9ab..055a5fbfc 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -30,7 +30,6 @@ static const SaveLoad _game_script[] = { SLEG_SSTR(_game_saveload_settings, SLE_STR), SLEG_VAR(_game_saveload_version, SLE_UINT32), SLEG_VAR(_game_saveload_is_random, SLE_BOOL), - SLE_END() }; static void SaveReal_GSDT(int *index_ptr) @@ -117,12 +116,10 @@ static uint _game_saveload_strings; static const SaveLoad _game_language_header[] = { SLEG_SSTR(_game_saveload_string, SLE_STR), SLEG_VAR(_game_saveload_strings, SLE_UINT32), - SLE_END() }; static const SaveLoad _game_language_string[] = { SLEG_SSTR(_game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL), - SLE_END() }; static void SaveReal_GSTR(const LanguageStrings *ls) diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp index d68297c9a..3d236b136 100644 --- a/src/saveload/gamelog_sl.cpp +++ b/src/saveload/gamelog_sl.cpp @@ -17,13 +17,11 @@ static const SaveLoad _glog_action_desc[] = { SLE_VAR(LoggedAction, tick, SLE_UINT16), - SLE_END() }; static const SaveLoad _glog_mode_desc[] = { SLE_VAR(LoggedChange, mode.mode, SLE_UINT8), SLE_VAR(LoggedChange, mode.landscape, SLE_UINT8), - SLE_END() }; static const SaveLoad _glog_revision_desc[] = { @@ -31,62 +29,53 @@ static const SaveLoad _glog_revision_desc[] = { SLE_VAR(LoggedChange, revision.newgrf, SLE_UINT32), SLE_VAR(LoggedChange, revision.slver, SLE_UINT16), SLE_VAR(LoggedChange, revision.modified, SLE_UINT8), - SLE_END() }; static const SaveLoad _glog_oldver_desc[] = { SLE_VAR(LoggedChange, oldver.type, SLE_UINT32), SLE_VAR(LoggedChange, oldver.version, SLE_UINT32), - SLE_END() }; static const SaveLoad _glog_setting_desc[] = { SLE_STR(LoggedChange, setting.name, SLE_STR, 128), SLE_VAR(LoggedChange, setting.oldval, SLE_INT32), SLE_VAR(LoggedChange, setting.newval, SLE_INT32), - SLE_END() }; static const SaveLoad _glog_grfadd_desc[] = { SLE_VAR(LoggedChange, grfadd.grfid, SLE_UINT32 ), SLE_ARR(LoggedChange, grfadd.md5sum, SLE_UINT8, 16), - SLE_END() }; static const SaveLoad _glog_grfrem_desc[] = { SLE_VAR(LoggedChange, grfrem.grfid, SLE_UINT32), - SLE_END() }; static const SaveLoad _glog_grfcompat_desc[] = { SLE_VAR(LoggedChange, grfcompat.grfid, SLE_UINT32 ), SLE_ARR(LoggedChange, grfcompat.md5sum, SLE_UINT8, 16), - SLE_END() }; static const SaveLoad _glog_grfparam_desc[] = { SLE_VAR(LoggedChange, grfparam.grfid, SLE_UINT32), - SLE_END() }; static const SaveLoad _glog_grfmove_desc[] = { SLE_VAR(LoggedChange, grfmove.grfid, SLE_UINT32), SLE_VAR(LoggedChange, grfmove.offset, SLE_INT32), - SLE_END() }; static const SaveLoad _glog_grfbug_desc[] = { SLE_VAR(LoggedChange, grfbug.data, SLE_UINT64), SLE_VAR(LoggedChange, grfbug.grfid, SLE_UINT32), SLE_VAR(LoggedChange, grfbug.bug, SLE_UINT8), - SLE_END() }; static const SaveLoad _glog_emergency_desc[] = { - SLE_END() + SLE_CONDNULL(0, SL_MIN_VERSION, SL_MIN_VERSION), // Just an empty list, to keep the rest of the code easier. }; -static const SaveLoad * const _glog_desc[] = { +static const SaveLoadTable _glog_desc[] = { _glog_mode_desc, _glog_revision_desc, _glog_oldver_desc, diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp index 4ee9f39eb..2c9d8fde9 100644 --- a/src/saveload/goal_sl.cpp +++ b/src/saveload/goal_sl.cpp @@ -21,7 +21,6 @@ static const SaveLoad _goals_desc[] = { SLE_STR(Goal, text, SLE_STR | SLF_ALLOW_CONTROL, 0), SLE_CONDSTR(Goal, progress, SLE_STR | SLF_ALLOW_CONTROL, 0, SLV_182, SL_MAX_VERSION), SLE_CONDVAR(Goal, completed, SLE_BOOL, SLV_182, SL_MAX_VERSION), - SLE_END() }; static void Save_GOAL() diff --git a/src/saveload/group_sl.cpp b/src/saveload/group_sl.cpp index c5f7e2b50..a6ae263f9 100644 --- a/src/saveload/group_sl.cpp +++ b/src/saveload/group_sl.cpp @@ -26,7 +26,6 @@ static const SaveLoad _group_desc[] = { SLE_CONDVAR(Group, livery.colour1, SLE_UINT8, SLV_GROUP_LIVERIES, SL_MAX_VERSION), SLE_CONDVAR(Group, livery.colour2, SLE_UINT8, SLV_GROUP_LIVERIES, SL_MAX_VERSION), SLE_CONDVAR(Group, parent, SLE_UINT16, SLV_189, SL_MAX_VERSION), - SLE_END() }; static void Save_GRPS() diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 6f41e3455..a59524de6 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -75,8 +75,6 @@ static const SaveLoad _industry_desc[] = { SLE_CONDSSTR(Industry, text, SLE_STR | SLF_ALLOW_CONTROL, SLV_INDUSTRY_TEXT, SL_MAX_VERSION), SLE_CONDNULL(32, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static void Save_INDY() @@ -139,7 +137,6 @@ static void Ptrs_INDY() /** Description of the data to save and load in #IndustryBuildData. */ static const SaveLoad _industry_builder_desc[] = { SLEG_VAR(_industry_builder.wanted_inds, SLE_UINT32), - SLEG_END() }; /** Load/save industry builder. */ @@ -155,7 +152,6 @@ static const SaveLoad _industrytype_builder_desc[] = { SLE_VAR(IndustryTypeBuildData, target_count, SLE_UINT16), SLE_VAR(IndustryTypeBuildData, max_wait, SLE_UINT16), SLE_VAR(IndustryTypeBuildData, wait_count, SLE_UINT16), - SLE_END() }; /** Save industry-type build data. */ diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp index 542b85b9f..6c2cd1bca 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -95,7 +95,6 @@ struct LabelObject { static const SaveLoad _label_object_desc[] = { SLE_VAR(LabelObject, label, SLE_UINT32), - SLE_END(), }; static void Save_RAIL() diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index 7d4fe5671..398300028 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -26,13 +26,12 @@ static uint16 _num_nodes; * Get a SaveLoad array for a link graph. * @return SaveLoad array for link graph. */ -const SaveLoad *GetLinkGraphDesc() +SaveLoadTable GetLinkGraphDesc() { static const SaveLoad link_graph_desc[] = { SLE_VAR(LinkGraph, last_compression, SLE_INT32), SLEG_VAR(_num_nodes, SLE_UINT16), SLE_VAR(LinkGraph, cargo, SLE_UINT8), - SLE_END() }; return link_graph_desc; } @@ -46,7 +45,7 @@ const SaveLoad *GetLinkGraphDesc() * Of course the settings have to be saved and loaded, too, to avoid desyncs. * @return Array of SaveLoad structs. */ -const SaveLoad *GetLinkGraphJobDesc() +SaveLoadTable GetLinkGraphJobDesc() { static std::vector<SaveLoad> saveloads; static const char *prefix = "linkgraph."; @@ -54,7 +53,6 @@ const SaveLoad *GetLinkGraphJobDesc() static const SaveLoad job_desc[] = { SLE_VAR(LinkGraphJob, join_date, SLE_INT32), SLE_VAR(LinkGraphJob, link_graph.index, SLE_UINT16), - SLE_END() }; /* The member offset arithmetic below is only valid if the types in question @@ -74,25 +72,23 @@ const SaveLoad *GetLinkGraphJobDesc() sl.address_proc = proc; } - int i = 0; - do { - saveloads.push_back(job_desc[i++]); - } while (saveloads.back().cmd != SL_END); + for (auto &sld : job_desc) { + saveloads.push_back(sld); + } } - return &saveloads[0]; + return saveloads; } /** * Get a SaveLoad array for the link graph schedule. * @return SaveLoad array for the link graph schedule. */ -const SaveLoad *GetLinkGraphScheduleDesc() +SaveLoadTable GetLinkGraphScheduleDesc() { static const SaveLoad schedule_desc[] = { SLE_LST(LinkGraphSchedule, schedule, REF_LINK_GRAPH), SLE_LST(LinkGraphSchedule, running, REF_LINK_GRAPH_JOB), - SLE_END() }; return schedule_desc; } @@ -108,7 +104,6 @@ static const SaveLoad _node_desc[] = { SLE_VAR(Node, demand, SLE_UINT32), SLE_VAR(Node, station, SLE_UINT16), SLE_VAR(Node, last_update, SLE_INT32), - SLE_END() }; /** @@ -121,7 +116,6 @@ static const SaveLoad _edge_desc[] = { SLE_VAR(Edge, last_unrestricted_update, SLE_INT32), SLE_CONDVAR(Edge, last_restricted_update, SLE_INT32, SLV_187, SL_MAX_VERSION), SLE_VAR(Edge, next_edge, SLE_UINT16), - SLE_END() }; /** diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index 51c56684a..d08fc6389 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -20,10 +20,9 @@ static uint32 _map_dim_x; static uint32 _map_dim_y; -static const SaveLoadGlobVarList _map_dimensions[] = { +static const SaveLoad _map_dimensions[] = { SLEG_CONDVAR(_map_dim_x, SLE_UINT32, SLV_6, SL_MAX_VERSION), SLEG_CONDVAR(_map_dim_y, SLE_UINT32, SLV_6, SL_MAX_VERSION), - SLEG_END() }; static void Save_MAPS() diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index 0d760c9d5..ba49c11be 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -68,7 +68,7 @@ void ResetViewportAfterLoadGame() byte _age_cargo_skip_counter; ///< Skip aging of cargo? Used before savegame version 162. -static const SaveLoadGlobVarList _date_desc[] = { +static const SaveLoad _date_desc[] = { SLEG_CONDVAR(_date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31), SLEG_CONDVAR(_date, SLE_INT32, SLV_31, SL_MAX_VERSION), SLEG_VAR(_date_fract, SLE_UINT16), @@ -90,10 +90,9 @@ static const SaveLoadGlobVarList _date_desc[] = { SLEG_VAR(_trees_tick_ctr, SLE_UINT8), SLEG_CONDVAR(_pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION), SLE_CONDNULL(4, SLV_11, SLV_120), - SLEG_END() }; -static const SaveLoadGlobVarList _date_check_desc[] = { +static const SaveLoad _date_check_desc[] = { SLEG_CONDVAR(_load_check_data.current_date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31), SLEG_CONDVAR(_load_check_data.current_date, SLE_INT32, SLV_31, SL_MAX_VERSION), SLE_NULL(2), // _date_fract @@ -115,7 +114,6 @@ static const SaveLoadGlobVarList _date_check_desc[] = { SLE_NULL(1), // _trees_tick_ctr SLE_CONDNULL(1, SLV_4, SL_MAX_VERSION), // _pause_mode SLE_CONDNULL(4, SLV_11, SLV_120), - SLEG_END() }; /* Save load date related variables as well as persistent tick counters @@ -134,13 +132,12 @@ static void Check_DATE() } -static const SaveLoadGlobVarList _view_desc[] = { +static const SaveLoad _view_desc[] = { SLEG_CONDVAR(_saved_scrollpos_x, SLE_FILE_I16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_6), SLEG_CONDVAR(_saved_scrollpos_x, SLE_INT32, SLV_6, SL_MAX_VERSION), SLEG_CONDVAR(_saved_scrollpos_y, SLE_FILE_I16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_6), SLEG_CONDVAR(_saved_scrollpos_y, SLE_INT32, SLV_6, SL_MAX_VERSION), SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8), - SLEG_END() }; static void SaveLoad_VIEW() diff --git a/src/saveload/newgrf_sl.cpp b/src/saveload/newgrf_sl.cpp index 2e9f1ccaf..3faf9a64a 100644 --- a/src/saveload/newgrf_sl.cpp +++ b/src/saveload/newgrf_sl.cpp @@ -20,7 +20,6 @@ static const SaveLoad _newgrf_mapping_desc[] = { SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8), SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8), - SLE_END() }; /** @@ -65,7 +64,6 @@ static const SaveLoad _grfconfig_desc[] = { SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80), SLE_VAR(GRFConfig, num_params, SLE_UINT8), SLE_CONDVAR(GRFConfig, palette, SLE_UINT8, SLV_101, SL_MAX_VERSION), - SLE_END() }; diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp index 2c385b655..40ca8cd11 100644 --- a/src/saveload/object_sl.cpp +++ b/src/saveload/object_sl.cpp @@ -25,8 +25,6 @@ static const SaveLoad _object_desc[] = { SLE_CONDVAR(Object, colour, SLE_UINT8, SLV_148, SL_MAX_VERSION), SLE_CONDVAR(Object, view, SLE_UINT8, SLV_155, SL_MAX_VERSION), SLE_CONDVAR(Object, type, SLE_UINT16, SLV_186, SL_MAX_VERSION), - - SLE_END() }; static void Save_OBJS() diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 1292c1b05..44080e695 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -99,7 +99,7 @@ Order UnpackOldOrder(uint16 packed) return order; } -const SaveLoad *GetOrderDescription() +SaveLoadTable GetOrderDescription() { static const SaveLoad _order_desc[] = { SLE_VAR(Order, type, SLE_UINT8), @@ -115,7 +115,6 @@ const SaveLoad *GetOrderDescription() /* Leftover from the minor savegame version stuff * We will never use those free bytes, but we have to keep this line to allow loading of old savegames */ SLE_CONDNULL(10, SLV_5, SLV_36), - SLE_END() }; return _order_desc; @@ -196,11 +195,10 @@ static void Ptrs_ORDR() } } -const SaveLoad *GetOrderListDescription() +SaveLoadTable GetOrderListDescription() { static const SaveLoad _orderlist_desc[] = { SLE_REF(OrderList, first, REF_ORDER), - SLE_END() }; return _orderlist_desc; @@ -233,7 +231,7 @@ static void Ptrs_ORDL() } } -const SaveLoad *GetOrderBackupDescription() +SaveLoadTable GetOrderBackupDescription() { static const SaveLoad _order_backup_desc[] = { SLE_VAR(OrderBackup, user, SLE_UINT32), @@ -252,7 +250,6 @@ const SaveLoad *GetOrderBackupDescription() SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_FILE_U8 | SLE_VAR_U16, SLV_176, SLV_180), SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT16, SLV_180, SL_MAX_VERSION), SLE_REF(OrderBackup, orders, REF_ORDER), - SLE_END() }; return _order_backup_desc; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 9a9ed7cc5..f056404b5 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1400,10 +1400,10 @@ static void SlDeque(void *deque, VarType conv) /** Are we going to save this object or not? */ -static inline bool SlIsObjectValidInSavegame(const SaveLoad *sld) +static inline bool SlIsObjectValidInSavegame(const SaveLoad &sld) { - if (_sl_version < sld->version_from || _sl_version >= sld->version_to) return false; - if (sld->conv & SLF_NOT_IN_SAVE) return false; + if (_sl_version < sld.version_from || _sl_version >= sld.version_to) return false; + if (sld.conv & SLF_NOT_IN_SAVE) return false; return true; } @@ -1413,10 +1413,10 @@ static inline bool SlIsObjectValidInSavegame(const SaveLoad *sld) * @note If the variable is skipped it is skipped in the savegame * bytestream itself as well, so there is no need to skip it somewhere else */ -static inline bool SlSkipVariableOnLoad(const SaveLoad *sld) +static inline bool SlSkipVariableOnLoad(const SaveLoad &sld) { - if ((sld->conv & SLF_NO_NETWORK_SYNC) && _sl.action != SLA_SAVE && _networking && !_network_server) { - SlSkipBytes(SlCalcConvMemLen(sld->conv) * sld->length); + if ((sld.conv & SLF_NO_NETWORK_SYNC) && _sl.action != SLA_SAVE && _networking && !_network_server) { + SlSkipBytes(SlCalcConvMemLen(sld.conv) * sld.length); return true; } @@ -1425,26 +1425,26 @@ static inline bool SlSkipVariableOnLoad(const SaveLoad *sld) /** * Calculate the size of an object. - * @param object to be measured - * @param sld The SaveLoad description of the object so we know how to manipulate it - * @return size of given object + * @param object to be measured. + * @param slt The SaveLoad table with objects to save/load. + * @return size of given object. */ -size_t SlCalcObjLength(const void *object, const SaveLoad *sld) +size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt) { size_t length = 0; /* Need to determine the length and write a length tag. */ - for (; sld->cmd != SL_END; sld++) { + for (auto &sld : slt) { length += SlCalcObjMemberLength(object, sld); } return length; } -size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld) +size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld) { assert(_sl.action == SLA_SAVE); - switch (sld->cmd) { + switch (sld.cmd) { case SL_VAR: case SL_REF: case SL_ARR: @@ -1455,13 +1455,13 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld) /* CONDITIONAL saveload types depend on the savegame version */ if (!SlIsObjectValidInSavegame(sld)) break; - switch (sld->cmd) { - case SL_VAR: return SlCalcConvFileLen(sld->conv); + switch (sld.cmd) { + case SL_VAR: return SlCalcConvFileLen(sld.conv); case SL_REF: return SlCalcRefLen(); - case SL_ARR: return SlCalcArrayLen(sld->length, sld->conv); - case SL_STR: return SlCalcStringLen(GetVariableAddress(object, sld), sld->length, sld->conv); + case SL_ARR: return SlCalcArrayLen(sld.length, sld.conv); + case SL_STR: return SlCalcStringLen(GetVariableAddress(object, sld), sld.length, sld.conv); case SL_LST: return SlCalcListLen(GetVariableAddress(object, sld)); - case SL_DEQUE: return SlCalcDequeLen(GetVariableAddress(object, sld), sld->conv); + case SL_DEQUE: return SlCalcDequeLen(GetVariableAddress(object, sld), sld.conv); case SL_STDSTR: return SlCalcStdStringLen(GetVariableAddress(object, sld)); default: NOT_REACHED(); } @@ -1481,41 +1481,41 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld) * matches with the actual variable size. * @param sld The saveload configuration to test. */ -static bool IsVariableSizeRight(const SaveLoad *sld) +static bool IsVariableSizeRight(const SaveLoad &sld) { - switch (sld->cmd) { + switch (sld.cmd) { case SL_VAR: - switch (GetVarMemType(sld->conv)) { + switch (GetVarMemType(sld.conv)) { case SLE_VAR_BL: - return sld->size == sizeof(bool); + return sld.size == sizeof(bool); case SLE_VAR_I8: case SLE_VAR_U8: - return sld->size == sizeof(int8); + return sld.size == sizeof(int8); case SLE_VAR_I16: case SLE_VAR_U16: - return sld->size == sizeof(int16); + return sld.size == sizeof(int16); case SLE_VAR_I32: case SLE_VAR_U32: - return sld->size == sizeof(int32); + return sld.size == sizeof(int32); case SLE_VAR_I64: case SLE_VAR_U64: - return sld->size == sizeof(int64); + return sld.size == sizeof(int64); case SLE_VAR_NAME: - return sld->size == sizeof(std::string); + return sld.size == sizeof(std::string); default: - return sld->size == sizeof(void *); + return sld.size == sizeof(void *); } case SL_REF: /* These should all be pointer sized. */ - return sld->size == sizeof(void *); + return sld.size == sizeof(void *); case SL_STR: /* These should be pointer sized, or fixed array. */ - return sld->size == sizeof(void *) || sld->size == sld->length; + return sld.size == sizeof(void *) || sld.size == sld.length; case SL_STDSTR: /* These should be all pointers to std::string. */ - return sld->size == sizeof(std::string); + return sld.size == sizeof(std::string); default: return true; @@ -1524,14 +1524,14 @@ static bool IsVariableSizeRight(const SaveLoad *sld) #endif /* OTTD_ASSERT */ -bool SlObjectMember(void *ptr, const SaveLoad *sld) +bool SlObjectMember(void *ptr, const SaveLoad &sld) { #ifdef OTTD_ASSERT assert(IsVariableSizeRight(sld)); #endif - VarType conv = GB(sld->conv, 0, 8); - switch (sld->cmd) { + VarType conv = GB(sld.conv, 0, 8); + switch (sld.cmd) { case SL_VAR: case SL_REF: case SL_ARR: @@ -1543,7 +1543,7 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld) if (!SlIsObjectValidInSavegame(sld)) return false; if (SlSkipVariableOnLoad(sld)) return false; - switch (sld->cmd) { + switch (sld.cmd) { case SL_VAR: SlSaveLoadConv(ptr, conv); break; case SL_REF: // Reference variable, translate switch (_sl.action) { @@ -1563,11 +1563,11 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld) default: NOT_REACHED(); } break; - case SL_ARR: SlArray(ptr, sld->length, conv); break; - case SL_STR: SlString(ptr, sld->length, sld->conv); break; + case SL_ARR: SlArray(ptr, sld.length, conv); break; + case SL_STR: SlString(ptr, sld.length, sld.conv); break; case SL_LST: SlList(ptr, (SLRefType)conv); break; case SL_DEQUE: SlDeque(ptr, conv); break; - case SL_STDSTR: SlStdString(ptr, sld->conv); break; + case SL_STDSTR: SlStdString(ptr, sld.conv); break; default: NOT_REACHED(); } break; @@ -1602,30 +1602,30 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld) /** * Main SaveLoad function. - * @param object The object that is being saved or loaded - * @param sld The SaveLoad description of the object so we know how to manipulate it + * @param object The object that is being saved or loaded. + * @param slt The SaveLoad table with objects to save/load. */ -void SlObject(void *object, const SaveLoad *sld) +void SlObject(void *object, const SaveLoadTable &slt) { /* Automatically calculate the length? */ if (_sl.need_length != NL_NONE) { - SlSetLength(SlCalcObjLength(object, sld)); + SlSetLength(SlCalcObjLength(object, slt)); if (_sl.need_length == NL_CALCLENGTH) return; } - for (; sld->cmd != SL_END; sld++) { + for (auto &sld : slt) { void *ptr = GetVariableAddress(object, sld); SlObjectMember(ptr, sld); } } /** - * Save or Load (a list of) global variables - * @param sldg The global variable that is being loaded or saved + * Save or Load (a list of) global variables. + * @param slt The SaveLoad table with objects to save/load. */ -void SlGlobList(const SaveLoadGlobVarList *sldg) +void SlGlobList(const SaveLoadTable &slt) { - SlObject(nullptr, (const SaveLoad*)sldg); + SlObject(nullptr, slt); } /** diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index d28b81692..1c763a93f 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -12,6 +12,7 @@ #include "../fileio_type.h" #include "../strings_type.h" +#include "../core/span_type.hpp" #include <string> /** SaveLoad versions @@ -506,7 +507,6 @@ enum SaveLoadType : byte { SL_WRITEBYTE = 8, SL_VEH_INCLUDE = 9, SL_ST_INCLUDE = 10, - SL_END = 15 }; typedef void *SaveLoadAddrProc(void *base, size_t extra); @@ -523,8 +523,8 @@ struct SaveLoad { size_t extra_data; ///< extra data for the callback proc }; -/** Same as #SaveLoad but global variables are used (for better readability); */ -typedef SaveLoad SaveLoadGlobVarList; +/** A table of SaveLoad entries. */ +using SaveLoadTable = span<const SaveLoad>; /** * Storage of simple variables, references (pointers), and arrays. @@ -681,9 +681,6 @@ typedef SaveLoad SaveLoadGlobVarList; #define SLE_VEH_INCLUDE() {SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0} #define SLE_ST_INCLUDE() {SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0} -/** End marker of a struct/class save or load. */ -#define SLE_END() {SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, 0, nullptr, 0} - /** * Storage of global simple variables, references (pointers), and arrays. * @param cmd Load/save type. @see SaveLoadType @@ -802,9 +799,6 @@ typedef SaveLoad SaveLoadGlobVarList; */ #define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, 0, nullptr, 0} -/** End marker of global variables save or load. */ -#define SLEG_END() {SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, 0, nullptr, 0} - /** * Checks whether the savegame is below \a major.\a minor. * @param major Major number of the version to check against. @@ -883,17 +877,17 @@ static inline bool IsNumericType(VarType conv) * everything else has a callback function that returns the address based * on the saveload data and the current object for non-globals. */ -static inline void *GetVariableAddress(const void *object, const SaveLoad *sld) +static inline void *GetVariableAddress(const void *object, const SaveLoad &sld) { /* Entry is a null-variable, mostly used to read old savegames etc. */ - if (GetVarMemType(sld->conv) == SLE_VAR_NULL) { - assert(sld->address_proc == nullptr); + if (GetVarMemType(sld.conv) == SLE_VAR_NULL) { + assert(sld.address_proc == nullptr); return nullptr; } /* Everything else should be a non-null pointer. */ - assert(sld->address_proc != nullptr); - return sld->address_proc(const_cast<void *>(object), sld->extra_data); + assert(sld.address_proc != nullptr); + return sld.address_proc(const_cast<void *>(object), sld.extra_data); } int64 ReadValue(const void *ptr, VarType conv); @@ -905,16 +899,16 @@ int SlIterateArray(); void SlAutolength(AutolengthProc *proc, void *arg); size_t SlGetFieldLength(); void SlSetLength(size_t length); -size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld); -size_t SlCalcObjLength(const void *object, const SaveLoad *sld); +size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld); +size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt); byte SlReadByte(); void SlWriteByte(byte b); -void SlGlobList(const SaveLoadGlobVarList *sldg); +void SlGlobList(const SaveLoadTable &slt); void SlArray(void *array, size_t length, VarType conv); -void SlObject(void *object, const SaveLoad *sld); -bool SlObjectMember(void *object, const SaveLoad *sld); +void SlObject(void *object, const SaveLoadTable &slt); +bool SlObjectMember(void *object, const SaveLoad &sld); void NORETURN SlError(StringID string, const char *extra_msg = nullptr); void NORETURN SlErrorCorrupt(const char *msg); void NORETURN SlErrorCorruptFmt(const char *format, ...) WARN_FORMAT(1, 2); diff --git a/src/saveload/saveload_internal.h b/src/saveload/saveload_internal.h index bca0e87cd..920be0417 100644 --- a/src/saveload/saveload_internal.h +++ b/src/saveload/saveload_internal.h @@ -23,7 +23,7 @@ void ResetOldNames(); void ResetOldWaypoints(); void MoveBuoysToWaypoints(); void MoveWaypointsToBaseStations(); -const SaveLoad *GetBaseStationDescription(); +SaveLoadTable GetBaseStationDescription(); void AfterLoadVehicles(bool part_of_load); void FixupTrainLengths(); diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp index 99e24435b..86a1468a5 100644 --- a/src/saveload/signs_sl.cpp +++ b/src/saveload/signs_sl.cpp @@ -26,7 +26,6 @@ static const SaveLoad _sign_desc[] = { SLE_CONDVAR(Sign, owner, SLE_UINT8, SLV_6, SL_MAX_VERSION), SLE_CONDVAR(Sign, z, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_164), SLE_CONDVAR(Sign, z, SLE_INT32, SLV_164, SL_MAX_VERSION), - SLE_END() }; /** Save all signs */ 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); diff --git a/src/saveload/storage_sl.cpp b/src/saveload/storage_sl.cpp index 7abe396f3..a01904e3a 100644 --- a/src/saveload/storage_sl.cpp +++ b/src/saveload/storage_sl.cpp @@ -18,7 +18,6 @@ static const SaveLoad _storage_desc[] = { SLE_CONDVAR(PersistentStorage, grfid, SLE_UINT32, SLV_6, SL_MAX_VERSION), SLE_CONDARR(PersistentStorage, storage, SLE_UINT32, 16, SLV_161, SLV_EXTEND_PERSISTENT_STORAGE), SLE_CONDARR(PersistentStorage, storage, SLE_UINT32, 256, SLV_EXTEND_PERSISTENT_STORAGE, SL_MAX_VERSION), - SLE_END() }; /** Load persistent storage data. */ diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp index dba2a064f..06083fb10 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -34,7 +34,6 @@ static const SaveLoad _story_page_elements_desc[] = { SLE_CONDVAR(StoryPageElement, type, SLE_UINT8, SLV_185, SL_MAX_VERSION), SLE_VAR(StoryPageElement, referenced_id, SLE_UINT32), SLE_STR(StoryPageElement, text, SLE_STR | SLF_ALLOW_CONTROL, 0), - SLE_END() }; static void Save_STORY_PAGE_ELEMENT() @@ -69,7 +68,6 @@ static const SaveLoad _story_pages_desc[] = { SLE_CONDVAR(StoryPage, company, SLE_FILE_U16 | SLE_VAR_U8, SL_MIN_VERSION, SLV_185), SLE_CONDVAR(StoryPage, company, SLE_UINT8, SLV_185, SL_MAX_VERSION), SLE_STR(StoryPage, title, SLE_STR | SLF_ALLOW_CONTROL, 0), - SLE_END() }; static void Save_STORY_PAGE() diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp index d0db78b61..dbd04c8ad 100644 --- a/src/saveload/subsidy_sl.cpp +++ b/src/saveload/subsidy_sl.cpp @@ -24,7 +24,6 @@ static const SaveLoad _subsidies_desc[] = { SLE_CONDVAR(Subsidy, src, SLE_UINT16, SLV_5, SL_MAX_VERSION), SLE_CONDVAR(Subsidy, dst, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_5), SLE_CONDVAR(Subsidy, dst, SLE_UINT16, SLV_5, SL_MAX_VERSION), - SLE_END() }; static void Save_SUBS() diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index 4e9e0afeb..3ba25f640 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -194,8 +194,6 @@ static const SaveLoad _town_desc[] = { SLE_CONDNULL(4, SLV_166, SLV_EXTEND_CARGOTYPES), ///< cargo_produced, no longer in use SLE_CONDNULL(8, SLV_EXTEND_CARGOTYPES, SLV_REMOVE_TOWN_CARGO_CACHE), ///< cargo_produced, no longer in use SLE_CONDNULL(30, SLV_2, SLV_REMOVE_TOWN_CARGO_CACHE), ///< old reserved space - - SLE_END() }; static const SaveLoad _town_supplied_desc[] = { @@ -203,8 +201,6 @@ static const SaveLoad _town_supplied_desc[] = { SLE_CONDVAR(TransportedCargoStat<uint32>, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION), SLE_CONDVAR(TransportedCargoStat<uint32>, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), SLE_CONDVAR(TransportedCargoStat<uint32>, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), - - SLE_END() }; static const SaveLoad _town_received_desc[] = { @@ -212,8 +208,6 @@ static const SaveLoad _town_received_desc[] = { SLE_CONDVAR(TransportedCargoStat<uint16>, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION), SLE_CONDVAR(TransportedCargoStat<uint16>, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), SLE_CONDVAR(TransportedCargoStat<uint16>, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), - - SLE_END() }; static void Save_HIDS() @@ -226,14 +220,13 @@ static void Load_HIDS() Load_NewGRFMapping(_house_mngr); } -const SaveLoad *GetTileMatrixDesc() +SaveLoadTable GetTileMatrixDesc() { /* Here due to private member vars. */ static const SaveLoad _tilematrix_desc[] = { SLE_VAR(AcceptanceMatrix, area.tile, SLE_UINT32), SLE_VAR(AcceptanceMatrix, area.w, SLE_UINT16), SLE_VAR(AcceptanceMatrix, area.h, SLE_UINT16), - SLE_END() }; return _tilematrix_desc; diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 131d31519..e637f03b2 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -578,7 +578,7 @@ static uint32 _cargo_loaded_at_xy; * @param vt the vehicle type. Can be VEH_END for the common vehicle description data * @return the saveload description */ -const SaveLoad *GetVehicleDescription(VehicleType vt) +SaveLoadTable GetVehicleDescription(VehicleType vt) { /** Save and load of vehicles */ static const SaveLoad _common_veh_desc[] = { @@ -712,11 +712,8 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(Vehicle, lateness_counter, SLE_INT32, SLV_67, SL_MAX_VERSION), SLE_CONDNULL(10, SLV_2, SLV_144), // old reserved space - - SLE_END() }; - static const SaveLoad _train_desc[] = { SLE_WRITEBYTE(Vehicle, type), SLE_VEH_INCLUDE(), @@ -734,8 +731,6 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDNULL(2, SLV_2, SLV_20), SLE_CONDVAR(Train, gv_flags, SLE_UINT16, SLV_139, SL_MAX_VERSION), SLE_CONDNULL(11, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _roadveh_desc[] = { @@ -756,8 +751,6 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDNULL(4, SLV_69, SLV_131), SLE_CONDNULL(2, SLV_6, SLV_131), SLE_CONDNULL(16, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _ship_desc[] = { @@ -768,8 +761,6 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(Ship, rotation, SLE_UINT8, SLV_SHIP_ROTATION, SL_MAX_VERSION), SLE_CONDNULL(16, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _aircraft_desc[] = { @@ -791,8 +782,6 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(Aircraft, flags, SLE_UINT8, SLV_167, SL_MAX_VERSION), SLE_CONDNULL(13, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _special_desc[] = { @@ -821,8 +810,6 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(Vehicle, spritenum, SLE_UINT8, SLV_2, SL_MAX_VERSION), SLE_CONDNULL(15, SLV_2, SLV_144), // old reserved space - - SLE_END() }; static const SaveLoad _disaster_desc[] = { @@ -862,12 +849,10 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(DisasterVehicle, flags, SLE_UINT8, SLV_194, SL_MAX_VERSION), SLE_CONDNULL(16, SLV_2, SLV_144), // old reserved space - - SLE_END() }; - static const SaveLoad * const _veh_descs[] = { + static const SaveLoadTable _veh_descs[] = { _train_desc, _roadveh_desc, _ship_desc, diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index 663c61f6a..9ad3da1f3 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -180,8 +180,6 @@ static const SaveLoad _old_waypoint_desc[] = { SLE_CONDVAR(OldWaypoint, localidx, SLE_UINT8, SLV_3, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, grfid, SLE_UINT32, SLV_17, SL_MAX_VERSION), SLE_CONDVAR(OldWaypoint, owner, SLE_UINT8, SLV_101, SL_MAX_VERSION), - - SLE_END() }; static void Load_WAYP() |