fix(rcon): patch buffer flush bug (#216)

This commit is contained in:
Diamante 2024-04-19 16:49:37 +02:00 committed by GitHub
parent 009b97e4a1
commit 88f75fca4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 9 deletions

View File

@ -169,11 +169,11 @@ namespace command
{
if (args.size() == 1)
{
const auto current = game::Dvar_ValueToString(dvar, dvar->current);
const auto reset = game::Dvar_ValueToString(dvar, dvar->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\" default: \"%s\" checksum: %d type: %i\n",
dvars::dvar_get_name(dvar).data(), current, reset, dvar->checksum, dvar->type);
dvars::dvar_get_name(dvar).data(), current.data(), reset.data(), dvar->checksum, dvar->type);
const auto dvar_info = dvars::dvar_get_description(dvar);
@ -184,7 +184,7 @@ namespace command
}
else
{
char command[0x1000] = { 0 };
char command[0x1000]{};
game::Dvar_GetCombinedString(command, 1);
game::Dvar_SetCommand(args[0], command);
}

View File

@ -20,6 +20,7 @@ namespace rcon
std::atomic_bool is_redirecting_{ false };
std::atomic_bool has_redirected_{ false };
game::netadr_s redirect_target_ = {};
std::string redirect_buffer = {};
std::recursive_mutex redirect_lock;
void setup_redirect(const game::netadr_s& target)
@ -29,15 +30,19 @@ namespace rcon
has_redirected_ = false;
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');
has_redirected_ = false;
is_redirecting_ = false;
redirect_target_ = {};
redirect_buffer.clear();
}
void send_rcon_command(const std::string& password, const std::string& data)
@ -69,7 +74,7 @@ namespace rcon
std::string build_status_buffer()
{
const auto mapname = game::Dvar_FindVar("mapname");
const auto* mapname = game::Dvar_FindVar("mapname");
std::string buffer{};
buffer.append(utils::string::va("map: %s\n", mapname->current.string));
@ -78,7 +83,7 @@ namespace rcon
buffer.append(
"--- ----- --- ---- -------------------------------- ---------------- --------------------- -----\n");
const auto svs_clients = *game::svs_clients;
const auto* svs_clients = *game::svs_clients;
if (svs_clients == nullptr)
{
return buffer;
@ -86,7 +91,7 @@ namespace rcon
for (auto i = 0u; i < *game::svs_numclients; i++)
{
const auto client = &svs_clients[i];
const auto* client = &svs_clients[i];
if (client->header.state >= 1 && client->gentity && client->gentity->client)
{
@ -122,9 +127,10 @@ namespace rcon
if (is_redirecting_)
{
has_redirected_ = true;
network::send(redirect_target_, "print", message, '\n');
redirect_buffer.append(message);
return true;
}
return false;
}

View File

@ -22,7 +22,7 @@ namespace demonware
{
auto result = std::make_unique<bdDMLRawData>();
result->country_code = "US";
result->country_code = "'Murica";
result->country = "United States of America";
result->region = "New York";
result->city = "New York";
result->latitude = 0;