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/voxel_registry.cc | |
| parent | 99cf6cca8dbbc1e563c10cf0167432d3d8af9783 (diff) | |
| download | voxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.tar.bz2 voxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.zip | |
Clang-format the entire source code
Diffstat (limited to 'game/shared/voxel_registry.cc')
| -rw-r--r-- | game/shared/voxel_registry.cc | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/game/shared/voxel_registry.cc b/game/shared/voxel_registry.cc index ce6ee7f..cb3c724 100644 --- a/game/shared/voxel_registry.cc +++ b/game/shared/voxel_registry.cc @@ -1,4 +1,5 @@ #include "shared/pch.hh" + #include "shared/voxel_registry.hh" #include "core/crc64.hh" @@ -7,7 +8,7 @@ std::unordered_map<std::string, VoxelInfoBuilder> voxel_registry::builders = {}; std::unordered_map<std::string, voxel_id> voxel_registry::names = {}; std::vector<std::shared_ptr<VoxelInfo>> voxel_registry::voxels = {}; -VoxelInfoBuilder::VoxelInfoBuilder(const char *name, voxel_type type, bool animated, bool blending) +VoxelInfoBuilder::VoxelInfoBuilder(const char* name, voxel_type type, bool animated, bool blending) { prototype.name = name; prototype.type = type; @@ -44,27 +45,27 @@ VoxelInfoBuilder::VoxelInfoBuilder(const char *name, voxel_type type, bool anima prototype.item_pick = NULL_ITEM_ID; } -VoxelInfoBuilder &VoxelInfoBuilder::add_texture_default(const char *texture) +VoxelInfoBuilder& VoxelInfoBuilder::add_texture_default(const char* texture) { default_texture.paths.push_back(texture); return *this; } -VoxelInfoBuilder &VoxelInfoBuilder::add_texture(voxel_face face, const char *texture) +VoxelInfoBuilder& VoxelInfoBuilder::add_texture(voxel_face face, const char* texture) { const auto index = static_cast<std::size_t>(face); prototype.textures[index].paths.push_back(texture); return *this; } -VoxelInfoBuilder &VoxelInfoBuilder::set_touch(voxel_touch type, const glm::fvec3 &values) +VoxelInfoBuilder& VoxelInfoBuilder::set_touch(voxel_touch type, const glm::fvec3& values) { prototype.touch_type = type; prototype.touch_values = values; return *this; } -VoxelInfoBuilder &VoxelInfoBuilder::set_surface(voxel_surface surface) +VoxelInfoBuilder& VoxelInfoBuilder::set_surface(voxel_surface surface) { prototype.surface = surface; return *this; @@ -113,8 +114,7 @@ voxel_id VoxelInfoBuilder::build(void) const new_info->textures[i].paths = default_texture.paths; new_info->textures[i].cached_offset = SIZE_MAX; new_info->textures[i].cached_plane = SIZE_MAX; - } - else { + } else { new_info->textures[i].paths = prototype.textures[i].paths; new_info->textures[i].cached_offset = SIZE_MAX; new_info->textures[i].cached_plane = SIZE_MAX; @@ -139,27 +139,35 @@ voxel_id VoxelInfoBuilder::build(void) const return new_info->base_voxel; } -VoxelInfoBuilder &voxel_registry::construct(const char *name, voxel_type type, bool animated, bool blending) +VoxelInfoBuilder& voxel_registry::construct(const char* name, voxel_type type, bool animated, bool blending) { const auto it = voxel_registry::builders.find(name); - if(it != voxel_registry::builders.cend()) + + if(it != voxel_registry::builders.cend()) { return it->second; - return voxel_registry::builders.emplace(name, VoxelInfoBuilder(name, type, animated, blending)).first->second; + } else { + return voxel_registry::builders.emplace(name, VoxelInfoBuilder(name, type, animated, blending)).first->second; + } } -VoxelInfo *voxel_registry::find(const char *name) +VoxelInfo* voxel_registry::find(const char* name) { const auto it = voxel_registry::names.find(name); - if(it != voxel_registry::names.cend()) + + if(it != voxel_registry::names.cend()) { return voxel_registry::find(it->second); - return nullptr; + } else { + return nullptr; + } } -VoxelInfo *voxel_registry::find(const voxel_id voxel) +VoxelInfo* voxel_registry::find(const voxel_id voxel) { - if((voxel != NULL_VOXEL_ID) && (voxel <= voxel_registry::voxels.size())) + if((voxel != NULL_VOXEL_ID) && (voxel <= voxel_registry::voxels.size())) { return voxel_registry::voxels[voxel - 1].get(); - return nullptr; + } else { + return nullptr; + } } void voxel_registry::purge(void) @@ -173,7 +181,7 @@ std::uint64_t voxel_registry::calcualte_checksum(void) { std::uint64_t result = 0; - for(const std::shared_ptr<VoxelInfo> &info : voxel_registry::voxels) { + for(const std::shared_ptr<VoxelInfo>& info : voxel_registry::voxels) { result = crc64::get(info->name, result); result += static_cast<std::uint64_t>(info->type); result += static_cast<std::uint64_t>(info->base_voxel); |
