summaryrefslogtreecommitdiffstats
path: root/game
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-16 22:19:39 +0500
committeruntodesu <kirill@untode.su>2025-03-16 22:19:39 +0500
commitd1d7521ee859f10e99fb3f82e710c8bbeb7c41c5 (patch)
tree900e6a537bd5763636db8497404d3b28e6afcef2 /game
parent68b0b663514d1a5dcf79cfbdeea544b5d69ed1ed (diff)
downloadvoxelius-d1d7521ee859f10e99fb3f82e710c8bbeb7c41c5.tar.bz2
voxelius-d1d7521ee859f10e99fb3f82e710c8bbeb7c41c5.zip
Fix the bizzare CRC32 callback I forgot to remove
- This fixes bother not working - Separated client and server splashes - Added server splashes
Diffstat (limited to 'game')
-rw-r--r--game/client/bother.cc1
-rw-r--r--game/client/game.cc1
-rw-r--r--game/client/main.cc2
-rw-r--r--game/client/play_menu.cc3
-rw-r--r--game/server/game.cc5
-rw-r--r--game/server/status.cc1
-rw-r--r--game/shared/splash.cc46
-rw-r--r--game/shared/splash.hh3
8 files changed, 45 insertions, 17 deletions
diff --git a/game/client/bother.cc b/game/client/bother.cc
index e808485..8ca247a 100644
--- a/game/client/bother.cc
+++ b/game/client/bother.cc
@@ -75,6 +75,7 @@ void bother::update_late(void)
if(auto peer = enet_host_connect(bother_host, &address, 1, 0)) {
peer->data = reinterpret_cast<void *>(static_cast<std::uintptr_t>(item.identity));
bother_set.insert(item.identity);
+ enet_host_flush(bother_host);
}
bother_queue.pop_front();
diff --git a/game/client/game.cc b/game/client/game.cc
index e0e02d1..f7a6349 100644
--- a/game/client/game.cc
+++ b/game/client/game.cc
@@ -205,7 +205,6 @@ void client_game::init(void)
settings::add_keybind(4, hide_hud_toggle, settings_location::KEYBOARD_MISC, "game.key.toggle_hide_hud");
globals::client_host = enet_host_create(nullptr, 1, 1, 0, 0);
- globals::client_host->checksum = &enet_crc32;
if(!globals::client_host) {
spdlog::critical("game: unable to setup an ENet host");
diff --git a/game/client/main.cc b/game/client/main.cc
index 6fabaa3..277b278 100644
--- a/game/client/main.cc
+++ b/game/client/main.cc
@@ -266,7 +266,7 @@ int main(int argc, char **argv)
alcMakeContextCurrent(globals::sound_ctx);
- splash::init();
+ splash::init_client();
window_title::update();
diff --git a/game/client/play_menu.cc b/game/client/play_menu.cc
index 4c1d2cd..1c89252 100644
--- a/game/client/play_menu.cc
+++ b/game/client/play_menu.cc
@@ -195,7 +195,7 @@ static void on_bother_response(const BotherResponseEvent &event)
item->num_players = event.num_players;
item->max_players = event.max_players;
item->motd = event.motd;
- item->status = item_status::FAILURE;
+ item->status = item_status::REACHED;
}
break;
@@ -480,7 +480,6 @@ void play_menu::update_late(void)
{
for(auto item : servers_deque) {
if(item->status == item_status::UNKNOWN) {
- spdlog::info("bothering {}", item->name);
bother::ping(item->identity, item->hostname.c_str(), item->port);
item->status = item_status::PINGING;
continue;
diff --git a/game/server/game.cc b/game/server/game.cc
index 9d690f2..cc5baf8 100644
--- a/game/server/game.cc
+++ b/game/server/game.cc
@@ -48,7 +48,7 @@ void server_game::init(void)
whitelist::init();
- splash::init();
+ splash::init_server();
status::init();
@@ -72,8 +72,7 @@ void server_game::init_late(void)
address.port = listen_port.get_value();
globals::server_host = enet_host_create(&address, sessions::max_players.get_value() + status_peers.get_value(), 1, 0, 0);
- globals::server_host->checksum = &enet_crc32;
-
+
if(!globals::server_host) {
spdlog::critical("game: unable to setup an ENet host");
std::terminate();
diff --git a/game/server/status.cc b/game/server/status.cc
index 0b8660b..e44a4f4 100644
--- a/game/server/status.cc
+++ b/game/server/status.cc
@@ -11,7 +11,6 @@
static void on_status_request_packet(const protocol::StatusRequest &packet)
{
- spdlog::info("STATUS REQUEST");
protocol::StatusResponse response;
response.version = protocol::VERSION;
response.max_players = sessions::max_players.get_value();
diff --git a/game/shared/splash.cc b/game/shared/splash.cc
index ec7b3c8..068c5c6 100644
--- a/game/shared/splash.cc
+++ b/game/shared/splash.cc
@@ -1,14 +1,29 @@
#include "shared/pch.hh"
#include "shared/splash.hh"
-constexpr static const char *SPLASHES_FILENAME = "misc/splashes.txt";
+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;
-void splash::init(void)
+static std::string sanitize_line(const std::string &line)
{
- if(auto file = PHYSFS_openRead(SPLASHES_FILENAME)) {
+ std::string result;
+
+ for(auto chr : line) {
+ if((chr == '\r') || (chr == '\n'))
+ continue;
+ 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);
@@ -16,14 +31,29 @@ void splash::init(void)
std::string line;
std::istringstream stream(source);
- while(std::getline(stream, line)) {
- splash_lines.push_back(line);
- }
-
+ while(std::getline(stream, line))
+ splash_lines.push_back(sanitize_line(line));
splash_random.seed(std::random_device()());
}
else {
- splash_lines.push_back(fmt::format("{}: {}", SPLASHES_FILENAME, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())));
+ splash_lines.push_back(fmt::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);
}
}
diff --git a/game/shared/splash.hh b/game/shared/splash.hh
index 2a370f9..9510d35 100644
--- a/game/shared/splash.hh
+++ b/game/shared/splash.hh
@@ -4,7 +4,8 @@
namespace splash
{
-void init(void);
+void init_client(void);
+void init_server(void);
const char* get(void);
} // namespace splash