From d1d7521ee859f10e99fb3f82e710c8bbeb7c41c5 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 16 Mar 2025 22:19:39 +0500 Subject: Fix the bizzare CRC32 callback I forgot to remove - This fixes bother not working - Separated client and server splashes - Added server splashes --- data/misc/splashes.txt | 54 ------------------------------------------- data/misc/splashes_client.txt | 54 +++++++++++++++++++++++++++++++++++++++++++ data/misc/splashes_server.txt | 46 ++++++++++++++++++++++++++++++++++++ game/client/bother.cc | 1 + game/client/game.cc | 1 - game/client/main.cc | 2 +- game/client/play_menu.cc | 3 +-- game/server/game.cc | 5 ++-- game/server/status.cc | 1 - game/shared/splash.cc | 46 +++++++++++++++++++++++++++++------- game/shared/splash.hh | 3 ++- 11 files changed, 145 insertions(+), 71 deletions(-) delete mode 100644 data/misc/splashes.txt create mode 100644 data/misc/splashes_client.txt create mode 100644 data/misc/splashes_server.txt diff --git a/data/misc/splashes.txt b/data/misc/splashes.txt deleted file mode 100644 index cb5801d..0000000 --- a/data/misc/splashes.txt +++ /dev/null @@ -1,54 +0,0 @@ -((void *)(0)) -[deleted] -#define FALSE 1 -#define NULL ((void *)(0)) -#define NULL ((void *)(1)) -#define TRUE 0 -100% intentional -100% international -100% lag free -100% organic -AAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -Also try CaveCube! -Also try OpenBuilder! -BEHOLD -Chicken and sphere challenge -Curse you Perry the Platypus -DELETE THIS -Did You Bring the Cheese -Did you know? -Don't eat yellow snow! -Don't look behind you -Either. Or Both. Depends on perspective. -Every day is the same! -Format your hard drive today! -From Urals with Love -Happiness only real when shared -Hell is empty and all the devils are here. -I am confiscating that MOTD -I am inside your walls -It's all connected! -It's downward from here -ITS ALL CONNECTED -Lets Play A Game... -Made in Russia -Maintain a positive attitude! -More than a meme -My stepdads play this game -Null -Own a musket for home defense -PIXEL SIZE 4 GAMEPLAY -Press Alt+F4 -Real life sucks anyway! -REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE -Send dudes, we need more men! -Sometimes I dream about cheese -Stay hydrated. This is a threat. -STOP POSTING ABOUT AMONG US -Stop reading this and join -Trust me, I'm a doctor. -What is a MOTD? -YES NO YES NO YES NO YES NO YES NO YES NO -YOU DARE CHALLENGE MEGAMIND?! -Your inbox has (13) new messages diff --git a/data/misc/splashes_client.txt b/data/misc/splashes_client.txt new file mode 100644 index 0000000..581c47f --- /dev/null +++ b/data/misc/splashes_client.txt @@ -0,0 +1,54 @@ +((void *)(0)) +[deleted] +[REDACTED] +#define FALSE 1 +#define NULL ((void *)(0)) +#define NULL ((void *)(1)) +#define TRUE 0 +100% intentional +100% international +100% lag free +100% organic +AAAAAAAAAAAAAAAAAAA +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +Also try CaveCube! +Also try OpenBuilder! +BEHOLD +Chicken and sphere challenge +Curse you Perry the Platypus +DELETE THIS +Did You Bring the Cheese +Did you know? +Don't eat yellow snow! +Don't look behind you +Either. Or Both. Depends on perspective. +Every day is the same! +Format your hard drive today! +From Urals with Love +Happiness only real when shared +Hell is empty and all the devils are here. +I am confiscating that splash +I am inside your walls +It's all connected! +It's downward from here +ITS ALL CONNECTED +Lets Play A Game... +Made in Russia +Maintain a positive attitude! +More than a meme +My stepdads play this game +Null +Own a musket for home defense +PIXEL SIZE 4 GAMEPLAY +Press Alt+F4 +Real life sucks anyway! +REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE +Send dudes, we need more men! +Sometimes I dream about cheese +Stay hydrated. This is a threat. +STOP POSTING ABOUT AMONG US +Trust me, I'm a doctor. +What is a MOTD? +YES NO YES NO YES NO YES NO YES NO YES NO +YOU DARE CHALLENGE MEGAMIND?! +Your inbox has (13) new messages diff --git a/data/misc/splashes_server.txt b/data/misc/splashes_server.txt new file mode 100644 index 0000000..fab2330 --- /dev/null +++ b/data/misc/splashes_server.txt @@ -0,0 +1,46 @@ +((void *)(0)) +[deleted] +[REDACTED] +#define FALSE 1 +#define NULL ((void *)(-1)) +#define NULL ((void *)(0)) +#define NULL ((void *)(1)) +#define TRUE 0 +A Voxelius Server +All your base are belong to us +Also try CaveCube! +Also try OpenBuilder! +Cache my chunks if you can +Chicken and sphere challenge +Connection limit: YES +Don't eat yellow snow! +ENetPacket tastes like purple +Error 418: I'm a teapot +Experiencing technical gremlins +Fahrenheit 451 Server Room +From Urals with Love +globals::sanity underflow +Good code was never an option +I am confiscating that MOTD +I am inside your walls +Insert more server RAM here +It's all connected! +It's not a bug - it's lore +ITS ALL CONNECTED +Maximum sass capacity reached +My stepdads play in here +No cookies, only sessions +protocol.entity_id_desync +Rebooting the matrix... +REEEEEEEEEEEEEEEEEEEEEEEEEEEEEE +Segmentation fault (core dumped) +Server hamsters need coffee +Stay hydrated. This is a threat. +STOP POSTING ABOUT AMONG US +Stop reading this and join +this_is_fine_20220224.png +Uptime: 30 years... maybe +VoxelStorage overflow detected +vserver.exe has stopped thinking +We ran out of stack traces +You wouldn't download a server 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(static_cast(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 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 -- cgit