diff options
| author | untodesu <kirill@untode.su> | 2025-09-11 13:48:31 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-09-11 13:48:31 +0500 |
| commit | aaed751bf4430bf4b9b30cef532b8753b9f639ce (patch) | |
| tree | 16bc751c272ba27ad53ec48dbdd3a6d9e6a8d4c2 /game/client/resource | |
| parent | 96bd73ae020ecca1f94698744c77498a89ad19f7 (diff) | |
| download | voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2 voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip | |
Replace most of C strings with string_view
Diffstat (limited to 'game/client/resource')
| -rw-r--r-- | game/client/resource/sound_effect.cc | 8 | ||||
| -rw-r--r-- | game/client/resource/texture_gui.cc | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/game/client/resource/sound_effect.cc b/game/client/resource/sound_effect.cc index 0d987a5..75d5984 100644 --- a/game/client/resource/sound_effect.cc +++ b/game/client/resource/sound_effect.cc @@ -24,9 +24,9 @@ static drwav_bool32 drwav_seek_physfs(void* file, int offset, drwav_seek_origin } template<> -resource_ptr<SoundEffect> resource::load<SoundEffect>(const char* name, unsigned int flags) +resource_ptr<SoundEffect> resource::load<SoundEffect>(std::string_view name, unsigned int flags) { - auto it = resource_map.find(name); + auto it = resource_map.find(std::string(name)); if(it != resource_map.cend()) { // Return an existing resource @@ -38,7 +38,7 @@ resource_ptr<SoundEffect> resource::load<SoundEffect>(const char* name, unsigned return nullptr; } - auto file = PHYSFS_openRead(name); + auto file = PHYSFS_openRead(std::string(name).c_str()); if(file == nullptr) { spdlog::warn("resource: {} [SoundEffect]: {}", name, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); @@ -76,7 +76,7 @@ resource_ptr<SoundEffect> resource::load<SoundEffect>(const char* name, unsigned delete[] samples; - return resource_map.insert_or_assign(name, new_resource).first->second; + return resource_map.insert_or_assign(std::string(name), new_resource).first->second; } template<> diff --git a/game/client/resource/texture_gui.cc b/game/client/resource/texture_gui.cc index 971e201..415845d 100644 --- a/game/client/resource/texture_gui.cc +++ b/game/client/resource/texture_gui.cc @@ -8,9 +8,9 @@ static emhash8::HashMap<std::string, resource_ptr<TextureGUI>> resource_map; template<> -resource_ptr<TextureGUI> resource::load<TextureGUI>(const char* name, unsigned int flags) +resource_ptr<TextureGUI> resource::load<TextureGUI>(std::string_view name, unsigned int flags) { - auto it = resource_map.find(name); + auto it = resource_map.find(std::string(name)); if(it != resource_map.cend()) { // Return an existing resource @@ -67,7 +67,7 @@ resource_ptr<TextureGUI> resource::load<TextureGUI>(const char* name, unsigned i new_resource->size.x = image->size.x; new_resource->size.y = image->size.y; - return resource_map.insert_or_assign(name, new_resource).first->second; + return resource_map.insert_or_assign(std::string(name), new_resource).first->second; } return nullptr; |
