From 5a2c0b565da99c527aef61647298b04f90246de8 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 3 Mar 2022 16:37:18 +0000 Subject: [PATCH 1/2] Do not lookup rcon dvars every single time we need them --- src/Components/Modules/RCon.cpp | 11 +++++++---- src/Components/Modules/RCon.hpp | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 1ab6fc59..064b15d2 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -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("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - Dvar::Register("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); + RCon::RconLogRequests = Dvar::Register("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(); + const std::string svPassword = RCon::RconPassword.get(); if (svPassword.empty()) { @@ -114,7 +117,7 @@ namespace Components outputBuffer.clear(); #ifndef DEBUG - if (Dvar::Var("log_rcon_requests").get()) + if (RCon::RconLogRequests.get()) #endif { Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); diff --git a/src/Components/Modules/RCon.hpp b/src/Components/Modules/RCon.hpp index 1cc486e5..b5ec83cd 100644 --- a/src/Components/Modules/RCon.hpp +++ b/src/Components/Modules/RCon.hpp @@ -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; }; } From 74ed534bf63dd32fa05373e51df8134b834f435d Mon Sep 17 00:00:00 2001 From: FutureRave Date: Thu, 3 Mar 2022 17:43:22 +0000 Subject: [PATCH 2/2] snake case var --- src/Components/Modules/RCon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 064b15d2..8d506708 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -79,7 +79,7 @@ namespace Components Dvar::OnInit([]() { RCon::RconPassword = Dvar::Register("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); - RCon::RconLogRequests = Dvar::Register("rcon_logRequests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); + RCon::RconLogRequests = Dvar::Register("rcon_log_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); }); Network::Handle("rcon", [](Network::Address address, const std::string& _data)