implement blocks data conversion
This commit is contained in:
@@ -56,11 +56,40 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
||||
indices, blocks_c, items_c, regionsVersion);
|
||||
report->blocks.setup(blocklist, content->blocks);
|
||||
report->items.setup(itemlist, content->items);
|
||||
|
||||
for (const auto& [name, map] : root["blocks-data"].asObject()) {
|
||||
data::StructLayout layout;
|
||||
layout.deserialize(map);
|
||||
auto def = content->blocks.find(name);
|
||||
if (def == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (def->dataStruct == nullptr) {
|
||||
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
||||
report->issues.push_back(issue);
|
||||
report->dataLoss.push_back(name+": discard data");
|
||||
continue;
|
||||
}
|
||||
auto incapatibility = layout.checkCompatibility(*def->dataStruct);
|
||||
if (!incapatibility.empty()) {
|
||||
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
||||
report->issues.push_back(issue);
|
||||
for (const auto& error : incapatibility) {
|
||||
report->dataLoss.push_back(
|
||||
"[" + name + "] field " + error.name + " - " +
|
||||
data::to_string(error.type)
|
||||
);
|
||||
}
|
||||
}
|
||||
report->blocksDataLayouts[name] = std::move(layout);
|
||||
}
|
||||
|
||||
report->buildIssues();
|
||||
|
||||
if (report->isUpgradeRequired() ||
|
||||
report->hasContentReorder() ||
|
||||
report->hasMissingContent()) {
|
||||
report->hasMissingContent() ||
|
||||
report->hasDataLoss()) {
|
||||
return report;
|
||||
} else {
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user