Do not lookup rcon dvars every single time we need them
This commit is contained in:
parent
3982dfe5cc
commit
5a2c0b565d
@ -7,6 +7,9 @@ namespace Components
|
|||||||
|
|
||||||
std::string RCon::Password;
|
std::string RCon::Password;
|
||||||
|
|
||||||
|
Dvar::Var RCon::RconPassword;
|
||||||
|
Dvar::Var RCon::RconLogRequests;
|
||||||
|
|
||||||
RCon::RCon()
|
RCon::RCon()
|
||||||
{
|
{
|
||||||
Command::Add("rcon", [](Command::Params* params)
|
Command::Add("rcon", [](Command::Params* params)
|
||||||
@ -75,8 +78,8 @@ namespace Components
|
|||||||
|
|
||||||
Dvar::OnInit([]()
|
Dvar::OnInit([]()
|
||||||
{
|
{
|
||||||
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
|
RCon::RconPassword = 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::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)
|
Network::Handle("rcon", [](Network::Address address, const std::string& _data)
|
||||||
@ -100,7 +103,7 @@ namespace Components
|
|||||||
password.erase(password.begin());
|
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())
|
if (svPassword.empty())
|
||||||
{
|
{
|
||||||
@ -114,7 +117,7 @@ namespace Components
|
|||||||
outputBuffer.clear();
|
outputBuffer.clear();
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
if (Dvar::Var("log_rcon_requests").get<bool>())
|
if (RCon::RconLogRequests.get<bool>())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
|
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
|
||||||
|
@ -25,5 +25,8 @@ namespace Components
|
|||||||
// For sr0's fucking rcon command
|
// For sr0's fucking rcon command
|
||||||
// Son of a bitch! Annoying me day and night with that shit...
|
// Son of a bitch! Annoying me day and night with that shit...
|
||||||
static std::string Password;
|
static std::string Password;
|
||||||
|
|
||||||
|
static Dvar::Var RconPassword;
|
||||||
|
static Dvar::Var RconLogRequests;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user