summaryrefslogtreecommitdiffstats
path: root/game/shared/splash.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/splash.cc
parent96bd73ae020ecca1f94698744c77498a89ad19f7 (diff)
downloadvoxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.tar.bz2
voxelius-aaed751bf4430bf4b9b30cef532b8753b9f639ce.zip
Replace most of C strings with string_view
Diffstat (limited to 'game/shared/splash.cc')
-rw-r--r--game/shared/splash.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/game/shared/splash.cc b/game/shared/splash.cc
index 1ff3e8f..d5b0a6e 100644
--- a/game/shared/splash.cc
+++ b/game/shared/splash.cc
@@ -2,8 +2,8 @@
#include "shared/splash.hh"
-constexpr static const char* SPLASHES_FILENAME_CLIENT = "misc/splashes_client.txt";
-constexpr static const char* SPLASHES_FILENAME_SERVER = "misc/splashes_server.txt";
+constexpr static std::string_view SPLASHES_FILENAME_CLIENT = "misc/splashes_client.txt";
+constexpr static std::string_view SPLASHES_FILENAME_SERVER = "misc/splashes_server.txt";
constexpr static std::size_t SPLASH_SERVER_MAX_LENGTH = 32;
static std::mt19937_64 splash_random;
@@ -22,9 +22,9 @@ static std::string sanitize_line(const std::string& line)
return result;
}
-static void splash_init_filename(const char* filename)
+static void splash_init_filename(std::string_view filename)
{
- if(auto file = PHYSFS_openRead(filename)) {
+ if(auto file = PHYSFS_openRead(std::string(filename).c_str())) {
auto source = std::string(PHYSFS_fileLength(file), char(0x00));
PHYSFS_readBytes(file, source.data(), source.size());
PHYSFS_close(file);
@@ -58,8 +58,8 @@ void splash::init_server(void)
}
}
-const char* splash::get(void)
+std::string_view splash::get(void)
{
std::uniform_int_distribution<std::size_t> dist(0, splash_lines.size() - 1);
- return splash_lines.at(dist(splash_random)).c_str();
+ return splash_lines.at(dist(splash_random));
}