Saveload: Add helper for null/ptr named save load table handling

This commit is contained in:
Jonathan G Rennison 2024-07-15 18:21:08 +01:00
parent 38781fb16e
commit c7a4c6ba0e
2 changed files with 16 additions and 0 deletions

View File

@ -2456,6 +2456,21 @@ SaveLoadTableData SlTableHeaderOrRiff(const NamedSaveLoadTable &slt)
return saveloads;
}
SaveLoadTableData SlPrepareNamedSaveLoadTableForPtrOrNull(const NamedSaveLoadTable &slt)
{
SaveLoadTableData saveloads;
SlFilterNamedSaveLoadTable(slt, saveloads);
for (auto &sld : saveloads) {
if (sld.cmd == SL_STRUCTLIST || sld.cmd == SL_STRUCT) {
std::unique_ptr<SaveLoadStructHandler> handler = sld.struct_handler_factory();
sld.struct_handler = handler.get();
saveloads.struct_handlers.push_back(std::move(handler));
sld.struct_handler->table_data = SlPrepareNamedSaveLoadTableForPtrOrNull(sld.struct_handler->GetDescription());
}
}
return saveloads;
}
void SlSaveTableObjectChunk(const SaveLoadTable &slt)
{
SlSetArrayIndex(0);

View File

@ -1094,6 +1094,7 @@ bool SlIsTableChunk();
void SlSkipTableHeader();
SaveLoadTableData SlTableHeader(const NamedSaveLoadTable &slt, TableHeaderSpecialHandler *special_handler = nullptr);
SaveLoadTableData SlTableHeaderOrRiff(const NamedSaveLoadTable &slt);
SaveLoadTableData SlPrepareNamedSaveLoadTableForPtrOrNull(const NamedSaveLoadTable &slt);
void SlSaveTableObjectChunk(const SaveLoadTable &slt);
void SlLoadTableOrRiffFiltered(const SaveLoadTable &slt);
void SlLoadTableWithArrayLengthPrefixesMissing();