diff options
author | glx22 <glx@openttd.org> | 2021-06-07 23:24:37 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-07-06 22:29:08 +0200 |
commit | 2c941cd8b3cb1774f4982b86735e276597a91750 (patch) | |
tree | ae545cd8e0b66ece181fb5b5bc9ebe8db48c374a /src/saveload/goal_sl.cpp | |
parent | c1a9fe6fbd736c9e3a93314b0721d8f2cb8a2052 (diff) | |
download | openttd-2c941cd8b3cb1774f4982b86735e276597a91750.tar.xz |
Codechange: Use ChunkHandlers sub-classes
Diffstat (limited to 'src/saveload/goal_sl.cpp')
-rw-r--r-- | src/saveload/goal_sl.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/saveload/goal_sl.cpp b/src/saveload/goal_sl.cpp index 2dac477d0..ae6b8577b 100644 --- a/src/saveload/goal_sl.cpp +++ b/src/saveload/goal_sl.cpp @@ -25,28 +25,32 @@ static const SaveLoad _goals_desc[] = { SLE_CONDVAR(Goal, completed, SLE_BOOL, SLV_182, SL_MAX_VERSION), }; -static void Save_GOAL() -{ - SlTableHeader(_goals_desc); +struct GOALChunkHandler : ChunkHandler { + GOALChunkHandler() : ChunkHandler('GOAL', CH_TABLE) {} - for (Goal *s : Goal::Iterate()) { - SlSetArrayIndex(s->index); - SlObject(s, _goals_desc); + void Save() const override + { + SlTableHeader(_goals_desc); + + for (Goal *s : Goal::Iterate()) { + SlSetArrayIndex(s->index); + SlObject(s, _goals_desc); + } } -} -static void Load_GOAL() -{ - const std::vector<SaveLoad> slt = SlCompatTableHeader(_goals_desc, _goals_sl_compat); + void Load() const override + { + const std::vector<SaveLoad> slt = SlCompatTableHeader(_goals_desc, _goals_sl_compat); - int index; - while ((index = SlIterateArray()) != -1) { - Goal *s = new (index) Goal(); - SlObject(s, slt); + int index; + while ((index = SlIterateArray()) != -1) { + Goal *s = new (index) Goal(); + SlObject(s, slt); + } } -} +}; -static const ChunkHandler GOAL{ 'GOAL', Save_GOAL, Load_GOAL, nullptr, nullptr, CH_TABLE }; +static const GOALChunkHandler GOAL; static const ChunkHandlerRef goal_chunk_handlers[] = { GOAL, }; |