mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Make Discord update the activity if player count changes
This commit is contained in:
parent
de048928ce
commit
3f3936e874
3 changed files with 19 additions and 1 deletions
|
@ -117,7 +117,7 @@ void discord_activity_update(bool hosting) {
|
||||||
if (gCurActivity.party.size.current_size > 1) {
|
if (gCurActivity.party.size.current_size > 1) {
|
||||||
strcpy(gCurActivity.state, "Playing!");
|
strcpy(gCurActivity.state, "Playing!");
|
||||||
} else if (hosting) {
|
} else if (hosting) {
|
||||||
strcpy(gCurActivity.state, "Waiting for player...");
|
strcpy(gCurActivity.state, "Waiting for players...");
|
||||||
} else {
|
} else {
|
||||||
strcpy(gCurActivity.state, "In-game.");
|
strcpy(gCurActivity.state, "In-game.");
|
||||||
gCurActivity.party.size.current_size = 1;
|
gCurActivity.party.size.current_size = 1;
|
||||||
|
@ -138,6 +138,21 @@ void discord_activity_update(bool hosting) {
|
||||||
LOGFILE_INFO(LFT_DISCORD, "set activity");
|
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) {
|
struct IDiscordActivityEvents* discord_activity_initialize(void) {
|
||||||
static struct IDiscordActivityEvents events = { 0 };
|
static struct IDiscordActivityEvents events = { 0 };
|
||||||
events.on_activity_join = on_activity_join;
|
events.on_activity_join = on_activity_join;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
extern struct DiscordActivity gCurActivity;
|
extern struct DiscordActivity gCurActivity;
|
||||||
|
|
||||||
void discord_activity_update(bool hosting);
|
void discord_activity_update(bool hosting);
|
||||||
|
void discord_activity_update_check(void);
|
||||||
struct IDiscordActivityEvents* discord_activity_initialize(void);
|
struct IDiscordActivityEvents* discord_activity_initialize(void);
|
||||||
extern bool gActivityLock;
|
extern bool gActivityLock;
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ static bool ns_discord_match_addr(void* addr1, void* addr2) {
|
||||||
|
|
||||||
static void ns_discord_update(void) {
|
static void ns_discord_update(void) {
|
||||||
if (!gDiscordInitialized) { return; }
|
if (!gDiscordInitialized) { return; }
|
||||||
|
|
||||||
|
discord_activity_update_check();
|
||||||
discord_lobby_update();
|
discord_lobby_update();
|
||||||
DISCORD_REQUIRE(app.core->run_callbacks(app.core));
|
DISCORD_REQUIRE(app.core->run_callbacks(app.core));
|
||||||
discord_network_flush();
|
discord_network_flush();
|
||||||
|
|
Loading…
Reference in a new issue