diff --git a/src/client/component/dedicated.cpp b/src/client/component/dedicated.cpp index 2839858a..92da00c6 100644 --- a/src/client/component/dedicated.cpp +++ b/src/client/component/dedicated.cpp @@ -1,4 +1,5 @@ #include +#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); } diff --git a/src/client/component/dedicated.hpp b/src/client/component/dedicated.hpp new file mode 100644 index 00000000..140587ba --- /dev/null +++ b/src/client/component/dedicated.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace dedicated +{ + void send_heartbeat(); +} diff --git a/src/client/steam/interfaces/game_server.cpp b/src/client/steam/interfaces/game_server.cpp index 11e7a79d..8127c377 100644 --- a/src/client/steam/interfaces/game_server.cpp +++ b/src/client/steam/interfaces/game_server.cpp @@ -1,5 +1,6 @@ #include #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)