Make Discord update the activity if player count changes
This commit is contained in:
parent
5efd8565eb
commit
923d881588
|
@ -117,7 +117,7 @@ void discord_activity_update(bool hosting) {
|
|||
if (gCurActivity.party.size.current_size > 1) {
|
||||
strcpy(gCurActivity.state, "Playing!");
|
||||
} else if (hosting) {
|
||||
strcpy(gCurActivity.state, "Waiting for player...");
|
||||
strcpy(gCurActivity.state, "Waiting for players...");
|
||||
} else {
|
||||
strcpy(gCurActivity.state, "In-game.");
|
||||
gCurActivity.party.size.current_size = 1;
|
||||
|
@ -138,6 +138,21 @@ void discord_activity_update(bool hosting) {
|
|||
LOGFILE_INFO(LFT_DISCORD, "set activity");
|
||||
}
|
||||
|
||||
void discord_activity_update_check(void) {
|
||||
if (gNetworkType == NT_NONE) { return; }
|
||||
bool shouldUpdate = false;
|
||||
u8 connectedCount = network_player_connected_count();
|
||||
|
||||
if (connectedCount > 0 && connectedCount != gCurActivity.party.size.current_size) {
|
||||
gCurActivity.party.size.current_size = connectedCount;
|
||||
shouldUpdate = true;
|
||||
}
|
||||
|
||||
if (shouldUpdate) {
|
||||
discord_activity_update(gNetworkType == NT_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
struct IDiscordActivityEvents* discord_activity_initialize(void) {
|
||||
static struct IDiscordActivityEvents events = { 0 };
|
||||
events.on_activity_join = on_activity_join;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
extern struct DiscordActivity gCurActivity;
|
||||
|
||||
void discord_activity_update(bool hosting);
|
||||
void discord_activity_update_check(void);
|
||||
struct IDiscordActivityEvents* discord_activity_initialize(void);
|
||||
extern bool gActivityLock;
|
||||
|
||||
|
|
|
@ -138,6 +138,8 @@ static bool ns_discord_match_addr(void* addr1, void* addr2) {
|
|||
|
||||
static void ns_discord_update(void) {
|
||||
if (!gDiscordInitialized) { return; }
|
||||
|
||||
discord_activity_update_check();
|
||||
discord_lobby_update();
|
||||
DISCORD_REQUIRE(app.core->run_callbacks(app.core));
|
||||
discord_network_flush();
|
||||
|
|
Loading…
Reference in New Issue