Saveload: Add helper to filter named save load table

This commit is contained in:
Jonathan G Rennison 2024-07-15 18:56:56 +01:00
parent c7a4c6ba0e
commit 7bf1cf0865
2 changed files with 17 additions and 4 deletions

View File

@ -1990,6 +1990,21 @@ std::vector<SaveLoad> SlFilterObject(const SaveLoadTable &slt)
return save;
}
void SlFilterNamedSaveLoadTable(const NamedSaveLoadTable &nslt, std::vector<SaveLoad> &save)
{
for (auto &nsld : nslt) {
if ((nsld.nsl_flags & NSLF_TABLE_ONLY) != 0) continue;
SlFilterObjectMember(nsld.save_load, save);
}
}
std::vector<SaveLoad> SlFilterNamedSaveLoadTable(const NamedSaveLoadTable &nslt)
{
std::vector<SaveLoad> save;
SlFilterNamedSaveLoadTable(nslt, save);
return save;
}
template <SaveLoadAction action, bool check_version>
bool SlObjectMemberGeneric(void *object, const SaveLoad &sld)
{
@ -2449,10 +2464,7 @@ SaveLoadTableData SlTableHeaderOrRiff(const NamedSaveLoadTable &slt)
if (SlIsTableChunk()) return SlTableHeader(slt);
SaveLoadTableData saveloads;
for (auto &nsld : slt) {
if ((nsld.nsl_flags & NSLF_TABLE_ONLY) != 0) continue;
SlFilterObjectMember(nsld.save_load, saveloads);
}
SlFilterNamedSaveLoadTable(slt, saveloads);
return saveloads;
}

View File

@ -1080,6 +1080,7 @@ void SlObject(void *object, const SaveLoadTable &slt);
bool SlObjectMember(void *object, const SaveLoad &sld);
std::vector<SaveLoad> SlFilterObject(const SaveLoadTable &slt);
std::vector<SaveLoad> SlFilterNamedSaveLoadTable(const NamedSaveLoadTable &nslt);
void SlObjectSaveFiltered(void *object, const SaveLoadTable &slt);
void SlObjectLoadFiltered(void *object, const SaveLoadTable &slt);
void SlObjectPtrOrNullFiltered(void *object, const SaveLoadTable &slt);