diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9c3555d7e..f695023d0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1998,11 +1998,6 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) } else SetPlayerSkinByNum(playernum, skin); - -#ifdef HAVE_DISCORDRPC - if (playernum == consoleplayer) - DRPC_UpdatePresence(); -#endif } void SendWeaponPref(void) diff --git a/src/discord.c b/src/discord.c index 207a249a6..f94cd574d 100644 --- a/src/discord.c +++ b/src/discord.c @@ -49,6 +49,27 @@ discordRequest_t *discordRequestList = NULL; static char self_ip[IP_SIZE+1]; +/*-------------------------------------------------- + * const char *DRPC_HideUsername(const char *input) + * + * See header file for description. + * --------------------------------------------------*/ +const char *DRPC_HideUsername(const char *input) +{ + static char buffer[5]; + int i; + + buffer[0] = input[0]; + + for (i = 1; i < 4; ++i) + { + buffer[i] = '.'; + } + + buffer[4] = '\0'; + return buffer; +} + boolean drpc_init = false; /*-------------------------------------------------- @@ -105,7 +126,7 @@ static void DRPC_HandleReady(const DiscordUser *user) } else { - CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId); + CONS_Printf("Discord: connected to %s (%s)\n", user->username, user->userId); } } @@ -241,8 +262,10 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser) newRequest->username = Z_Calloc(344, PU_STATIC, NULL); snprintf(newRequest->username, 344, "%s", requestUser->username); +#if 0 newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL); snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator); +#endif newRequest->userID = Z_Calloc(32, PU_STATIC, NULL); snprintf(newRequest->userID, 32, "%s", requestUser->userId); @@ -308,6 +331,9 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest) } Z_Free(removeRequest->username); +#if 0 + Z_Free(removeRequest->discriminator); +#endif Z_Free(removeRequest->userID); Z_Free(removeRequest); } diff --git a/src/discord.h b/src/discord.h index 131dc05f9..fa37c306b 100644 --- a/src/discord.h +++ b/src/discord.h @@ -29,7 +29,9 @@ extern struct discordInfo_s { typedef struct discordRequest_s { char *username; // Discord user name. +#if 0 // Good night, sweet prince... char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar. +#endif char *userID; // The ID of the Discord user, gets used with Discord_Respond() // HAHAHA, no. @@ -44,6 +46,15 @@ typedef struct discordRequest_s { extern discordRequest_t *discordRequestList; +/*-------------------------------------------------- + * const char *DRPC_HideUsername(const char *input); + * + * Handle usernames while cv_discordstreamer is activated. + * (The loss of discriminators is still a dumbass regression + * that I will never forgive the Discord developers for.) + * --------------------------------------------------*/ + +const char *DRPC_HideUsername(const char *input); /*-------------------------------------------------- void DRPC_RemoveRequest(void); diff --git a/src/m_menu.c b/src/m_menu.c index 0588ccf64..3d8857b9a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10332,9 +10332,9 @@ static const char *M_GetDiscordName(discordRequest_t *r) return ""; if (cv_discordstreamer.value) - return r->username; + return DRPC_HideUsername(r->username); - return va("%s#%s", r->username, r->discriminator); + return r->username; } // (this goes in k_hud.c when merged into v2) diff --git a/src/r_skins.c b/src/r_skins.c index f0fbfcfd1..9d289f936 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -35,6 +35,8 @@ CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; +#include "discord.h" + INT32 numskins = 0; INT32 numallskins = 0; INT32 numlocalskins = 0; @@ -328,8 +330,14 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) if (player->mo) P_SetScale(player->mo, player->mo->scale); + // for replays: We have changed our skin mid-game; let the game know so it can do the same in the replay! demo_extradata[playernum] |= DXD_SKIN; +#ifdef HAVE_DISCORDRPC + if (player - players == consoleplayer) + DRPC_UpdatePresence(); +#endif + return; }