From e0d0a3a74ed4b73ef41a19751bfb09f8d4e00376 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 22 Aug 2020 00:01:56 -0400 Subject: [PATCH] Ignore any duplicate requests You will still get a message for them, so if they're being annoying you will want to block them anyway, but at least it won't clog up the game. --- src/discord.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/discord.c b/src/discord.c index 82b5ed348..98188990c 100644 --- a/src/discord.c +++ b/src/discord.c @@ -159,10 +159,10 @@ static void DRPC_HandleJoin(const char *secret) static void DRPC_HandleJoinRequest(const DiscordUser *requestUser) { discordRequest_t *append = discordRequestList; - discordRequest_t *newRequest = Z_Calloc(sizeof (discordRequest_t), PU_STATIC, NULL); + discordRequest_t *newRequest = Z_Calloc(sizeof(discordRequest_t), PU_STATIC, NULL); - // Discord requests exprie after 30 seconds, give 1 second of lee-way for connection discrepancies - newRequest->timer = 29*TICRATE; + // Discord requests exprie after 30 seconds + newRequest->timer = (30*TICRATE)-1; newRequest->username = Z_Calloc(344+1+8, PU_STATIC, NULL); snprintf(newRequest->username, 344+1+8, "%s#%s", @@ -179,6 +179,14 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser) while (append != NULL) { + // CHECK FOR DUPES!! Ignore any that already exist from the same user. + if (!strcmp(newRequest->userID, append->userID)) + { + Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE); + DRPC_RemoveRequest(newRequest); + return; + } + prev = append; append = append->next; }