update ContentType naming

This commit is contained in:
MihailRis 2024-08-14 00:47:57 +03:00
parent 7da8e133a5
commit cae314bc36
7 changed files with 23 additions and 24 deletions

View File

@ -11,9 +11,8 @@ function generate_heightmap(x, y)
local bmap = Heightmap(W, H)
bmap:noise({x+3, y+6}, 0.1, 1, 3)
local map = Heightmap(W, H)
map:noise({x, y}, 0.06, 5, 0.2, umap, vmap)
map:noise({x, y}, 0.12, 6, 0.5, umap, vmap)
map:mul(bmap)

View File

@ -24,15 +24,15 @@ namespace rigging {
class SkeletonConfig;
}
constexpr const char* contenttype_name(contenttype type) {
constexpr const char* ContentType_name(ContentType type) {
switch (type) {
case contenttype::none:
case ContentType::NONE:
return "none";
case contenttype::block:
case ContentType::BLOCK:
return "block";
case contenttype::item:
case ContentType::ITEM:
return "item";
case contenttype::entity:
case ContentType::ENTITY:
return "entity";
default:
return "unknown";
@ -40,13 +40,13 @@ constexpr const char* contenttype_name(contenttype type) {
}
class namereuse_error : public std::runtime_error {
contenttype type;
ContentType type;
public:
namereuse_error(const std::string& msg, contenttype type)
namereuse_error(const std::string& msg, ContentType type)
: std::runtime_error(msg), type(type) {
}
inline contenttype getType() const {
inline ContentType getType() const {
return type;
}
};

View File

@ -12,8 +12,8 @@
template <class T>
class ContentUnitBuilder {
std::unordered_map<std::string, contenttype>& allNames;
contenttype type;
std::unordered_map<std::string, ContentType>& allNames;
ContentType type;
void checkIdentifier(const std::string& id) {
const auto& found = allNames.find(id);
@ -28,7 +28,7 @@ public:
std::vector<std::string> names;
ContentUnitBuilder(
std::unordered_map<std::string, contenttype>& allNames, contenttype type
std::unordered_map<std::string, ContentType>& allNames, ContentType type
)
: allNames(allNames), type(type) {
}
@ -54,11 +54,11 @@ class ContentBuilder {
UptrsMap<std::string, BlockMaterial> blockMaterials;
UptrsMap<std::string, rigging::SkeletonConfig> skeletons;
UptrsMap<std::string, ContentPackRuntime> packs;
std::unordered_map<std::string, contenttype> allNames;
std::unordered_map<std::string, ContentType> allNames;
public:
ContentUnitBuilder<Block> blocks {allNames, contenttype::block};
ContentUnitBuilder<ItemDef> items {allNames, contenttype::item};
ContentUnitBuilder<EntityDef> entities {allNames, contenttype::entity};
ContentUnitBuilder<Block> blocks {allNames, ContentType::BLOCK};
ContentUnitBuilder<ItemDef> items {allNames, ContentType::ITEM};
ContentUnitBuilder<EntityDef> entities {allNames, ContentType::ENTITY};
ResourceIndicesSet resourceIndices {};
~ContentBuilder();

View File

@ -14,8 +14,8 @@
ContentLUT::ContentLUT(
const ContentIndices* indices, size_t blocksCount, size_t itemsCount
)
: blocks(blocksCount, indices->blocks, BLOCK_VOID, contenttype::block),
items(itemsCount, indices->items, ITEM_VOID, contenttype::item) {
: blocks(blocksCount, indices->blocks, BLOCK_VOID, ContentType::BLOCK),
items(itemsCount, indices->items, ITEM_VOID, ContentType::ITEM) {
}
template <class T>

View File

@ -13,7 +13,7 @@
namespace fs = std::filesystem;
struct contententry {
contenttype type;
ContentType type;
std::string name;
};
@ -26,13 +26,13 @@ class ContentUnitLUT {
bool missingContent = false;
bool reorderContent = false;
T missingValue;
contenttype type;
ContentType type;
public:
ContentUnitLUT(
size_t count,
const ContentUnitIndices<U>& unitIndices,
T missingValue,
contenttype type
ContentType type
)
: missingValue(missingValue), type(type) {
for (size_t i = 0; i < count; i++) {

View File

@ -5,7 +5,7 @@
class Content;
class ContentPackRuntime;
enum class contenttype { none, block, item, entity };
enum class ContentType { NONE, BLOCK, ITEM, ENTITY };
enum class ResourceType : size_t { CAMERA, LAST = CAMERA };

View File

@ -92,7 +92,7 @@ static void show_content_missing(
auto root = create_map();
auto& contentEntries = root->putList("content");
for (auto& entry : lut->getMissingContent()) {
std::string contentName = contenttype_name(entry.type);
std::string contentName = ContentType_name(entry.type);
auto& contentEntry = contentEntries.putMap();
contentEntry.put("type", contentName);
contentEntry.put("name", entry.name);