t7x/src/client/component/dedicated.cpp

56 lines
1.2 KiB
C++
Raw Normal View History

2022-11-24 11:25:37 -05:00
#include <std_include.hpp>
2023-02-08 12:27:30 -05:00
#include "dedicated.hpp"
2022-11-24 11:25:37 -05:00
#include "loader/component_loader.hpp"
2023-01-02 07:57:00 -05:00
#include "game/game.hpp"
2023-02-05 13:39:44 -05:00
#include "command.hpp"
#include "network.hpp"
#include "scheduler.hpp"
#include "server_list.hpp"
2023-01-02 07:57:00 -05:00
2022-11-24 11:25:37 -05:00
#include <utils/hook.hpp>
namespace dedicated
{
namespace
{
2023-02-08 12:27:30 -05:00
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)
2023-01-09 10:53:51 -05:00
{
game::SV_SendServerCommand(cl_0, type, "%c \"GAME_SERVER\x15: %s\"", 79, text);
}
2023-02-08 12:27:30 -05:00
}
void send_heartbeat()
{
if (!game::is_server())
{
return;
}
2023-02-05 13:39:44 -05:00
2023-02-08 12:27:30 -05:00
game::netadr_t target{};
if (server_list::get_master_server(target))
2023-02-05 13:39:44 -05:00
{
2023-02-08 12:27:30 -05:00
network::send(target, "heartbeat", "T7");
2023-02-05 13:39:44 -05:00
}
2022-11-24 11:25:37 -05:00
}
2023-01-01 15:51:04 -05:00
struct component final : server_component
2022-11-24 11:25:37 -05:00
{
void post_unpack() override
{
2023-01-02 07:57:00 -05:00
// Ignore "bad stats"
2023-02-05 13:08:47 -05:00
//utils::hook::set<uint8_t>(0x14052D523_g, 0xEB);
//utils::hook::nop(0x14052D4E4_g, 2);
2023-01-09 10:53:51 -05:00
// Fix tell command for IW4M
utils::hook::call(0x14052A8CF_g, sv_con_tell_f_stub);
2023-02-05 13:39:44 -05:00
scheduler::loop(send_heartbeat, scheduler::pipeline::server, 10min);
command::add("heartbeat", send_heartbeat);
2022-11-24 11:25:37 -05:00
}
};
}
REGISTER_COMPONENT(dedicated::component)