Merge branch 'discord-invite-fix' into 'master'

DRPC: Wait for join secret to be ready

See merge request KartKrew/Kart-Public!248
This commit is contained in:
Sal 2021-04-07 17:47:59 -04:00
commit 6e33b5281d

View file

@ -341,15 +341,14 @@ static void DRPC_GotServerIP(UINT32 address)
{ {
const unsigned char * p = (const unsigned char *)&address; const unsigned char * p = (const unsigned char *)&address;
sprintf(self_ip, "%u.%u.%u.%u:%u", p[0], p[1], p[2], p[3], current_port); sprintf(self_ip, "%u.%u.%u.%u:%u", p[0], p[1], p[2], p[3], current_port);
DRPC_UpdatePresence();
} }
/*-------------------------------------------------- /*--------------------------------------------------
static const char *DRPC_GetServerIP(void) static const char *DRPC_GetServerIP(void)
Retrieves the IP address of the server that you're Retrieves the IP address of the server that you're
connected to. Will attempt to use curl for getting your connected to. Will attempt to use STUN for getting your
own IP address, if it's not yours. own IP address.
--------------------------------------------------*/ --------------------------------------------------*/
static const char *DRPC_GetServerIP(void) static const char *DRPC_GetServerIP(void)
{ {
@ -442,6 +441,19 @@ void DRPC_UpdatePresence(void)
// Server info // Server info
if (netgame) if (netgame)
{ {
if (cv_advertise.value)
{
discordPresence.state = "Public";
}
else
{
discordPresence.state = "Private";
}
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
discordPresence.partySize = D_NumPlayers(); // Players in server
discordPresence.partyMax = discordInfo.maxPlayers; // Max players
if (DRPC_InvitesAreAllowed() == true) if (DRPC_InvitesAreAllowed() == true)
{ {
const char *join; const char *join;
@ -455,25 +467,8 @@ void DRPC_UpdatePresence(void)
joinSecretSet = true; joinSecretSet = true;
} }
else
{
return;
} }
} }
if (cv_advertise.value)
{
discordPresence.state = "Public";
}
else
{
discordPresence.state = "Private";
}
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
discordPresence.partySize = D_NumPlayers(); // Players in server
discordPresence.partyMax = discordInfo.maxPlayers; // Max players
}
else else
{ {
// Reset discord info if you're not in a place that uses it! // Reset discord info if you're not in a place that uses it!