mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 04:59:57 -04:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user