Do not lookup rcon dvars every single time we need them

This commit is contained in:
FutureRave 2022-03-03 16:37:18 +00:00
parent 3982dfe5cc
commit 5a2c0b565d
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
2 changed files with 10 additions and 4 deletions

View File

@ -7,6 +7,9 @@ namespace Components
std::string RCon::Password;
Dvar::Var RCon::RconPassword;
Dvar::Var RCon::RconLogRequests;
RCon::RCon()
{
Command::Add("rcon", [](Command::Params* params)
@ -75,8 +78,8 @@ namespace Components
Dvar::OnInit([]()
{
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
Dvar::Register<bool>("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log");
RCon::RconPassword = Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
RCon::RconLogRequests = Dvar::Register<bool>("rcon_logRequests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log");
});
Network::Handle("rcon", [](Network::Address address, const std::string& _data)
@ -100,7 +103,7 @@ namespace Components
password.erase(password.begin());
}
std::string svPassword = Dvar::Var("rcon_password").get<std::string>();
const std::string svPassword = RCon::RconPassword.get<std::string>();
if (svPassword.empty())
{
@ -114,7 +117,7 @@ namespace Components
outputBuffer.clear();
#ifndef DEBUG
if (Dvar::Var("log_rcon_requests").get<bool>())
if (RCon::RconLogRequests.get<bool>())
#endif
{
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());

View File

@ -25,5 +25,8 @@ namespace Components
// For sr0's fucking rcon command
// Son of a bitch! Annoying me day and night with that shit...
static std::string Password;
static Dvar::Var RconPassword;
static Dvar::Var RconLogRequests;
};
}