refactor
This commit is contained in:
@@ -19,6 +19,16 @@ enum class contenttype {
|
||||
none, block, item
|
||||
};
|
||||
|
||||
inline const char* contenttype_name(contenttype type) {
|
||||
switch (type) {
|
||||
case contenttype::none: return "none";
|
||||
case contenttype::block: return "block";
|
||||
case contenttype::item: return "item";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
class namereuse_error: public std::runtime_error {
|
||||
contenttype type;
|
||||
public:
|
||||
|
||||
@@ -80,3 +80,20 @@ ContentLUT* ContentLUT::create(const fs::path& filename,
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<contententry> ContentLUT::getMissingContent() const {
|
||||
std::vector<contententry> entries;
|
||||
for (size_t i = 0; i < blocks.size(); i++) {
|
||||
if (blocks[i] == BLOCK_VOID) {
|
||||
auto& name = blockNames[i];
|
||||
entries.push_back(contententry {contenttype::block, name});
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < items.size(); i++) {
|
||||
if (items[i] == ITEM_VOID) {
|
||||
auto& name = itemNames[i];
|
||||
entries.push_back(contententry {contenttype::item, name});
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,14 @@
|
||||
#include "../typedefs.h"
|
||||
#include "../constants.h"
|
||||
|
||||
#include "Content.h"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Content;
|
||||
struct contententry {
|
||||
contenttype type;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// TODO: make it unified for all types of content
|
||||
|
||||
@@ -84,6 +89,8 @@ public:
|
||||
inline size_t countItems() const {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
std::vector<contententry> getMissingContent() const;
|
||||
};
|
||||
|
||||
#endif // CONTENT_CONTENT_LUT_H_
|
||||
|
||||
Reference in New Issue
Block a user