blob: 592c5cef74172c3d4b8d95db8629406db8cbbc75 (
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
27
28
29
30
31
32
33
34
35
|
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2025 Kirill Dmitrievich
// File: status.cc
// Description: Respond to client bothering
#include "server/pch.hh"
#include "server/status.hh"
#include "core/config/number.hh"
#include "core/version.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)
{
protocol::StatusResponse response;
response.game_version_major = version::major;
response.max_players = sessions::max_players.get_value();
response.num_players = sessions::num_players;
response.motd = splash::get();
response.game_version_minor = version::minor;
response.game_version_patch = version::patch;
protocol::send(packet.peer, protocol::encode(response));
}
void status::init(void)
{
globals::dispatcher.sink<protocol::StatusRequest>().connect<&on_status_request_packet>();
}
|