From e2c34dfb70be62a2b0dcb20554384d65823742f1 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 17 Jun 2024 22:02:31 -0700 Subject: [PATCH] add option to enable switch assist by default --- src/ReceiveCommands.cc | 6 +++++- src/ServerState.cc | 1 + src/ServerState.hh | 1 + system/config.example.json | 5 +++++ tests/config.json | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index ad132d97..8d276883 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -253,9 +253,13 @@ static bool send_enable_send_function_call_if_applicable(shared_ptr c) { //////////////////////////////////////////////////////////////////////////////// void on_connect(std::shared_ptr c) { + auto s = c->require_server_state(); + if (s->default_switch_assist_enabled) { + c->config.set_flag(Client::Flag::SWITCH_ASSIST_ENABLED); + } + switch (c->server_behavior) { case ServerBehavior::PC_CONSOLE_DETECT: { - auto s = c->require_server_state(); uint16_t pc_port = s->name_to_port_config.at("pc-login")->port; uint16_t console_port = s->name_to_port_config.at("console-login")->port; send_pc_console_split_reconnect(c, s->connect_address_for_client(c), pc_port, console_port); diff --git a/src/ServerState.cc b/src/ServerState.cc index d13198f7..2992b108 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -783,6 +783,7 @@ void ServerState::load_config_early() { this->persistent_game_idle_timeout_usecs = this->config_json->get_int("PersistentGameIdleTimeout", 0); this->cheat_mode_behavior = parse_behavior_switch("CheatModeBehavior", BehaviorSwitch::OFF_BY_DEFAULT); + this->default_switch_assist_enabled = this->config_json->get_bool("EnableSwitchAssistByDefault", false); this->use_game_creator_section_id = this->config_json->get_bool("UseGameCreatorSectionID", false); this->default_rare_notifs_enabled_v1_v2 = this->config_json->get_bool("RareNotificationsEnabledByDefault", false); this->default_rare_notifs_enabled_v3_v4 = this->default_rare_notifs_enabled_v1_v2; diff --git a/src/ServerState.hh b/src/ServerState.hh index b4b26d26..990ae226 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -131,6 +131,7 @@ struct ServerState : public std::enable_shared_from_this { bool hide_download_commands = true; RunShellBehavior run_shell_behavior = RunShellBehavior::DEFAULT; BehaviorSwitch cheat_mode_behavior = BehaviorSwitch::OFF_BY_DEFAULT; + bool default_switch_assist_enabled = false; bool use_game_creator_section_id = false; bool default_rare_notifs_enabled_v1_v2 = false; bool default_rare_notifs_enabled_v3_v4 = false; diff --git a/system/config.example.json b/system/config.example.json index a8fd93ad..7da72cc8 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -995,6 +995,11 @@ // available on the proxy server. "CheatModeBehavior": "OnByDefault", + // Default switch assist behavior. Players can always toggle switch assist + // with the $swa command; this only controls whether it's enabled by default + // for all players or not. + "EnableSwitchAssistByDefault": false, + // Whether to enable rare drop notifications by default. Players can toggle // this behavior for themselves with the $itemnotifs command. "RareNotificationsEnabledByDefaultV1V2": false, diff --git a/tests/config.json b/tests/config.json index 2f27a292..3934663d 100644 --- a/tests/config.json +++ b/tests/config.json @@ -30,6 +30,7 @@ "DefaultDropModeV4Battle": "SERVER_SHARED", "DefaultDropModeV4Challenge": "SERVER_SHARED", "CheatModeBehavior": "OnByDefault", + "EnableSwitchAssistByDefault": false, "RareNotificationsEnabledByDefault": false, "NotifyGameForItemPrimaryIdentifiersV1V2": [], "NotifyGameForItemPrimaryIdentifiersV3": [],