Merge pull request #8151 from fr500/master

[discord] use discord username if available
This commit is contained in:
Twinaphex 2019-02-02 20:33:51 +01:00 committed by GitHub
commit f76547a96f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);