mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Saveload: Add SaveLoadStructHandler handler for table header load
This commit is contained in:
parent
b2c0a9c22e
commit
daf77f5ab1
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {};
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user