update WorldConverter (WIP)
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
ContentReport::ContentReport(
|
||||
const ContentIndices* indices,
|
||||
size_t blocksCount,
|
||||
size_t itemsCount
|
||||
size_t itemsCount,
|
||||
uint regionsVersion
|
||||
)
|
||||
: 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)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
@@ -38,6 +40,8 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
||||
}
|
||||
|
||||
auto root = files::read_json(filename);
|
||||
// TODO: remove default value 2 in 0.24
|
||||
uint regionsVersion = root->get("region-version", 2U);
|
||||
auto blocklist = root->list("blocks");
|
||||
auto itemlist = root->list("items");
|
||||
|
||||
@@ -45,7 +49,8 @@ std::shared_ptr<ContentReport> ContentReport::create(
|
||||
size_t blocks_c = get_entries_count(indices->blocks, blocklist);
|
||||
size_t items_c = get_entries_count(indices->items, itemlist);
|
||||
|
||||
auto report = std::make_shared<ContentReport>(indices, blocks_c, items_c);
|
||||
auto report = std::make_shared<ContentReport>(
|
||||
indices, blocks_c, items_c, regionsVersion);
|
||||
report->blocks.setup(blocklist.get(), content->blocks);
|
||||
report->items.setup(itemlist.get(), content->items);
|
||||
report->buildIssues();
|
||||
|
||||
@@ -9,17 +9,22 @@
|
||||
#include "data/dynamic.hpp"
|
||||
#include "typedefs.hpp"
|
||||
#include "Content.hpp"
|
||||
#include "files/world_regions_fwd.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
enum class ContentIssueType {
|
||||
REORDER,
|
||||
MISSING,
|
||||
REGION_FORMAT_UPDATE,
|
||||
};
|
||||
|
||||
struct ContentIssue {
|
||||
ContentIssueType issueType;
|
||||
ContentType contentType;
|
||||
union {
|
||||
ContentType contentType;
|
||||
RegionLayerIndex regionLayer;
|
||||
};
|
||||
};
|
||||
|
||||
struct ContentEntry {
|
||||
@@ -29,12 +34,16 @@ struct ContentEntry {
|
||||
|
||||
class WorldFiles;
|
||||
|
||||
/// @brief Content unit lookup table
|
||||
/// @tparam T index type
|
||||
/// @tparam U unit class
|
||||
template <typename T, class U>
|
||||
class ContentUnitLUT {
|
||||
std::vector<T> indices;
|
||||
std::vector<std::string> names;
|
||||
bool missingContent = false;
|
||||
bool reorderContent = false;
|
||||
/// @brief index that will be used to mark missing unit
|
||||
T missingValue;
|
||||
ContentType type;
|
||||
public:
|
||||
@@ -110,13 +119,15 @@ class ContentReport {
|
||||
public:
|
||||
ContentUnitLUT<blockid_t, Block> blocks;
|
||||
ContentUnitLUT<itemid_t, ItemDef> items;
|
||||
uint regionsVersion;
|
||||
|
||||
std::vector<ContentIssue> issues;
|
||||
|
||||
ContentReport(
|
||||
const ContentIndices* indices,
|
||||
size_t blocks,
|
||||
size_t items
|
||||
size_t items,
|
||||
uint regionsVersion
|
||||
);
|
||||
|
||||
static std::shared_ptr<ContentReport> create(
|
||||
@@ -131,6 +142,9 @@ public:
|
||||
inline bool hasMissingContent() const {
|
||||
return blocks.hasMissingContent() || items.hasMissingContent();
|
||||
}
|
||||
inline bool isUpgradeRequired() const {
|
||||
return regionsVersion < REGION_FORMAT_VERSION;
|
||||
}
|
||||
void buildIssues();
|
||||
|
||||
const std::vector<ContentIssue>& getIssues() const;
|
||||
|
||||
Reference in New Issue
Block a user