maint: April update

This commit is contained in:
2024-04-26 11:04:02 +02:00
parent 97c48da499
commit 0090d894c4
6 changed files with 37 additions and 16 deletions

View File

@ -204,6 +204,7 @@ namespace bots
if (server_list::get_master_server(master) && !bot_names_received && target == master)
{
bot_names = utils::string::split(data, '\n');
console::info("Got %zu names from the master server\n", bot_names.size());
bot_names_received = true;
}
});

View File

@ -3,7 +3,9 @@
#include "game/game.hpp"
#include "command.hpp"
#include "console.hpp"
#include "network.hpp"
#include "party.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -86,8 +88,7 @@ namespace network
return net_compare_base_address(a1, a2) && a1->port == a2->port;
}
void reconnect_migratated_client(game::mp::client_t*, game::netadr_s* from, const int, const int, const char*,
const char*, bool)
void reconnect_migrated_client(game::mp::client_t*, game::netadr_s* from, const int, const int, const char*, const char*, bool)
{
// This happens when a client tries to rejoin after being recently disconnected, OR by a duplicated guid
// We don't want this to do anything. It decides to crash seemingly randomly
@ -224,7 +225,7 @@ namespace network
utils::hook::jump(0x14041DFB0, utils::hook::assemble(set_xuid_config_string_stub), true);
utils::hook::jump(0x14041D010, net_compare_address);
utils::hook::jump(0x14041D060, net_compare_base_address);
utils::hook::jump(0x14041D060, net_compare_address);
// don't establish secure conenction
utils::hook::set<uint8_t>(0x1402ECF1D, 0xEB);
@ -275,13 +276,26 @@ namespace network
utils::hook::jump(0x1405019CB, 0x1405019F3);
// don't try to reconnect client
utils::hook::call(0x14047197E, reconnect_migratated_client);
utils::hook::call(0x14047197E, reconnect_migrated_client);
// allow server owner to modify net_port before the socket bind
utils::hook::call(0x140500FD0, register_netport_stub);
// ignore built in "print" oob command for security reasons
utils::hook::set<std::uint8_t>(0x1402C6AA4, 0xEB);
if (!game::environment::is_dedi())
{
// we need this on the client for RCon
on("print", [](const game::netadr_s& address, const std::string& message)
{
if (address != party::get_target())
{
return;
}
console::info("%s", message.data());
});
}
// patch buffer overflow
utils::hook::call(0x14041D17E, memmove_stub); // NET_DeferPacketToClient

View File

@ -132,14 +132,14 @@ namespace patches
{
if (args.size() == 1)
{
const auto current = game::Dvar_ValueToString(dvar, dvar->current);
const auto reset = game::Dvar_ValueToString(dvar, dvar->reset);
console::info("\"%s\" is: \"%s^7\" default: \"%s^7\"\n", dvar->name, current, reset);
const std::string current = game::Dvar_ValueToString(dvar, dvar->current);
const std::string reset = game::Dvar_ValueToString(dvar, dvar->reset);
console::info("\"%s\" is: \"%s^7\" default: \"%s^7\"\n", dvar->name, current.data(), reset.data());
console::info(" %s\n", dvars::dvar_get_domain(dvar->type, dvar->domain).data());
}
else
{
char command[0x1000] = {0};
char command[0x1000]{};
game::Dvar_GetCombinedString(command, 1);
game::Dvar_SetCommand(args.get(0), command);
}

View File

@ -15,6 +15,7 @@ namespace rcon
{
bool is_redirecting_ = false;
game::netadr_s redirect_target_ = {};
std::string redirect_buffer = {};
std::recursive_mutex redirect_lock;
void setup_redirect(const game::netadr_s& target)
@ -23,14 +24,18 @@ namespace rcon
is_redirecting_ = true;
redirect_target_ = target;
redirect_buffer.clear();
}
void clear_redirect()
{
std::lock_guard<std::recursive_mutex> $(redirect_lock);
network::send(redirect_target_, "print", redirect_buffer, '\n');
is_redirecting_ = false;
redirect_target_ = {};
redirect_buffer.clear();
}
std::string build_status_buffer()
@ -104,9 +109,10 @@ namespace rcon
if (is_redirecting_)
{
network::send(redirect_target_, "print\n", message);
redirect_buffer.append(message);
return true;
}
return false;
}