From cae314bc36753cba99bd73b9e2068949bb583ba6 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 14 Aug 2024 00:47:57 +0300 Subject: [PATCH] update ContentType naming --- res/generators/default.lua | 3 +-- src/content/Content.hpp | 16 ++++++++-------- src/content/ContentBuilder.hpp | 14 +++++++------- src/content/ContentLUT.cpp | 4 ++-- src/content/ContentLUT.hpp | 6 +++--- src/content/content_fwd.hpp | 2 +- src/logic/EngineController.cpp | 2 +- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/res/generators/default.lua b/res/generators/default.lua index 65d7dcd2..defe9131 100644 --- a/res/generators/default.lua +++ b/res/generators/default.lua @@ -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) diff --git a/src/content/Content.hpp b/src/content/Content.hpp index 4178b7d8..9a802d43 100644 --- a/src/content/Content.hpp +++ b/src/content/Content.hpp @@ -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; } }; diff --git a/src/content/ContentBuilder.hpp b/src/content/ContentBuilder.hpp index 9207316c..cd652883 100644 --- a/src/content/ContentBuilder.hpp +++ b/src/content/ContentBuilder.hpp @@ -12,8 +12,8 @@ template class ContentUnitBuilder { - std::unordered_map& allNames; - contenttype type; + std::unordered_map& allNames; + ContentType type; void checkIdentifier(const std::string& id) { const auto& found = allNames.find(id); @@ -28,7 +28,7 @@ public: std::vector names; ContentUnitBuilder( - std::unordered_map& allNames, contenttype type + std::unordered_map& allNames, ContentType type ) : allNames(allNames), type(type) { } @@ -54,11 +54,11 @@ class ContentBuilder { UptrsMap blockMaterials; UptrsMap skeletons; UptrsMap packs; - std::unordered_map allNames; + std::unordered_map allNames; public: - ContentUnitBuilder blocks {allNames, contenttype::block}; - ContentUnitBuilder items {allNames, contenttype::item}; - ContentUnitBuilder entities {allNames, contenttype::entity}; + ContentUnitBuilder blocks {allNames, ContentType::BLOCK}; + ContentUnitBuilder items {allNames, ContentType::ITEM}; + ContentUnitBuilder entities {allNames, ContentType::ENTITY}; ResourceIndicesSet resourceIndices {}; ~ContentBuilder(); diff --git a/src/content/ContentLUT.cpp b/src/content/ContentLUT.cpp index 8e670152..0ee747bb 100644 --- a/src/content/ContentLUT.cpp +++ b/src/content/ContentLUT.cpp @@ -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 diff --git a/src/content/ContentLUT.hpp b/src/content/ContentLUT.hpp index f0b92c07..cdd4ad72 100644 --- a/src/content/ContentLUT.hpp +++ b/src/content/ContentLUT.hpp @@ -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& unitIndices, T missingValue, - contenttype type + ContentType type ) : missingValue(missingValue), type(type) { for (size_t i = 0; i < count; i++) { diff --git a/src/content/content_fwd.hpp b/src/content/content_fwd.hpp index 719fbfca..b1618593 100644 --- a/src/content/content_fwd.hpp +++ b/src/content/content_fwd.hpp @@ -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 }; diff --git a/src/logic/EngineController.cpp b/src/logic/EngineController.cpp index 7e0d59c3..6ce12ee8 100644 --- a/src/logic/EngineController.cpp +++ b/src/logic/EngineController.cpp @@ -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);