Codechange: Use ChunkHandlers sub-classes

This commit is contained in:
glx22
2021-06-07 23:24:37 +02:00
committed by Loïc Guilloux
parent c1a9fe6fbd
commit 2c941cd8b3
35 changed files with 1953 additions and 1665 deletions

View File

@@ -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,
};