Add RARCH_CTL_{USERNAME}

This commit is contained in:
twinaphex 2016-04-06 00:30:21 +02:00
parent c7a9182d59
commit 6e3416b990
4 changed files with 23 additions and 5 deletions

View File

@ -1768,7 +1768,7 @@ static bool config_load_file(const char *path, bool set_defaults)
config_get_path(conf, "joypad_autoconfig_dir",
settings->input.autoconfig_dir, sizeof(settings->input.autoconfig_dir));
if (!global->has_set.username)
if (!rarch_ctl(RARCH_CTL_HAS_SET_USERNAME, NULL))
config_get_path(conf, "netplay_nickname", settings->username, sizeof(settings->username));
CONFIG_GET_INT_BASE(conf, settings, user_language, "user_language");
#ifdef HAVE_NETPLAY

View File

@ -689,7 +689,9 @@ static void parse_input(int argc, char *argv[])
global->has_set.verbosity = false;
global->has_set.netplay_mode = false;
global->has_set.username = false;
rarch_ctl(RARCH_CTL_USERNAME_UNSET, NULL);
global->has_set.netplay_ip_address = false;
global->has_set.netplay_delay_frames = false;
global->has_set.netplay_ip_port = false;
@ -945,7 +947,7 @@ static void parse_input(int argc, char *argv[])
#endif
case RA_OPT_NICK:
global->has_set.username = true;
rarch_ctl(RARCH_CTL_USERNAME_SET, NULL);
strlcpy(settings->username, optarg,
sizeof(settings->username));
break;
@ -1364,6 +1366,7 @@ static void rarch_main_deinit(void)
bool rarch_ctl(enum rarch_ctl_state state, void *data)
{
static bool has_set_username = false;
static bool rarch_is_inited = false;
static bool rarch_error_on_init = false;
static bool rarch_block_config_read = false;
@ -1391,6 +1394,14 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
return (current_core_type == CORE_TYPE_PLAIN);
case RARCH_CTL_IS_DUMMY_CORE:
return (current_core_type == CORE_TYPE_DUMMY);
case RARCH_CTL_USERNAME_SET:
has_set_username = true;
break;
case RARCH_CTL_USERNAME_UNSET:
has_set_username = false;
break;
case RARCH_CTL_HAS_SET_USERNAME:
return has_set_username;
case RARCH_CTL_IS_INITED:
return rarch_is_inited;
case RARCH_CTL_UNSET_INITED:
@ -1403,6 +1414,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
{
int flags = DRIVERS_CMD_ALL;
has_set_username = false;
rarch_is_inited = false;
rarch_error_on_init = false;
rarch_block_config_read = false;

View File

@ -129,6 +129,12 @@ enum rarch_ctl_state
RARCH_CTL_UNSET_ERROR_ON_INIT,
RARCH_CTL_HAS_SET_USERNAME,
RARCH_CTL_USERNAME_SET,
RARCH_CTL_USERNAME_UNSET,
RARCH_CTL_IS_ERROR_ON_INIT
};

View File

@ -186,13 +186,13 @@ typedef struct global
{
bool save_path;
bool state_path;
bool verbosity;
bool libretro_device[MAX_USERS];
bool libretro;
bool libretro_directory;
bool verbosity;
bool netplay_mode;
bool username;
bool netplay_ip_address;
bool netplay_delay_frames;
bool netplay_ip_port;