diff options
Diffstat (limited to 'game/shared/splash.cc')
| -rw-r--r-- | game/shared/splash.cc | 12 |
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)); } |
