summaryrefslogtreecommitdiffstats
path: root/game/server/status.cc
blob: 0b8660bc794ab88ce177655bfb0c324ce680f763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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<protocol::StatusRequest>().connect<&on_status_request_packet>();
}