[discord] use discord username if available

This commit is contained in:
radius 2019-02-02 13:03:23 -05:00
parent b4bf7c168d
commit 79d280e9c3
2 changed files with 15 additions and 3 deletions

View File

@ -76,12 +76,16 @@ DiscordRichPresence discord_presence;
char* discord_get_own_username(void)
{
return user_name;
if (discord_is_ready)
return user_name;
return NULL;
}
char* discord_get_own_avatar(void)
{
return user_avatar;
if (discord_is_ready)
return user_avatar;
return NULL;
}
bool discord_avatar_is_ready(void)

View File

@ -893,7 +893,12 @@ static void netplay_announce(void)
netplay_get_architecture(frontend_architecture, sizeof(frontend_architecture));
net_http_urlencode(&username, settings->paths.username);
if (!string_is_empty(settings->paths.username))
net_http_urlencode(&username, settings->paths.username);
#ifdef HAVE_DISCORD
else
net_http_urlencode(&username, discord_get_own_username());
#endif
net_http_urlencode(&corename, system->library_name);
net_http_urlencode(&coreversion, system->library_version);
net_http_urlencode(&frontend_ident, frontend_architecture);
@ -1492,6 +1497,9 @@ bool init_netplay(void *direct_host, const char *server, unsigned port)
settings->ints.netplay_check_frames,
&cbs,
settings->bools.netplay_nat_traversal,
#ifdef HAVE_DISCORD
string_is_empty(settings->paths.username) ? discord_get_own_username() :
#endif
settings->paths.username,
quirks);