summaryrefslogtreecommitdiffstats
path: root/game/shared/splash.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-06-29 22:24:42 +0500
committeruntodesu <kirill@untode.su>2025-06-29 22:24:42 +0500
commit6cd00aacfa22fed6a54a9b812f6b069ad16feec0 (patch)
treeb77f4e665da3dd235cdb01e7e6ea78c1c02ecf2e /game/shared/splash.cc
parentf440914e1ae453768d09383f332bc7844e0a700e (diff)
downloadvoxelius-6cd00aacfa22fed6a54a9b812f6b069ad16feec0.tar.bz2
voxelius-6cd00aacfa22fed6a54a9b812f6b069ad16feec0.zip
Move game sources into src subdirectory
Diffstat (limited to 'game/shared/splash.cc')
-rw-r--r--game/shared/splash.cc64
1 files changed, 0 insertions, 64 deletions
diff --git a/game/shared/splash.cc b/game/shared/splash.cc
deleted file mode 100644
index 0cd5f50..0000000
--- a/game/shared/splash.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "shared/pch.hh"
-
-#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::size_t SPLASH_SERVER_MAX_LENGTH = 32;
-
-static std::mt19937_64 splash_random;
-static std::vector<std::string> splash_lines;
-
-static std::string sanitize_line(const std::string& line)
-{
- std::string result;
-
- for(auto chr : line) {
- if(chr != '\r' && chr != '\n') {
- result.push_back(chr);
- }
- }
-
- return result;
-}
-
-static void splash_init_filename(const char* filename)
-{
- if(auto file = PHYSFS_openRead(filename)) {
- auto source = std::string(PHYSFS_fileLength(file), char(0x00));
- PHYSFS_readBytes(file, source.data(), source.size());
- PHYSFS_close(file);
-
- std::string line;
- std::istringstream stream(source);
-
- while(std::getline(stream, line))
- splash_lines.push_back(sanitize_line(line));
- splash_random.seed(std::random_device()());
- } else {
- splash_lines.push_back(std::format("{}: {}", filename, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())));
- splash_random.seed(std::random_device()());
- }
-}
-
-void splash::init_client(void)
-{
- splash_init_filename(SPLASHES_FILENAME_CLIENT);
-}
-
-void splash::init_server(void)
-{
- splash_init_filename(SPLASHES_FILENAME_SERVER);
-
- // Server browser GUI should be able to display
- // these splash messages without text clipping over
- for(int i = 0; i < splash_lines.size(); i++) {
- splash_lines[i] = splash_lines[i].substr(0, SPLASH_SERVER_MAX_LENGTH);
- }
-}
-
-const char* 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();
-}