Regularly send server heatbeats

This commit is contained in:
Maurice Heumann 2023-02-05 19:39:44 +01:00
parent e8372463cd
commit a15d6df35b

View File

@ -2,6 +2,10 @@
#include "loader/component_loader.hpp" #include "loader/component_loader.hpp"
#include "game/game.hpp" #include "game/game.hpp"
#include "command.hpp"
#include "network.hpp"
#include "scheduler.hpp"
#include "server_list.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
@ -13,6 +17,15 @@ namespace dedicated
{ {
game::SV_SendServerCommand(cl_0, type, "%c \"GAME_SERVER\x15: %s\"", 79, text); game::SV_SendServerCommand(cl_0, type, "%c \"GAME_SERVER\x15: %s\"", 79, text);
} }
void send_heartbeat()
{
game::netadr_t target{};
if (server_list::get_master_server(target))
{
network::send(target, "heartbeat", "T7");
}
}
} }
struct component final : server_component struct component final : server_component
@ -25,6 +38,10 @@ namespace dedicated
// Fix tell command for IW4M // Fix tell command for IW4M
utils::hook::call(0x14052A8CF_g, sv_con_tell_f_stub); 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);
} }
}; };
} }