From ffe13e1d52951ba49988e707a72e086fa27d8077 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Sun, 8 Nov 2026 09:22:03 -0500 Subject: [PATCH] Reconnect Discord's status only when its app id changes. Every settings change (a slider step, F10, a cheat) closed the connection and made a new one, so the status disappeared and came back each time, and a held slider reconnected twice a second, enough to hit Discord's rate limit. A new app id reconnects; a new image is resent on the same connection; anything else changes nothing. Co-Authored-By: Claude Opus 5.5 --- runtime/discord_rpc.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/runtime/discord_rpc.c b/runtime/discord_rpc.c index 43268099..99dfa093 100644 --- a/runtime/discord_rpc.c +++ b/runtime/discord_rpc.c @@ -202,10 +202,21 @@ static void discord_main(void *arg) { unsigned v = cfg_version(); if (v != seen) { // the settings changed (the menu writes them): pick the new ones up at once seen = v; + // any setting bumps the version (a slider step, a cheat): only a new app id needs a new handshake, and + // a new image only a resend; reconnecting on every change made the status blink and could hit Discord's + // rate limit while a slider was held + char was_id[APP_ID_CAP], was_image[IMAGE_KEY_CAP]; + memcpy(was_id, app_id, sizeof was_id); + memcpy(was_image, image, sizeof was_image); read_setting("NX2NAVI_DISCORD_APP_ID", app_id, sizeof app_id, valid_app_id); read_setting("NX2NAVI_DISCORD_IMAGE", image, sizeof image, valid_image_key); - if (ipc) plat_ipc_close(ipc), ipc = NULL; // the new app id needs a new handshake; the image is resent - said_no_client = said_no_app = 0; + if (strcmp(was_id, app_id)) { + if (ipc) plat_ipc_close(ipc), ipc = NULL; + retry_at = 0; + said_no_client = said_no_app = 0; + } else if (strcmp(was_image, image)) { + send_at = 0; + } } if (!cfg_bool("NX2NAVI_DISCORD_RPC")) { if (ipc) plat_ipc_close(ipc), ipc = NULL;