Skip to content

Commit

Permalink
rcon_commands::special -> server_maintenance_command
Browse files Browse the repository at this point in the history
  • Loading branch information
geneotech committed Nov 26, 2023
1 parent 2382517 commit a929c56
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/application/gui/client/rcon_gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
2 changes: 1 addition & 1 deletion src/application/network/net_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace net_messages {
}

template <class Stream>
bool serialize(Stream& s, rcon_commands::special& c) {
bool serialize(Stream& s, server_maintenance_command& c) {
return serialize_enum(s, c);
}

Expand Down
6 changes: 2 additions & 4 deletions src/application/network/rcon_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,10 +11,9 @@ namespace rcon_commands {

COUNT
};
};

using rcon_command_variant = std::variant<
std::monostate,
match_command,
rcon_commands::special
server_maintenance_command
>;
15 changes: 8 additions & 7 deletions src/application/setups/server/server_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -1870,9 +1869,11 @@ message_handler_result server_setup::handle_rcon_payload(

return continue_v;
}
else if constexpr(std::is_same_v<P, special>) {
else if constexpr(std::is_same_v<P, server_maintenance_command>) {
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.
Expand All @@ -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;
Expand Down

0 comments on commit a929c56

Please sign in to comment.