Make announcing netplay on the public lobby optional.

This commit is contained in:
Gregor Richards 2017-02-06 13:45:58 -05:00
parent 593d1ff7b5
commit aa77d688ec
11 changed files with 60 additions and 4 deletions

View File

@ -815,6 +815,9 @@ static const bool pause_nonactive = true;
* It is measured in seconds. A value of 0 disables autosave. */ * It is measured in seconds. A value of 0 disables autosave. */
static const unsigned autosave_interval = 0; static const unsigned autosave_interval = 0;
/* Publicly announce netplay */
static const bool netplay_public_announce = true;
/* Netplay without savestates/rewind */ /* Netplay without savestates/rewind */
static const bool netplay_stateless_mode = false; static const bool netplay_stateless_mode = false;

View File

@ -728,6 +728,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("all_users_control_menu", &settings->input.all_users_control_menu, true, all_users_control_menu, false); SETTING_BOOL("all_users_control_menu", &settings->input.all_users_control_menu, true, all_users_control_menu, false);
SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->input.menu_swap_ok_cancel_buttons, true, menu_swap_ok_cancel_buttons, false); SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->input.menu_swap_ok_cancel_buttons, true, menu_swap_ok_cancel_buttons, false);
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
SETTING_BOOL("netplay_public_announce", &settings->netplay.public_announce, true, netplay_public_announce, false);
SETTING_BOOL("netplay_stateless_mode", &settings->netplay.stateless_mode, false, netplay_stateless_mode, 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); SETTING_BOOL("netplay_client_swap_input", &settings->netplay.swap_input, true, netplay_client_swap_input, false);
#endif #endif

View File

@ -403,6 +403,7 @@ typedef struct settings
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
struct struct
{ {
bool public_announce;
char server[255]; char server[255];
unsigned port; unsigned port;
bool stateless_mode; bool stateless_mode;

View File

@ -611,6 +611,8 @@ MSG_HASH(MENU_ENUM_LABEL_NETPLAY_PASSWORD,
"netplay_password") "netplay_password")
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SETTINGS,
"menu_netplay_settings") "menu_netplay_settings")
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE,
"netplay_public_announce")
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD, MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD,
"netplay_spectate_password") "netplay_spectate_password")
MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE, MSG_HASH(MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE,

View File

@ -1535,6 +1535,13 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) {
"Increasing this value will increase \n" "Increasing this value will increase \n"
"performance, but introduce more latency."); "performance, but introduce more latency.");
break; break;
case MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE:
snprintf(s, len,
"Whether to announce netplay games publicly. \n"
" \n"
"If set to false, clients must manually connect \n"
"rather than using the public lobby.");
break;
case MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE: case MENU_ENUM_LABEL_NETPLAY_STATELESS_MODE:
snprintf(s, len, snprintf(s, len,
"Whether to run netplay in a mode not requiring\n" "Whether to run netplay in a mode not requiring\n"

View File

@ -990,6 +990,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_NICKNAME,
"Username") "Username")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PASSWORD, MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PASSWORD,
"Server Password") "Server Password")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_PUBLIC_ANNOUNCE,
"Publicly Announce Netplay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS, MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_SETTINGS,
"Netplay settings") "Netplay settings")
MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_STATELESS_MODE, MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_STATELESS_MODE,
@ -2619,6 +2621,10 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD, MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD,
"The password for connecting to the netplay host. Used only in host mode." "The password for connecting to the netplay host. Used only in host mode."
) )
MSG_HASH(
MENU_ENUM_SUBLABEL_NETPLAY_PUBLIC_ANNOUNCE,
"Whether to announce netplay games publicly. If unset, clients must manually connect rather than using the public lobby."
)
MSG_HASH( MSG_HASH(
MENU_ENUM_SUBLABEL_NETPLAY_SPECTATE_PASSWORD, MENU_ENUM_SUBLABEL_NETPLAY_SPECTATE_PASSWORD,
"The password for connecting to the netplay host with only spectator privileges. Used only in host mode." "The password for connecting to the netplay host with only spectator privileges. Used only in host mode."

View File

@ -184,6 +184,7 @@ default_sublabel_macro(action_bind_sublabel_overlay_opacity, MENU_
default_sublabel_macro(action_bind_sublabel_overlay_scale, MENU_ENUM_SUBLABEL_OVERLAY_SCALE) default_sublabel_macro(action_bind_sublabel_overlay_scale, MENU_ENUM_SUBLABEL_OVERLAY_SCALE)
default_sublabel_macro(action_bind_sublabel_overlay_enable, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ENABLE) default_sublabel_macro(action_bind_sublabel_overlay_enable, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ENABLE)
default_sublabel_macro(action_bind_sublabel_overlay_preset, MENU_ENUM_SUBLABEL_OVERLAY_PRESET) default_sublabel_macro(action_bind_sublabel_overlay_preset, MENU_ENUM_SUBLABEL_OVERLAY_PRESET)
default_sublabel_macro(action_bind_sublabel_netplay_public_announce, MENU_ENUM_SUBLABEL_NETPLAY_PUBLIC_ANNOUNCE)
default_sublabel_macro(action_bind_sublabel_netplay_ip_address, MENU_ENUM_SUBLABEL_NETPLAY_IP_ADDRESS) default_sublabel_macro(action_bind_sublabel_netplay_ip_address, MENU_ENUM_SUBLABEL_NETPLAY_IP_ADDRESS)
default_sublabel_macro(action_bind_sublabel_netplay_tcp_udp_port, MENU_ENUM_SUBLABEL_NETPLAY_TCP_UDP_PORT) default_sublabel_macro(action_bind_sublabel_netplay_tcp_udp_port, MENU_ENUM_SUBLABEL_NETPLAY_TCP_UDP_PORT)
default_sublabel_macro(action_bind_sublabel_netplay_password, MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD) default_sublabel_macro(action_bind_sublabel_netplay_password, MENU_ENUM_SUBLABEL_NETPLAY_PASSWORD)
@ -736,6 +737,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_STDIN_CMD_ENABLE: case MENU_ENUM_LABEL_STDIN_CMD_ENABLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_stdin_cmd_enable); BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_stdin_cmd_enable);
break; break;
case MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_public_announce);
break;
case MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL: case MENU_ENUM_LABEL_NETPLAY_NAT_TRAVERSAL:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_nat_traversal); BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_nat_traversal);
break; break;

View File

@ -4793,6 +4793,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
unsigned user; unsigned user;
unsigned count = 0; unsigned count = 0;
if (menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE,
PARSE_ONLY_BOOL, false) != -1)
count++;
if (menu_displaylist_parse_settings_enum(menu, info, if (menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS,
PARSE_ONLY_STRING, false) != -1) PARSE_ONLY_STRING, false) != -1)

View File

@ -5590,6 +5590,21 @@ static bool setting_append_list(
#if defined(HAVE_NETWORK_CMD) #if defined(HAVE_NETWORK_CMD)
unsigned user; unsigned user;
#endif #endif
CONFIG_BOOL(
list, list_info,
&settings->netplay.public_announce,
MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE,
MENU_ENUM_LABEL_VALUE_NETPLAY_PUBLIC_ANNOUNCE,
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);
CONFIG_STRING( CONFIG_STRING(
list, list_info, list, list_info,
settings->netplay.server, settings->netplay.server,

View File

@ -1017,6 +1017,7 @@ enum msg_hash_enums
MENU_LABEL(BLUETOOTH_ENABLE), MENU_LABEL(BLUETOOTH_ENABLE),
MENU_LABEL(NETPLAY_CLIENT_SWAP_INPUT), MENU_LABEL(NETPLAY_CLIENT_SWAP_INPUT),
MENU_LABEL(NETPLAY_DELAY_FRAMES), MENU_LABEL(NETPLAY_DELAY_FRAMES),
MENU_LABEL(NETPLAY_PUBLIC_ANNOUNCE),
MENU_LABEL(NETPLAY_STATELESS_MODE), MENU_LABEL(NETPLAY_STATELESS_MODE),
MENU_LABEL(NETPLAY_CHECK_FRAMES), MENU_LABEL(NETPLAY_CHECK_FRAMES),
MENU_LABEL(NETPLAY_INPUT_LATENCY_FRAMES_MIN), MENU_LABEL(NETPLAY_INPUT_LATENCY_FRAMES_MIN),

View File

@ -652,11 +652,22 @@ static void netplay_frontend_paused(netplay_t *netplay, bool paused)
bool netplay_pre_frame(netplay_t *netplay) bool netplay_pre_frame(netplay_t *netplay)
{ {
bool sync_stalled; bool sync_stalled;
reannounce ++; settings_t *settings = config_get_ptr();
if (netplay->is_server && (reannounce % 3600 == 0))
netplay_announce();
retro_assert(netplay); retro_assert(netplay);
if (settings->netplay.public_announce)
{
reannounce ++;
if (netplay->is_server && (reannounce % 3600 == 0))
netplay_announce();
}
else
{
/* Make sure that if announcement is turned on mid-game, it gets announced */
reannounce = -1;
}
/* FIXME: This is an ugly way to learn we're not paused anymore */ /* FIXME: This is an ugly way to learn we're not paused anymore */
if (netplay->local_paused) if (netplay->local_paused)
netplay_frontend_paused(netplay, false); netplay_frontend_paused(netplay, false);
@ -1027,7 +1038,8 @@ bool init_netplay(void *direct_host, const char *server, unsigned port)
msg_hash_to_str(MSG_WAITING_FOR_CLIENT), msg_hash_to_str(MSG_WAITING_FOR_CLIENT),
0, 180, false); 0, 180, false);
netplay_announce(); if (settings->netplay.public_announce)
netplay_announce();
} }
netplay_data = (netplay_t*)netplay_new( netplay_data = (netplay_t*)netplay_new(