format ContentReport.cpp
This commit is contained in:
@@ -19,22 +19,19 @@ ContentReport::ContentReport(
|
|||||||
)
|
)
|
||||||
: blocks(blocksCount, indices->blocks, BLOCK_VOID, ContentType::BLOCK),
|
: blocks(blocksCount, indices->blocks, BLOCK_VOID, ContentType::BLOCK),
|
||||||
items(itemsCount, indices->items, ITEM_VOID, ContentType::ITEM),
|
items(itemsCount, indices->items, ITEM_VOID, ContentType::ITEM),
|
||||||
regionsVersion(regionsVersion)
|
regionsVersion(regionsVersion) {
|
||||||
{}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static constexpr size_t get_entries_count(
|
static constexpr size_t get_entries_count(
|
||||||
const ContentUnitIndices<T>& indices, const dv::value& list
|
const ContentUnitIndices<T>& indices, const dv::value& list
|
||||||
) {
|
) {
|
||||||
return list != nullptr
|
return list != nullptr ? std::max(list.size(), indices.count())
|
||||||
? std::max(list.size(), indices.count())
|
: indices.count();
|
||||||
: indices.count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_blocks_data(
|
static void process_blocks_data(
|
||||||
const Content* content,
|
const Content* content, ContentReport& report, const dv::value& root
|
||||||
ContentReport& report,
|
|
||||||
const dv::value& root
|
|
||||||
) {
|
) {
|
||||||
for (const auto& [name, map] : root.asObject()) {
|
for (const auto& [name, map] : root.asObject()) {
|
||||||
data::StructLayout layout;
|
data::StructLayout layout;
|
||||||
@@ -46,7 +43,7 @@ static void process_blocks_data(
|
|||||||
if (def->dataStruct == nullptr) {
|
if (def->dataStruct == nullptr) {
|
||||||
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
ContentIssue issue {ContentIssueType::BLOCK_DATA_LAYOUTS_UPDATE};
|
||||||
report.issues.push_back(issue);
|
report.issues.push_back(issue);
|
||||||
report.dataLoss.push_back(name+": discard data");
|
report.dataLoss.push_back(name + ": discard data");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto incapatibility = layout.checkCompatibility(*def->dataStruct);
|
auto incapatibility = layout.checkCompatibility(*def->dataStruct);
|
||||||
@@ -89,7 +86,8 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
|||||||
size_t items_c = get_entries_count(indices->items, itemlist);
|
size_t items_c = get_entries_count(indices->items, itemlist);
|
||||||
|
|
||||||
auto report = std::make_shared<ContentReport>(
|
auto report = std::make_shared<ContentReport>(
|
||||||
indices, blocks_c, items_c, regionsVersion);
|
indices, blocks_c, items_c, regionsVersion
|
||||||
|
);
|
||||||
report->blocks.setup(blocklist, content->blocks);
|
report->blocks.setup(blocklist, content->blocks);
|
||||||
report->items.setup(itemlist, content->items);
|
report->items.setup(itemlist, content->items);
|
||||||
|
|
||||||
@@ -99,20 +97,17 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
|||||||
|
|
||||||
report->buildIssues();
|
report->buildIssues();
|
||||||
|
|
||||||
if (report->isUpgradeRequired() ||
|
if (report->isUpgradeRequired() || report->hasContentReorder() ||
|
||||||
report->hasContentReorder() ||
|
report->hasMissingContent() || report->hasUpdatedLayouts()) {
|
||||||
report->hasMissingContent() ||
|
|
||||||
report->hasUpdatedLayouts()) {
|
|
||||||
return report;
|
return report;
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class U>
|
template <class T, class U>
|
||||||
static void build_issues(
|
static void build_issues(
|
||||||
std::vector<ContentIssue>& issues,
|
std::vector<ContentIssue>& issues, const ContentUnitLUT<T, U>& report
|
||||||
const ContentUnitLUT<T, U>& report
|
|
||||||
) {
|
) {
|
||||||
auto type = report.getContentType();
|
auto type = report.getContentType();
|
||||||
if (report.hasContentReorder()) {
|
if (report.hasContentReorder()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user