Adding settings to allow/require connections in slave mode.

This commit is contained in:
Gregor Richards 2017-02-23 21:33:44 -05:00
parent 3ff9a43b7d
commit a3e3b3e790
10 changed files with 97 additions and 3 deletions

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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,

View File

@ -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"

View File

@ -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."

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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),