summaryrefslogtreecommitdiffstats
path: root/game/shared/world
diff options
context:
space:
mode:
Diffstat (limited to 'game/shared/world')
-rw-r--r--game/shared/world/dimension.cc6
-rw-r--r--game/shared/world/dimension.hh4
-rw-r--r--game/shared/world/item_registry.cc16
-rw-r--r--game/shared/world/item_registry.hh10
-rw-r--r--game/shared/world/voxel_registry.cc22
-rw-r--r--game/shared/world/voxel_registry.hh12
6 files changed, 35 insertions, 35 deletions
diff --git a/game/shared/world/dimension.cc b/game/shared/world/dimension.cc
index 3389917..2d193fc 100644
--- a/game/shared/world/dimension.cc
+++ b/game/shared/world/dimension.cc
@@ -7,7 +7,7 @@
#include "shared/coord.hh"
#include "shared/globals.hh"
-world::Dimension::Dimension(const char* name, float gravity)
+world::Dimension::Dimension(std::string_view name, float gravity)
{
m_name = name;
m_gravity = gravity;
@@ -21,9 +21,9 @@ world::Dimension::~Dimension(void)
chunks.clear();
}
-const char* world::Dimension::get_name(void) const
+std::string_view world::Dimension::get_name(void) const
{
- return m_name.c_str();
+ return m_name;
}
float world::Dimension::get_gravity(void) const
diff --git a/game/shared/world/dimension.hh b/game/shared/world/dimension.hh
index 5b06895..3a383ac 100644
--- a/game/shared/world/dimension.hh
+++ b/game/shared/world/dimension.hh
@@ -26,10 +26,10 @@ namespace world
{
class Dimension {
public:
- explicit Dimension(const char* name, float gravity);
+ explicit Dimension(std::string_view name, float gravity);
virtual ~Dimension(void);
- const char* get_name(void) const;
+ std::string_view get_name(void) const;
float get_gravity(void) const;
public:
diff --git a/game/shared/world/item_registry.cc b/game/shared/world/item_registry.cc
index 378f0f1..e0d30cc 100644
--- a/game/shared/world/item_registry.cc
+++ b/game/shared/world/item_registry.cc
@@ -10,7 +10,7 @@ std::unordered_map<std::string, world::ItemInfoBuilder> world::item_registry::bu
std::unordered_map<std::string, item_id> world::item_registry::names = {};
std::vector<std::shared_ptr<world::ItemInfo>> world::item_registry::items = {};
-world::ItemInfoBuilder::ItemInfoBuilder(const char* name)
+world::ItemInfoBuilder::ItemInfoBuilder(std::string_view name)
{
prototype.name = name;
prototype.texture = std::string();
@@ -18,7 +18,7 @@ world::ItemInfoBuilder::ItemInfoBuilder(const char* name)
prototype.cached_texture = nullptr;
}
-world::ItemInfoBuilder& world::ItemInfoBuilder::set_texture(const char* texture)
+world::ItemInfoBuilder& world::ItemInfoBuilder::set_texture(std::string_view texture)
{
prototype.texture = texture;
prototype.cached_texture = nullptr;
@@ -52,21 +52,21 @@ item_id world::ItemInfoBuilder::build(void) const
return static_cast<item_id>(world::item_registry::items.size());
}
-world::ItemInfoBuilder& world::item_registry::construct(const char* name)
+world::ItemInfoBuilder& world::item_registry::construct(std::string_view name)
{
- const auto it = world::item_registry::builders.find(name);
+ const auto it = world::item_registry::builders.find(std::string(name));
if(it != world::item_registry::builders.cend()) {
return it->second;
}
else {
- return world::item_registry::builders.emplace(name, ItemInfoBuilder(name)).first->second;
+ return world::item_registry::builders.emplace(std::string(name), ItemInfoBuilder(name)).first->second;
}
}
-world::ItemInfo* world::item_registry::find(const char* name)
+world::ItemInfo* world::item_registry::find(std::string_view name)
{
- const auto it = world::item_registry::names.find(name);
+ const auto it = world::item_registry::names.find(std::string(name));
if(it != world::item_registry::names.cend()) {
return world::item_registry::find(it->second);
@@ -93,7 +93,7 @@ void world::item_registry::purge(void)
world::item_registry::items.clear();
}
-std::uint64_t world::item_registry::calcualte_checksum(void)
+std::uint64_t world::item_registry::calculate_checksum(void)
{
std::uint64_t result = 0;
diff --git a/game/shared/world/item_registry.hh b/game/shared/world/item_registry.hh
index 7cf3bd8..7508f2a 100644
--- a/game/shared/world/item_registry.hh
+++ b/game/shared/world/item_registry.hh
@@ -26,11 +26,11 @@ namespace world
{
class ItemInfoBuilder final {
public:
- explicit ItemInfoBuilder(const char* name);
+ explicit ItemInfoBuilder(std::string_view name);
virtual ~ItemInfoBuilder(void) = default;
public:
- ItemInfoBuilder& set_texture(const char* texture);
+ ItemInfoBuilder& set_texture(std::string_view texture);
ItemInfoBuilder& set_place_voxel(voxel_id place_voxel);
public:
@@ -50,8 +50,8 @@ extern std::vector<std::shared_ptr<ItemInfo>> items;
namespace world::item_registry
{
-ItemInfoBuilder& construct(const char* name);
-ItemInfo* find(const char* name);
+ItemInfoBuilder& construct(std::string_view name);
+ItemInfo* find(std::string_view name);
ItemInfo* find(const item_id item);
} // namespace world::item_registry
@@ -62,7 +62,7 @@ void purge(void);
namespace world::item_registry
{
-std::uint64_t calcualte_checksum(void);
+std::uint64_t calculate_checksum(void);
} // namespace world::item_registry
#endif // SHARED_ITEM_REGISTRY_HH
diff --git a/game/shared/world/voxel_registry.cc b/game/shared/world/voxel_registry.cc
index 8deab30..46737d6 100644
--- a/game/shared/world/voxel_registry.cc
+++ b/game/shared/world/voxel_registry.cc
@@ -8,7 +8,7 @@ std::unordered_map<std::string, world::VoxelInfoBuilder> world::voxel_registry::
std::unordered_map<std::string, voxel_id> world::voxel_registry::names = {};
std::vector<std::shared_ptr<world::VoxelInfo>> world::voxel_registry::voxels = {};
-world::VoxelInfoBuilder::VoxelInfoBuilder(const char* name, voxel_type type, bool animated, bool blending)
+world::VoxelInfoBuilder::VoxelInfoBuilder(std::string_view name, voxel_type type, bool animated, bool blending)
{
prototype.name = name;
prototype.type = type;
@@ -45,16 +45,16 @@ world::VoxelInfoBuilder::VoxelInfoBuilder(const char* name, voxel_type type, boo
prototype.item_pick = NULL_ITEM_ID;
}
-world::VoxelInfoBuilder& world::VoxelInfoBuilder::add_texture_default(const char* texture)
+world::VoxelInfoBuilder& world::VoxelInfoBuilder::add_texture_default(std::string_view texture)
{
- default_texture.paths.push_back(texture);
+ default_texture.paths.push_back(std::string(texture));
return *this;
}
-world::VoxelInfoBuilder& world::VoxelInfoBuilder::add_texture(voxel_face face, const char* texture)
+world::VoxelInfoBuilder& world::VoxelInfoBuilder::add_texture(voxel_face face, std::string_view texture)
{
const auto index = static_cast<std::size_t>(face);
- prototype.textures[index].paths.push_back(texture);
+ prototype.textures[index].paths.push_back(std::string(texture));
return *this;
}
@@ -140,21 +140,21 @@ voxel_id world::VoxelInfoBuilder::build(void) const
return new_info->base_voxel;
}
-world::VoxelInfoBuilder& world::voxel_registry::construct(const char* name, voxel_type type, bool animated, bool blending)
+world::VoxelInfoBuilder& world::voxel_registry::construct(std::string_view name, voxel_type type, bool animated, bool blending)
{
- const auto it = world::voxel_registry::builders.find(name);
+ const auto it = world::voxel_registry::builders.find(std::string(name));
if(it != world::voxel_registry::builders.cend()) {
return it->second;
}
else {
- return world::voxel_registry::builders.emplace(name, VoxelInfoBuilder(name, type, animated, blending)).first->second;
+ return world::voxel_registry::builders.emplace(std::string(name), VoxelInfoBuilder(name, type, animated, blending)).first->second;
}
}
-world::VoxelInfo* world::voxel_registry::find(const char* name)
+world::VoxelInfo* world::voxel_registry::find(std::string_view name)
{
- const auto it = world::voxel_registry::names.find(name);
+ const auto it = world::voxel_registry::names.find(std::string(name));
if(it != world::voxel_registry::names.cend()) {
return world::voxel_registry::find(it->second);
@@ -181,7 +181,7 @@ void world::voxel_registry::purge(void)
world::voxel_registry::voxels.clear();
}
-std::uint64_t world::voxel_registry::calcualte_checksum(void)
+std::uint64_t world::voxel_registry::calculate_checksum(void)
{
std::uint64_t result = 0;
diff --git a/game/shared/world/voxel_registry.hh b/game/shared/world/voxel_registry.hh
index 653c56e..9a7e206 100644
--- a/game/shared/world/voxel_registry.hh
+++ b/game/shared/world/voxel_registry.hh
@@ -108,12 +108,12 @@ namespace world
{
class VoxelInfoBuilder final {
public:
- explicit VoxelInfoBuilder(const char* name, voxel_type type, bool animated, bool blending);
+ explicit VoxelInfoBuilder(std::string_view name, voxel_type type, bool animated, bool blending);
virtual ~VoxelInfoBuilder(void) = default;
public:
- VoxelInfoBuilder& add_texture_default(const char* texture);
- VoxelInfoBuilder& add_texture(voxel_face face, const char* texture);
+ VoxelInfoBuilder& add_texture_default(std::string_view texture);
+ VoxelInfoBuilder& add_texture(voxel_face face, std::string_view texture);
VoxelInfoBuilder& set_touch(voxel_touch type, const glm::fvec3& values);
VoxelInfoBuilder& set_surface(voxel_surface surface);
@@ -135,8 +135,8 @@ extern std::vector<std::shared_ptr<VoxelInfo>> voxels;
namespace world::voxel_registry
{
-VoxelInfoBuilder& construct(const char* name, voxel_type type, bool animated, bool blending);
-VoxelInfo* find(const char* name);
+VoxelInfoBuilder& construct(std::string_view name, voxel_type type, bool animated, bool blending);
+VoxelInfo* find(std::string_view name);
VoxelInfo* find(const voxel_id voxel);
} // namespace world::voxel_registry
@@ -147,7 +147,7 @@ void purge(void);
namespace world::voxel_registry
{
-std::uint64_t calcualte_checksum(void);
+std::uint64_t calculate_checksum(void);
} // namespace world::voxel_registry
#endif // SHARED_VOXEL_REGISTRY_HH