Fix discord lobby joining

This commit is contained in:
MysterD 2023-04-16 20:48:19 -07:00
parent 5337f206f0
commit ee0e1dce44
3 changed files with 10 additions and 8 deletions

Binary file not shown.

View File

@ -56,15 +56,16 @@ static void register_launch_command(void) {
} }
GetModuleFileName(hModule, cmd, sizeof(cmd)); GetModuleFileName(hModule, cmd, sizeof(cmd));
#else #else
char path[MAX_LAUNCH_CMD] = { 0 }; char pidpath[MAX_LAUNCH_CMD] = { 0 };
snprintf(path, MAX_LAUNCH_CMD - 1, "/proc/%d/exe", getpid()); char fullpath[MAX_LAUNCH_CMD] = { 0 };
rc = readlink(path, cmd, MAX_LAUNCH_CMD - 1); snprintf(pidpath, MAX_LAUNCH_CMD - 1, "/proc/%d/exe", getpid());
rc = readlink(pidpath, fullpath, MAX_LAUNCH_CMD - 1);
if (rc <= 0) { if (rc <= 0) {
LOG_ERROR("unable to retrieve absolute path! rc = %d", rc); LOG_ERROR("unable to retrieve absolute path! rc = %d", rc);
return; return;
} }
snprintf(cmd, MAX_LAUNCH_CMD, "%s", fullpath);
#endif #endif
strncat(cmd, " --discord 1", MAX_LAUNCH_CMD - 1);
rc = app.activities->register_command(app.activities, cmd); rc = app.activities->register_command(app.activities, cmd);
if (rc != DiscordResult_Ok) { if (rc != DiscordResult_Ok) {
LOG_ERROR("register command failed %d", rc); LOG_ERROR("register command failed %d", rc);
@ -139,9 +140,6 @@ static void discord_initialize(void) {
app.application = app.core->get_application_manager(app.core); app.application = app.core->get_application_manager(app.core);
} }
// register launch params
register_launch_command();
// get oath2 token // get oath2 token
app.application->get_oauth2_token(app.application, NULL, get_oauth2_token_callback); app.application->get_oauth2_token(app.application, NULL, get_oauth2_token_callback);
@ -149,6 +147,9 @@ static void discord_initialize(void) {
discord_activity_update(); discord_activity_update();
sDiscordFailed = false; sDiscordFailed = false;
// register launch params
register_launch_command();
LOG_INFO("initialized"); LOG_INFO("initialized");
} }

View File

@ -29,7 +29,8 @@ static void on_activity_join(UNUSED void* data, const char* secret) {
#ifdef COOPNET #ifdef COOPNET
// extract lobby ID // extract lobby ID
token = strtok(NULL, ":"); token = strtok(NULL, ":");
u64 lobbyId = atoi(token); char* end;
u64 lobbyId = strtoll(token, &end, 10);
// extract lobby password // extract lobby password
token = strtok(NULL, ":"); token = strtok(NULL, ":");