diff options
| author | untodesu <kirill@untode.su> | 2025-06-25 00:44:36 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-06-25 00:44:36 +0500 |
| commit | 88c01588aa0830e219eaa62588839e4d1e2883ce (patch) | |
| tree | 602bb27dd3399aab4aae8c19630e3b7a8dac824b /game/shared/item_registry.cc | |
| parent | 99cf6cca8dbbc1e563c10cf0167432d3d8af9783 (diff) | |
| download | voxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.tar.bz2 voxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.zip | |
Clang-format the entire source code
Diffstat (limited to 'game/shared/item_registry.cc')
| -rw-r--r-- | game/shared/item_registry.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/game/shared/item_registry.cc b/game/shared/item_registry.cc index 23dffdc..1263201 100644 --- a/game/shared/item_registry.cc +++ b/game/shared/item_registry.cc @@ -1,4 +1,5 @@ #include "shared/pch.hh" + #include "shared/item_registry.hh" #include "core/crc64.hh" @@ -9,7 +10,7 @@ std::unordered_map<std::string, ItemInfoBuilder> item_registry::builders = {}; std::unordered_map<std::string, item_id> item_registry::names = {}; std::vector<std::shared_ptr<ItemInfo>> item_registry::items = {}; -ItemInfoBuilder::ItemInfoBuilder(const char *name) +ItemInfoBuilder::ItemInfoBuilder(const char* name) { prototype.name = name; prototype.texture = std::string(); @@ -17,14 +18,14 @@ ItemInfoBuilder::ItemInfoBuilder(const char *name) prototype.cached_texture = nullptr; } -ItemInfoBuilder &ItemInfoBuilder::set_texture(const char *texture) +ItemInfoBuilder& ItemInfoBuilder::set_texture(const char* texture) { prototype.texture = texture; prototype.cached_texture = nullptr; return *this; } -ItemInfoBuilder &ItemInfoBuilder::set_place_voxel(voxel_id place_voxel) +ItemInfoBuilder& ItemInfoBuilder::set_place_voxel(voxel_id place_voxel) { prototype.place_voxel = place_voxel; return *this; @@ -51,27 +52,35 @@ item_id ItemInfoBuilder::build(void) const return static_cast<item_id>(item_registry::items.size()); } -ItemInfoBuilder &item_registry::construct(const char *name) +ItemInfoBuilder& item_registry::construct(const char* name) { const auto it = item_registry::builders.find(name); - if(it != item_registry::builders.cend()) + + if(it != item_registry::builders.cend()) { return it->second; - return item_registry::builders.emplace(name, ItemInfoBuilder(name)).first->second; + } else { + return item_registry::builders.emplace(name, ItemInfoBuilder(name)).first->second; + } } -ItemInfo *item_registry::find(const char *name) +ItemInfo* item_registry::find(const char* name) { const auto it = item_registry::names.find(name); - if(it != item_registry::names.cend()) + + if(it != item_registry::names.cend()) { return item_registry::find(it->second); - return nullptr; + } else { + return nullptr; + } } -ItemInfo *item_registry::find(const item_id item) +ItemInfo* item_registry::find(const item_id item) { - if((item != NULL_ITEM_ID) && (item <= item_registry::items.size())) + if((item != NULL_ITEM_ID) && (item <= item_registry::items.size())) { return item_registry::items[item - 1].get(); - return nullptr; + } else { + return nullptr; + } } void item_registry::purge(void) @@ -85,7 +94,7 @@ std::uint64_t item_registry::calcualte_checksum(void) { std::uint64_t result = 0; - for(const auto &info : item_registry::items) { + for(const auto& info : item_registry::items) { result = crc64::get(info->name, result); result += static_cast<std::uint64_t>(info->place_voxel); } |
