Merge pull request #3721 from GregorR/netplay-overrides

Making netplay-related settings overrides behave consistently
This commit is contained in:
Twinaphex 2016-10-03 16:11:51 +02:00 committed by GitHub
commit 8963db204d
3 changed files with 12 additions and 6 deletions

View File

@ -1703,6 +1703,7 @@ static bool config_load_file(const char *path, bool set_defaults,
struct config_path_setting *path_settings = NULL; struct config_path_setting *path_settings = NULL;
char *override_username = NULL; char *override_username = NULL;
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
bool override_netplay_is_client = false;
char *override_netplay_ip_address = NULL; char *override_netplay_ip_address = NULL;
#endif #endif
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
@ -1768,6 +1769,8 @@ static bool config_load_file(const char *path, bool set_defaults,
override_username = strdup(settings->username); override_username = strdup(settings->username);
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL))
override_netplay_is_client = settings->netplay.is_client;
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL)) if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL))
override_netplay_ip_address = strdup(settings->netplay.server); override_netplay_ip_address = strdup(settings->netplay.server);
#endif #endif
@ -1810,10 +1813,11 @@ static bool config_load_file(const char *path, bool set_defaults,
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL))
{
CONFIG_GET_BOOL_BASE(conf, settings, netplay.is_spectate, CONFIG_GET_BOOL_BASE(conf, settings, netplay.is_spectate,
"netplay_spectator_mode_enable"); "netplay_spectator_mode_enable");
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL))
CONFIG_GET_BOOL_BASE(conf, settings, netplay.is_client, "netplay_mode"); CONFIG_GET_BOOL_BASE(conf, settings, netplay.is_client, "netplay_mode");
}
#endif #endif
#ifdef HAVE_NETWORKGAMEPAD #ifdef HAVE_NETWORKGAMEPAD
for (i = 0; i < MAX_USERS; i++) for (i = 0; i < MAX_USERS; i++)
@ -1956,6 +1960,8 @@ static bool config_load_file(const char *path, bool set_defaults,
} }
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL))
settings->netplay.is_client = override_netplay_is_client;
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL)) if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL))
{ {
strlcpy(settings->netplay.server, override_netplay_ip_address, sizeof(settings->netplay.server)); strlcpy(settings->netplay.server, override_netplay_ip_address, sizeof(settings->netplay.server));

View File

@ -1656,15 +1656,12 @@ void general_write_handler(void *data)
break; break;
case MENU_ENUM_LABEL_NETPLAY_MODE: case MENU_ENUM_LABEL_NETPLAY_MODE:
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (!settings->netplay.is_client)
*settings->netplay.server = '\0';
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
#endif #endif
break; break;
case MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE: case MENU_ENUM_LABEL_NETPLAY_SPECTATOR_MODE_ENABLE:
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
if (settings->netplay.is_spectate) retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
*settings->netplay.server = '\0';
#endif #endif
break; break;
case MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES: case MENU_ENUM_LABEL_NETPLAY_DELAY_FRAMES:

View File

@ -691,15 +691,18 @@ static void retroarch_parse_input(int argc, char *argv[])
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
case 'H': case 'H':
retroarch_override_setting_set( retroarch_override_setting_set(
RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL); RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE, NULL);
settings->netplay.is_client = false; settings->netplay.is_client = false;
break; break;
case 'C': case 'C':
retroarch_override_setting_set(
RARCH_OVERRIDE_SETTING_NETPLAY_MODE, NULL);
retroarch_override_setting_set( retroarch_override_setting_set(
RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL); RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS, NULL);
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE, NULL);
settings->netplay.is_client = true;
strlcpy(settings->netplay.server, optarg, strlcpy(settings->netplay.server, optarg,
sizeof(settings->netplay.server)); sizeof(settings->netplay.server));
break; break;