mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
[discord] populate data correctly
This commit is contained in:
parent
4d0729187f
commit
fed74b9e70
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -15,7 +15,10 @@
|
|||||||
"*.rh": "c",
|
"*.rh": "c",
|
||||||
"array": "c",
|
"array": "c",
|
||||||
"file_stream.h": "c",
|
"file_stream.h": "c",
|
||||||
"driver.h": "c"
|
"driver.h": "c",
|
||||||
|
"iosfwd": "c",
|
||||||
|
"xlocbuf": "c",
|
||||||
|
"xmemory0": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.dimInactiveRegions": false,
|
"C_Cpp.dimInactiveRegions": false,
|
||||||
}
|
}
|
@ -28,6 +28,7 @@
|
|||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
#include "../../network/netplay/netplay.h"
|
#include "../../network/netplay/netplay.h"
|
||||||
#include "../../network/netplay/netplay_discovery.h"
|
#include "../../network/netplay/netplay_discovery.h"
|
||||||
|
#include "../../tasks/tasks_internal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
@ -44,6 +45,8 @@ static int64_t ellapsed_time = 0;
|
|||||||
static bool discord_ready = false;
|
static bool discord_ready = false;
|
||||||
static unsigned discord_status = 0;
|
static unsigned discord_status = 0;
|
||||||
|
|
||||||
|
struct netplay_room *room;
|
||||||
|
|
||||||
DiscordRichPresence discord_presence;
|
DiscordRichPresence discord_presence;
|
||||||
|
|
||||||
static void handle_discord_ready(const DiscordUser* connectedUser)
|
static void handle_discord_ready(const DiscordUser* connectedUser)
|
||||||
@ -67,6 +70,21 @@ static void handle_discord_error(int errcode, const char* message)
|
|||||||
static void handle_discord_join(const char* secret)
|
static void handle_discord_join(const char* secret)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[Discord] join (%s)\n", secret);
|
RARCH_LOG("[Discord] join (%s)\n", secret);
|
||||||
|
static struct string_list *list = NULL;
|
||||||
|
list = string_split(secret, "|");
|
||||||
|
|
||||||
|
char tmp_hostname[32];
|
||||||
|
snprintf(tmp_hostname,
|
||||||
|
sizeof(tmp_hostname),
|
||||||
|
"%s|%s", list->elems[0].data, list->elems[1].data);
|
||||||
|
|
||||||
|
if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL))
|
||||||
|
deinit_netplay();
|
||||||
|
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
|
||||||
|
|
||||||
|
task_push_netplay_crc_scan(atoi(list->elems[3].data),
|
||||||
|
list->elems[2].data,
|
||||||
|
tmp_hostname, list->elems[4].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_discord_spectate(const char* secret)
|
static void handle_discord_spectate(const char* secret)
|
||||||
@ -155,9 +173,26 @@ void discord_update(enum discord_presence presence)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DISCORD_PRESENCE_NETPLAY_HOSTING:
|
case DISCORD_PRESENCE_NETPLAY_HOSTING:
|
||||||
discord_presence.joinSecret = "JOINJOINJOIN";
|
room = netplay_get_host_room();
|
||||||
|
if (room->id == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RARCH_LOG("[Discord] netplay room details: id=%d, nick=%s IP=%s port=%d\n",
|
||||||
|
room->id, room->nickname,
|
||||||
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
||||||
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port);
|
||||||
|
|
||||||
|
char party_id[128];
|
||||||
|
snprintf(party_id, sizeof(party_id), "%d|%s", room->id, room->nickname);
|
||||||
|
char join_secret[128];
|
||||||
|
snprintf(join_secret, sizeof(join_secret), "%s|%d|%s|%u|%s",
|
||||||
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_address : room->address,
|
||||||
|
room->host_method == NETPLAY_HOST_METHOD_MITM ? room->mitm_port : room->port,
|
||||||
|
room->gamename, room->gamecrc, room->corename);
|
||||||
|
RARCH_LOG("%s\n", join_secret);
|
||||||
|
discord_presence.joinSecret = strdup(join_secret);
|
||||||
discord_presence.spectateSecret = "SPECSPECSPEC";
|
discord_presence.spectateSecret = "SPECSPECSPEC";
|
||||||
discord_presence.partyId = "RADIUS";
|
discord_presence.partyId = party_id;
|
||||||
discord_presence.partyMax = 0;
|
discord_presence.partyMax = 0;
|
||||||
discord_presence.partySize = 0;
|
discord_presence.partySize = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -640,6 +640,15 @@ static void netplay_announce_cb(void *task_data, void *user_data, const char *er
|
|||||||
{
|
{
|
||||||
RARCH_LOG("[netplay] announcing netplay game... \n");
|
RARCH_LOG("[netplay] announcing netplay game... \n");
|
||||||
|
|
||||||
|
#ifdef HAVE_DISCORD
|
||||||
|
if (discord_is_inited)
|
||||||
|
{
|
||||||
|
discord_userdata_t userdata;
|
||||||
|
userdata.status = DISCORD_PRESENCE_NETPLAY_HOSTING;
|
||||||
|
command_event(CMD_EVENT_DISCORD_UPDATE, &userdata);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (task_data)
|
if (task_data)
|
||||||
{
|
{
|
||||||
unsigned i, ip_len, port_len;
|
unsigned i, ip_len, port_len;
|
||||||
@ -1498,14 +1507,6 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
|||||||
case RARCH_NETPLAY_CTL_ENABLE_SERVER:
|
case RARCH_NETPLAY_CTL_ENABLE_SERVER:
|
||||||
netplay_enabled = true;
|
netplay_enabled = true;
|
||||||
netplay_is_client = false;
|
netplay_is_client = false;
|
||||||
#ifdef HAVE_DISCORD
|
|
||||||
if (discord_is_inited)
|
|
||||||
{
|
|
||||||
discord_userdata_t userdata;
|
|
||||||
userdata.status = DISCORD_PRESENCE_NETPLAY_HOSTING;
|
|
||||||
command_event(CMD_EVENT_DISCORD_UPDATE, &userdata);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
case RARCH_NETPLAY_CTL_ENABLE_CLIENT:
|
case RARCH_NETPLAY_CTL_ENABLE_CLIENT:
|
||||||
@ -1541,6 +1542,7 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data)
|
|||||||
case RARCH_NETPLAY_CTL_IS_CONNECTED:
|
case RARCH_NETPLAY_CTL_IS_CONNECTED:
|
||||||
ret = false;
|
ret = false;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user