From 3f150fbe0548f0a9b29cf600e8f7027245be617a Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 27 Feb 2021 00:37:15 -0500 Subject: [PATCH] If the join secret isn't ready right away, wait for the next update instead of trying to loop for it again immediately I believe this may be the cause of the invite crash some people have noticed in master, but I'm not sure, needs tested. --- src/discord.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/discord.c b/src/discord.c index 4f72b714..db0ea344 100644 --- a/src/discord.c +++ b/src/discord.c @@ -341,15 +341,14 @@ static void DRPC_GotServerIP(UINT32 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); - DRPC_UpdatePresence(); } /*-------------------------------------------------- static const char *DRPC_GetServerIP(void) Retrieves the IP address of the server that you're - connected to. Will attempt to use curl for getting your - own IP address, if it's not yours. + connected to. Will attempt to use STUN for getting your + own IP address. --------------------------------------------------*/ static const char *DRPC_GetServerIP(void) { @@ -442,6 +441,19 @@ void DRPC_UpdatePresence(void) // Server info 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) { const char *join; @@ -455,24 +467,7 @@ void DRPC_UpdatePresence(void) 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 {