diff --git a/config.def.h b/config.def.h index 7b03437332..fe46c2aab8 100644 --- a/config.def.h +++ b/config.def.h @@ -821,6 +821,12 @@ static const bool netplay_public_announce = true; /* Start netplay in spectator mode */ static const bool netplay_start_as_spectator = false; +/* Allow connections in slave mode */ +static const bool netplay_allow_slaves = true; + +/* Require connections only in slave mode */ +static const bool netplay_require_slaves = false; + /* Netplay without savestates/rewind */ static const bool netplay_stateless_mode = false; diff --git a/configuration.c b/configuration.c index 06c72ae1ce..bc9e76dd6a 100644 --- a/configuration.c +++ b/configuration.c @@ -730,6 +730,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, #ifdef HAVE_NETWORKING SETTING_BOOL("netplay_public_announce", &settings->netplay.public_announce, true, netplay_public_announce, false); SETTING_BOOL("netplay_start_as_spectator", &settings->netplay.start_as_spectator, false, netplay_start_as_spectator, false); + SETTING_BOOL("netplay_allow_slaves", &settings->netplay.allow_slaves, true, netplay_allow_slaves, false); + SETTING_BOOL("netplay_require_slaves", &settings->netplay.require_slaves, true, netplay_require_slaves, false); SETTING_BOOL("netplay_stateless_mode", &settings->netplay.stateless_mode, false, netplay_stateless_mode, false); SETTING_BOOL("netplay_client_swap_input", &settings->netplay.swap_input, true, netplay_client_swap_input, false); #endif diff --git a/configuration.h b/configuration.h index 3b6c51306f..941ff9f427 100644 --- a/configuration.h +++ b/configuration.h @@ -407,6 +407,8 @@ typedef struct settings char server[255]; unsigned port; bool start_as_spectator; + bool allow_slaves; + bool require_slaves; bool stateless_mode; int check_frames; unsigned input_latency_frames_min; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 8772de1888..8a0be73aa7 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -599,6 +599,8 @@ MSG_HASH(MENU_ENUM_LABEL_NETPLAY_ENABLE_CLIENT, "menu_netplay_enable_client") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_ENABLE_HOST, "menu_netplay_enable_host") +MSG_HASH(MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES, + "netplay_allow_slaves") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, "netplay_ip_address") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_MODE, @@ -613,6 +615,8 @@ MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SETTINGS, "menu_netplay_settings") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE, "netplay_public_announce") +MSG_HASH(MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES, + "netplay_require_slaves") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD, "netplay_spectate_password") MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 4dafc524fc..4decd24c25 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -1540,6 +1540,21 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) { "on start. It's always possible to change mode \n" "later."); break; + case MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES: + snprintf(s, len, + "Whether to allow connections in slave mode. \n" + " \n" + "Slave-mode clients require very little processing \n" + "power on either side, but will suffer \n" + "significantly from network latency."); + break; + case MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES: + snprintf(s, len, + "Whether to disallow connections not in slave mode. \n" + " \n" + "Not recommended except for very fast networks \n" + "with very weak machines. \n"); + break; case MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE: snprintf(s, len, "Whether to run netplay in a mode not requiring\n" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 7ca3391f13..9a3adf36e2 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -961,6 +961,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NEAREST, "Nearest") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY, "Netplay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ALLOW_SLAVES, + "Allow Slave-Mode Clients") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_CHECK_FRAMES, "Netplay Check Frames") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_INPUT_LATENCY_FRAMES_MIN, @@ -991,6 +993,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PASSWORD, "Server Password") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PUBLIC_ANNOUNCE, "Publicly Announce Netplay") +MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REQUIRE_SLAVES, + "Disallow Non-Slave-Mode Clients") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS, "Netplay settings") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_START_AS_SPECTATOR, @@ -2638,6 +2642,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_NETPLAY_START_AS_SPECTATOR, "Whether to start netplay in spectator mode." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_ALLOW_SLAVES, + "Whether to allow connections in slave mode. Slave-mode clients require very little processing power on either side, but will suffer significantly from network latency." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_NETPLAY_REQUIRE_SLAVES, + "Whether to disallow connections not in slave mode. Not recommended except for very fast networks with very weak machines." + ) MSG_HASH( MENU_ENUM_SUBLABEL_NETPLAY_STATELESS_MODE, "Whether to run netplay in a mode not requiring save states. If set to true, a very fast network is required, but no rewinding is performed, so there will be no netplay jitter." diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 161ff63e57..ee18c7a642 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -190,6 +190,8 @@ default_sublabel_macro(action_bind_sublabel_netplay_tcp_udp_port, MENU_ default_sublabel_macro(action_bind_sublabel_netplay_password, MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD) default_sublabel_macro(action_bind_sublabel_netplay_spectate_password, MENU_ENUM_SUBLABEL_NETPLAY_SPECTATE_PASSWORD) default_sublabel_macro(action_bind_sublabel_netplay_start_as_spectator, MENU_ENUM_SUBLABEL_NETPLAY_START_AS_SPECTATOR) +default_sublabel_macro(action_bind_sublabel_netplay_allow_slaves, MENU_ENUM_SUBLABEL_NETPLAY_ALLOW_SLAVES) +default_sublabel_macro(action_bind_sublabel_netplay_require_slaves, MENU_ENUM_SUBLABEL_NETPLAY_REQUIRE_SLAVES) default_sublabel_macro(action_bind_sublabel_netplay_stateless_mode, MENU_ENUM_SUBLABEL_NETPLAY_STATELESS_MODE) default_sublabel_macro(action_bind_sublabel_netplay_check_frames, MENU_ENUM_SUBLABEL_NETPLAY_CHECK_FRAMES) default_sublabel_macro(action_bind_sublabel_netplay_nat_traversal, MENU_ENUM_SUBLABEL_NETPLAY_NAT_TRAVERSAL) @@ -750,6 +752,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_NETPLAY_START_AS_SPECTATOR: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_start_as_spectator); break; + case MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_allow_slaves); + break; + case MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_require_slaves); + break; case MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_stateless_mode); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 22ba165c55..499ba82533 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4851,6 +4851,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) MENU_ENUM_LABEL_NETPLAY_START_AS_SPECTATOR, PARSE_ONLY_BOOL, false) != -1) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES, + PARSE_ONLY_BOOL, false) != -1) + count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES, + PARSE_ONLY_BOOL, false) != -1) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE, PARSE_ONLY_BOOL, false) != -1) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 3df51e103a..d9140611de 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5674,6 +5674,7 @@ static bool setting_append_list( general_write_handler, general_read_handler); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_UINT( list, list_info, @@ -5688,6 +5689,7 @@ static bool setting_append_list( general_read_handler); menu_settings_list_current_add_range(list, list_info, 0, 65535, 1, true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_STRING( list, list_info, @@ -5732,6 +5734,38 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->netplay.allow_slaves, + MENU_ENUM_LABEL_NETPLAY_ALLOW_SLAVES, + MENU_ENUM_LABEL_VALUE_NETPLAY_ALLOW_SLAVES, + true, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + + CONFIG_BOOL( + list, list_info, + &settings->netplay.require_slaves, + MENU_ENUM_LABEL_NETPLAY_REQUIRE_SLAVES, + MENU_ENUM_LABEL_VALUE_NETPLAY_REQUIRE_SLAVES, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + CONFIG_BOOL( list, list_info, &settings->netplay.stateless_mode, @@ -5746,6 +5780,7 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_INT( list, list_info, @@ -5773,7 +5808,6 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_range(list, list_info, 0, 15, 1, true, true); - settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_INT( list, list_info, @@ -5787,14 +5821,13 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_range(list, list_info, 0, 15, 1, true, true); - settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_BOOL( list, list_info, &settings->netplay.nat_traversal, MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL, MENU_ENUM_LABEL_VALUE_NETPLAY_NAT_TRAVERSAL, - false, + true, MENU_ENUM_LABEL_VALUE_OFF, MENU_ENUM_LABEL_VALUE_ON, &group_info, @@ -5803,6 +5836,7 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); CONFIG_BOOL( list, list_info, @@ -5818,6 +5852,7 @@ static bool setting_append_list( general_write_handler, general_read_handler, SD_FLAG_NONE); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); END_SUB_GROUP(list, list_info, parent_group); diff --git a/msg_hash.h b/msg_hash.h index 52b421b503..d38c6789ea 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1020,6 +1020,8 @@ enum msg_hash_enums MENU_LABEL(NETPLAY_DELAY_FRAMES), MENU_LABEL(NETPLAY_PUBLIC_ANNOUNCE), MENU_LABEL(NETPLAY_START_AS_SPECTATOR), + MENU_LABEL(NETPLAY_ALLOW_SLAVES), + MENU_LABEL(NETPLAY_REQUIRE_SLAVES), MENU_LABEL(NETPLAY_STATELESS_MODE), MENU_LABEL(NETPLAY_CHECK_FRAMES), MENU_LABEL(NETPLAY_INPUT_LATENCY_FRAMES_MIN),