From 8693b8a2b0d7395027676e7ea1fd6d1ef58e1d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucca=20Jim=C3=A9nez=20K=C3=B6nings?= Date: Mon, 26 Feb 2024 03:54:01 +0100 Subject: [PATCH] Add `list` argument to command `settings` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lucca Jiménez Könings --- src/TConsole.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/TConsole.cpp b/src/TConsole.cpp index ff50760..d0ca3af 100644 --- a/src/TConsole.cpp +++ b/src/TConsole.cpp @@ -29,6 +29,7 @@ #include #include #include +#include static inline bool StringStartsWith(const std::string& What, const std::string& StartsWith) { return What.size() >= StartsWith.size() && What.substr(0, StartsWith.size()) == StartsWith; @@ -465,7 +466,36 @@ void TConsole::Command_Settings(const std::string&, const std::vector + for(const auto& [keyName, keyACL] : Application::SettingsSingleton.getACLMap()){ + // even though we have the value, we want to ignore it in order to make use of access + // control checks + + try{ + + Settings::SettingsAccessControl acl = Application::SettingsSingleton.getConsoleInputAccessMapping(keyName); + Settings::SettingsTypeVariant keyType = Application::SettingsSingleton.get(acl.first); + + std::visit( + overloaded { + [&keyName](std::string keyValue) { + Application::Console().WriteRaw(fmt::format("{} = {}", keyName, keyValue)); + }, + [&keyName](int keyValue) { + Application::Console().WriteRaw(fmt::format("{} = {}", keyName, keyValue)); + }, + [&keyName](bool keyValue) { + Application::Console().WriteRaw(fmt::format("{} = {}", keyName, keyValue)); + } + + }, + keyType); + }catch(std::logic_error& e){ + beammp_errorf("Error when getting key: {}", e.what()); + } + } + }else { beammp_errorf("Unknown argument for cammand 'settings': {}", args.front()); Application::Console().WriteRaw("BeamMP-Server Console: " + std::string(sHelpString));