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/server/whitelist.cc | |
| parent | 96bd73ae020ecca1f94698744c77498a89ad19f7 (diff) | |
| download | voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2 voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip | |
Replace most of C strings with string_view
Diffstat (limited to 'game/server/whitelist.cc')
| -rw-r--r-- | game/server/whitelist.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/game/server/whitelist.cc b/game/server/whitelist.cc index 8a858c6..4e53ee8 100644 --- a/game/server/whitelist.cc +++ b/game/server/whitelist.cc @@ -11,7 +11,7 @@ #include "server/game.hh" #include "server/globals.hh" -constexpr static const char* DEFAULT_FILENAME = "whitelist.txt"; +constexpr static std::string_view DEFAULT_FILENAME = "whitelist.txt"; constexpr static char SEPARATOR_CHAR = ':'; config::Boolean whitelist::enabled(false); @@ -36,12 +36,12 @@ void whitelist::init_late(void) return; } - if(utils::is_whitespace(whitelist::filename.get())) { + if(utils::is_whitespace(whitelist::filename.get_value())) { spdlog::warn("whitelist: enabled but filename is empty, using default ({})", DEFAULT_FILENAME); whitelist::filename.set(DEFAULT_FILENAME); } - PHYSFS_File* file = PHYSFS_openRead(whitelist::filename.get()); + PHYSFS_File* file = PHYSFS_openRead(whitelist::filename.c_str()); if(file == nullptr) { spdlog::warn("whitelist: {}: {}", whitelist::filename.get(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); @@ -80,14 +80,14 @@ void whitelist::shutdown(void) // UNDONE: implement saving } -bool whitelist::contains(const char* username) +bool whitelist::contains(std::string_view username) { - return whitelist_map.contains(username); + return whitelist_map.contains(std::string(username)); } -bool whitelist::matches(const char* username, std::uint64_t password_hash) +bool whitelist::matches(std::string_view username, std::uint64_t password_hash) { - const auto it = whitelist_map.find(username); + const auto it = whitelist_map.find(std::string(username)); if(it == whitelist_map.cend()) { // Not whitelisted, no match |
