Fix dedicated server heartbeats

This commit is contained in:
Maurice Heumann 2023-02-08 18:27:30 +01:00
parent 3ec1361ed9
commit cf61232020
3 changed files with 22 additions and 8 deletions

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "dedicated.hpp"
#include "loader/component_loader.hpp"
#include "game/game.hpp"
@ -13,18 +14,24 @@ namespace dedicated
{
namespace
{
void sv_con_tell_f_stub(game::client_s* cl_0, game::svscmd_type type, [[maybe_unused]] const char* fmt, [[maybe_unused]] int c, char* text)
void sv_con_tell_f_stub(game::client_s* cl_0, game::svscmd_type type, [[maybe_unused]] const char* fmt,
[[maybe_unused]] int c, char* text)
{
game::SV_SendServerCommand(cl_0, type, "%c \"GAME_SERVER\x15: %s\"", 79, text);
}
}
void send_heartbeat()
void send_heartbeat()
{
if (!game::is_server())
{
game::netadr_t target{};
if (server_list::get_master_server(target))
{
network::send(target, "heartbeat", "T7");
}
return;
}
game::netadr_t target{};
if (server_list::get_master_server(target))
{
network::send(target, "heartbeat", "T7");
}
}
@ -39,7 +46,6 @@ namespace dedicated
// Fix tell command for IW4M
utils::hook::call(0x14052A8CF_g, sv_con_tell_f_stub);
scheduler::once(send_heartbeat, scheduler::pipeline::server);
scheduler::loop(send_heartbeat, scheduler::pipeline::server, 10min);
command::add("heartbeat", send_heartbeat);
}

View File

@ -0,0 +1,6 @@
#pragma once
namespace dedicated
{
void send_heartbeat();
}

View File

@ -1,5 +1,6 @@
#include <std_include.hpp>
#include "../steam.hpp"
#include "../../component/dedicated.hpp"
namespace steam
{
@ -182,6 +183,7 @@ namespace steam
void game_server::EnableHeartbeats(bool bActive)
{
dedicated::send_heartbeat();
}
void game_server::SetHeartbeatInterval(int iHeartbeatInterval)