From 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sat, 15 Mar 2025 16:22:09 +0500 Subject: Add whatever I was working on for the last month --- game/server/status.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 game/server/status.cc (limited to 'game/server/status.cc') diff --git a/game/server/status.cc b/game/server/status.cc new file mode 100644 index 0000000..0b8660b --- /dev/null +++ b/game/server/status.cc @@ -0,0 +1,26 @@ +#include "server/pch.hh" +#include "server/status.hh" + +#include "core/config.hh" + +#include "shared/protocol.hh" +#include "shared/splash.hh" + +#include "server/globals.hh" +#include "server/sessions.hh" + +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(); + response.num_players = sessions::num_players; + response.motd = splash::get(); + protocol::send(packet.peer, protocol::encode(response)); +} + +void status::init(void) +{ + globals::dispatcher.sink().connect<&on_status_request_packet>(); +} -- cgit