From d22ce632e5b63dbf11b1fc2772aea0121c607fb1 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 3 Mar 2019 13:09:21 -0500 Subject: [PATCH] fix discord launch arguments not working if RA was started from CWD or similar scenarios --- discord/discord.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/discord/discord.c b/discord/discord.c index 94d03ba3d9..8e8f339709 100644 --- a/discord/discord.c +++ b/discord/discord.c @@ -448,6 +448,7 @@ void discord_update(enum discord_presence presence) void discord_init(void) { + char full_path[PATH_MAX_LENGTH]; char command[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); @@ -467,11 +468,17 @@ void discord_init(void) Discord_Initialize(settings->arrays.discord_app_id, &handlers, 0, NULL); #ifdef _WIN32 - strlcpy(command, get_retroarch_launch_arguments(), sizeof(command)); + GetModuleFileNameA(NULL, full_path, sizeof(full_path)); + if (strstr(get_retroarch_launch_arguments(), full_path)) + strlcpy(command, get_retroarch_launch_arguments(), sizeof(command)); + else + { + path_basedir(full_path); + snprintf(command, sizeof(command), "%s%s", full_path, get_retroarch_launch_arguments()); + } #else snprintf(command, sizeof(command), "sh -c %s", get_retroarch_launch_arguments()); #endif - RARCH_LOG("[discord] registering startup command: %s\n", command); Discord_Register(settings->arrays.discord_app_id, command); discord_ready = true;