Display time elasped/time limit

This commit is contained in:
Sally Coolatta 2020-08-17 02:05:16 -04:00
parent d709e9782d
commit 8d386fba66
2 changed files with 33 additions and 19 deletions

View file

@ -192,25 +192,28 @@ void DRPC_UpdatePresence(void)
case 33: discordPresence.state = "Standard"; break;
case 28: discordPresence.state = "Casual"; break;
case 38: discordPresence.state = "Custom Gametypes"; break;
//case ??: discordPresence.state = "OLDC"; break; // If I remembered this one's room ID, I would add it :V
case 31: discordPresence.state = "OLDC"; break;
default: discordPresence.state = "Unknown Room"; break; // HOW
}
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
discordPresence.partySize = D_NumPlayers(); // Players in server
discordPresence.partyMax = cv_maxplayers.value; // Max players (TODO: use another variable to hold this, so maxplayers doesn't have to be a netvar!)
// Grab the host's IP for joining.
if ((join = DRPC_GetServerIP()) != NULL)
discordPresence.joinSecret = join;
discordPresence.partySize = D_NumPlayers(); // Players in server
discordPresence.partyMax = cv_maxplayers.value; // Max players (TODO: use another variable to hold this, so maxplayers doesn't have to be a netvar!)
}
else if (Playing())
discordPresence.state = "Offline";
else if (demo.playback)
discordPresence.state = "Watching Replay";
else
discordPresence.state = "Menu";
{
// Offline info
if (Playing())
discordPresence.state = "Offline";
else if (demo.playback && !demo.title)
discordPresence.state = "Watching Replay";
else
discordPresence.state = "Menu";
}
// Gametype info
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
@ -245,8 +248,19 @@ void DRPC_UpdatePresence(void)
discordPresence.largeImageText = mapname; // Map name
}
// discordPresence.startTimestamp & endTimestamp could be used to show leveltime & timelimit respectively,
// but would need converted to epoch seconds somehow
if (gamestate == GS_LEVEL)
{
const time_t currentTime = time(NULL);
const time_t mapTimeStart = currentTime - (leveltime / TICRATE);
discordPresence.startTimestamp = mapTimeStart;
if (timelimitintics > 0)
{
const time_t mapTimeEnd = mapTimeStart + ((timelimitintics + starttime + 1) / TICRATE);
discordPresence.endTimestamp = mapTimeEnd;
}
}
}
else if (gamestate == GS_VOTING)
{

View file

@ -261,6 +261,10 @@ Finish_update (void)
if (! done)
Finish_update();
#ifdef HAVE_DISCORDRPC
else
DRPC_UpdatePresence();
#endif
}
static void
@ -298,6 +302,10 @@ Finish_unlist (void)
MSId++;
}
Unlock_state();
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
#ifdef HAVE_THREADS
@ -434,10 +442,6 @@ void UnregisterServer(void)
#else
Finish_unlist();
#endif
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
static boolean
@ -495,10 +499,6 @@ Update_parameters (void)
if (! delayed && registered)
UpdateServer();
}
#ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence();
#endif
}
void MasterClient_Ticker(void)