summaryrefslogtreecommitdiff
path: root/src/saveload/subsidy_sl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload/subsidy_sl.cpp')
-rw-r--r--src/saveload/subsidy_sl.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/saveload/subsidy_sl.cpp b/src/saveload/subsidy_sl.cpp
index a02c19319..d4a882dad 100644
--- a/src/saveload/subsidy_sl.cpp
+++ b/src/saveload/subsidy_sl.cpp
@@ -29,28 +29,32 @@ static const SaveLoad _subsidies_desc[] = {
SLE_CONDVAR(Subsidy, dst, SLE_UINT16, SLV_5, SL_MAX_VERSION),
};
-static void Save_SUBS()
-{
- SlTableHeader(_subsidies_desc);
+struct SUBSChunkHandler : ChunkHandler {
+ SUBSChunkHandler() : ChunkHandler('SUBS', CH_TABLE) {}
- for (Subsidy *s : Subsidy::Iterate()) {
- SlSetArrayIndex(s->index);
- SlObject(s, _subsidies_desc);
+ void Save() const override
+ {
+ SlTableHeader(_subsidies_desc);
+
+ for (Subsidy *s : Subsidy::Iterate()) {
+ SlSetArrayIndex(s->index);
+ SlObject(s, _subsidies_desc);
+ }
}
-}
-static void Load_SUBS()
-{
- const std::vector<SaveLoad> slt = SlCompatTableHeader(_subsidies_desc, _subsidies_sl_compat);
+ void Load() const override
+ {
+ const std::vector<SaveLoad> slt = SlCompatTableHeader(_subsidies_desc, _subsidies_sl_compat);
- int index;
- while ((index = SlIterateArray()) != -1) {
- Subsidy *s = new (index) Subsidy();
- SlObject(s, slt);
+ int index;
+ while ((index = SlIterateArray()) != -1) {
+ Subsidy *s = new (index) Subsidy();
+ SlObject(s, slt);
+ }
}
-}
+};
-static const ChunkHandler SUBS{ 'SUBS', Save_SUBS, Load_SUBS, nullptr, nullptr, CH_TABLE };
+static const SUBSChunkHandler SUBS;
static const ChunkHandlerRef subsidy_chunk_handlers[] = {
SUBS,
};