summaryrefslogtreecommitdiffstats
path: root/game/shared/world/item_registry.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
committeruntodesu <kirill@untode.su>2025-09-11 13:48:31 +0500
commitaaed751bf4430bf4b9b30cef532b8753b9f639ce (patch)
tree16bc751c272ba27ad53ec48dbdd3a6d9e6a8d4c2 /game/shared/world/item_registry.cc
parent96bd73ae020ecca1f94698744c77498a89ad19f7 (diff)
downloadvoxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2
voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip
Replace most of C strings with string_view
Diffstat (limited to 'game/shared/world/item_registry.cc')
-rw-r--r--game/shared/world/item_registry.cc16
1 files changed, 8 insertions, 8 deletions
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;