Saveload: Add SaveLoadStructHandler handler for table header load

This commit is contained in:
Jonathan G Rennison 2024-07-29 17:40:18 +01:00
parent b2c0a9c22e
commit daf77f5ab1
3 changed files with 14 additions and 5 deletions

View File

@ -337,11 +337,6 @@ struct DispatchNameStructHandler final : public TypedSaveLoadStructHandler<Dispa
void Load(DispatchSchedule *ds) const override
{
SaveLoadTable slt = this->GetLoadDescription();
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_0 || slt[1].label_tag != SLTAG_CUSTOM_1) {
SlErrorCorrupt("Dispatch names sub-chunk fields not as expected");
}
size_t string_count = SlGetStructListLength(UINT32_MAX);
btree::btree_map<uint32_t, std::string> &names = ds->GetSupplementaryNameMap();
for (size_t i = 0; i < string_count; i++) {
@ -349,6 +344,14 @@ struct DispatchNameStructHandler final : public TypedSaveLoadStructHandler<Dispa
SlStdString(&(names[key]), SLE_STR);
}
}
void LoadedTableDescription() override
{
SaveLoadTable slt = this->GetLoadDescription();
if (slt.size() != 2 || slt[0].label_tag != SLTAG_CUSTOM_0 || slt[1].label_tag != SLTAG_CUSTOM_1) {
SlErrorCorrupt("Dispatch names sub-chunk fields not as expected");
}
}
};
NamedSaveLoadTable GetDispatchScheduleDescription()

View File

@ -2412,6 +2412,7 @@ SaveLoadTableData SlTableHeader(const NamedSaveLoadTable &slt, TableHeaderSpecia
for (auto &sld : saveloads) {
if (sld.cmd == SL_STRUCTLIST || sld.cmd == SL_STRUCT) {
sld.struct_handler->table_data = SlTableHeader(sld.struct_handler->GetDescription());
sld.struct_handler->LoadedTableDescription();
}
}

View File

@ -259,6 +259,11 @@ public:
* @param object The object to fix.
*/
virtual void FixPointers([[maybe_unused]] void *object) const {}
/**
* Called immediately after table_data is populated during header load.
*/
virtual void LoadedTableDescription() {};
};