mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 15:22:20 +00:00
Display time elasped/time limit
This commit is contained in:
parent
d709e9782d
commit
8d386fba66
2 changed files with 33 additions and 19 deletions
|
@ -192,25 +192,28 @@ void DRPC_UpdatePresence(void)
|
||||||
case 33: discordPresence.state = "Standard"; break;
|
case 33: discordPresence.state = "Standard"; break;
|
||||||
case 28: discordPresence.state = "Casual"; break;
|
case 28: discordPresence.state = "Casual"; break;
|
||||||
case 38: discordPresence.state = "Custom Gametypes"; 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
|
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.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.
|
// Grab the host's IP for joining.
|
||||||
if ((join = DRPC_GetServerIP()) != NULL)
|
if ((join = DRPC_GetServerIP()) != NULL)
|
||||||
discordPresence.joinSecret = join;
|
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
|
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
|
// Gametype info
|
||||||
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
|
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
|
||||||
|
@ -245,8 +248,19 @@ void DRPC_UpdatePresence(void)
|
||||||
discordPresence.largeImageText = mapname; // Map name
|
discordPresence.largeImageText = mapname; // Map name
|
||||||
}
|
}
|
||||||
|
|
||||||
// discordPresence.startTimestamp & endTimestamp could be used to show leveltime & timelimit respectively,
|
if (gamestate == GS_LEVEL)
|
||||||
// but would need converted to epoch seconds somehow
|
{
|
||||||
|
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)
|
else if (gamestate == GS_VOTING)
|
||||||
{
|
{
|
||||||
|
|
16
src/mserv.c
16
src/mserv.c
|
@ -261,6 +261,10 @@ Finish_update (void)
|
||||||
|
|
||||||
if (! done)
|
if (! done)
|
||||||
Finish_update();
|
Finish_update();
|
||||||
|
#ifdef HAVE_DISCORDRPC
|
||||||
|
else
|
||||||
|
DRPC_UpdatePresence();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -298,6 +302,10 @@ Finish_unlist (void)
|
||||||
MSId++;
|
MSId++;
|
||||||
}
|
}
|
||||||
Unlock_state();
|
Unlock_state();
|
||||||
|
|
||||||
|
#ifdef HAVE_DISCORDRPC
|
||||||
|
DRPC_UpdatePresence();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
|
@ -434,10 +442,6 @@ void UnregisterServer(void)
|
||||||
#else
|
#else
|
||||||
Finish_unlist();
|
Finish_unlist();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
|
||||||
DRPC_UpdatePresence();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
|
@ -495,10 +499,6 @@ Update_parameters (void)
|
||||||
if (! delayed && registered)
|
if (! delayed && registered)
|
||||||
UpdateServer();
|
UpdateServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
|
||||||
DRPC_UpdatePresence();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterClient_Ticker(void)
|
void MasterClient_Ticker(void)
|
||||||
|
|
Loading…
Reference in a new issue