From a929c5678eb35a3fba852019febbf6934b237e6c Mon Sep 17 00:00:00 2001 From: geneotech Date: Fri, 24 Nov 2023 17:37:13 +0100 Subject: [PATCH] rcon_commands::special -> server_maintenance_command --- src/application/gui/client/rcon_gui.hpp | 2 +- src/application/network/net_serialize.h | 2 +- src/application/network/rcon_command.h | 6 ++---- src/application/setups/server/server_setup.cpp | 15 ++++++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/application/gui/client/rcon_gui.hpp b/src/application/gui/client/rcon_gui.hpp index f4f76933e..d043e6348 100644 --- a/src/application/gui/client/rcon_gui.hpp +++ b/src/application/gui/client/rcon_gui.hpp @@ -35,7 +35,7 @@ void perform_rcon_gui( else { do_pretty_tabs(state.active_pane); - using RS = rcon_commands::special; + using RS = server_maintenance_command; auto do_command_button = [&](const std::string& label, const auto cmd) { if (ImGui::Button(label.c_str())) { diff --git a/src/application/network/net_serialize.h b/src/application/network/net_serialize.h index 8e7427d8d..055a6d630 100644 --- a/src/application/network/net_serialize.h +++ b/src/application/network/net_serialize.h @@ -188,7 +188,7 @@ namespace net_messages { } template - bool serialize(Stream& s, rcon_commands::special& c) { + bool serialize(Stream& s, server_maintenance_command& c) { return serialize_enum(s, c); } diff --git a/src/application/network/rcon_command.h b/src/application/network/rcon_command.h index c5a626fbd..c87495c5c 100644 --- a/src/application/network/rcon_command.h +++ b/src/application/network/rcon_command.h @@ -2,8 +2,7 @@ #include "application/setups/server/server_vars.h" #include "game/modes/mode_commands/match_command.h" -namespace rcon_commands { - enum class special : unsigned char { +enum class server_maintenance_command : unsigned char { SHUTDOWN, RESTART, CHECK_FOR_UPDATES_NOW, @@ -12,10 +11,9 @@ namespace rcon_commands { COUNT }; -}; using rcon_command_variant = std::variant< std::monostate, match_command, - rcon_commands::special + server_maintenance_command >; diff --git a/src/application/setups/server/server_setup.cpp b/src/application/setups/server/server_setup.cpp index c077a0c12..31121ffd0 100644 --- a/src/application/setups/server/server_setup.cpp +++ b/src/application/setups/server/server_setup.cpp @@ -1861,7 +1861,6 @@ message_handler_result server_setup::handle_rcon_payload( const rcon_level_type level, const P& typed_payload ) { - using namespace rcon_commands; constexpr auto abort_v = message_handler_result::ABORT_AND_DISCONNECT; constexpr auto continue_v = message_handler_result::CONTINUE; @@ -1870,9 +1869,11 @@ message_handler_result server_setup::handle_rcon_payload( return continue_v; } - else if constexpr(std::is_same_v) { + else if constexpr(std::is_same_v) { + using command = server_maintenance_command; + if (level == rcon_level_type::BASIC) { - if (typed_payload != special::REQUEST_RUNTIME_INFO) { + if (typed_payload != command::REQUEST_RUNTIME_INFO) { /* Basic RCON can only ask REQUEST_RUNTIME_INFO. The other tasks are administrative. @@ -1886,26 +1887,26 @@ message_handler_result server_setup::handle_rcon_payload( LOG("Performing a RCON command: %x", typed_payload); switch (typed_payload) { - case special::CHECK_FOR_UPDATES_NOW: + case command::CHECK_FOR_UPDATES_NOW: check_for_updates_once = true; return continue_v; - case special::SHUTDOWN: { + case command::SHUTDOWN: { LOG("Shutting down due to rcon's request."); schedule_shutdown(); return continue_v; } - case special::RESTART: { + case command::RESTART: { LOG("Restarting the server due to rcon's request."); schedule_restart(); return continue_v; } - case special::REQUEST_RUNTIME_INFO: + case command::REQUEST_RUNTIME_INFO: refresh_runtime_info_for_rcon(); return continue_v;