mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 15:22:20 +00:00
Guard discord.h, add cvar to disable rich presence
This commit is contained in:
parent
8d386fba66
commit
886db8cde1
3 changed files with 26 additions and 4 deletions
|
@ -1004,6 +1004,10 @@ void D_RegisterClientCommands(void)
|
|||
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE)
|
||||
COM_AddCommand("dumplua", Command_Dumplua_f);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
CV_RegisterVar(&cv_discordrp);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Checks if a name (as received from another player) is okay.
|
||||
|
|
|
@ -29,7 +29,10 @@
|
|||
#include "discord.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
#define DISCORD_APPID "503531144395096085" // Feel free to use your own, if you care.
|
||||
// Feel free to provide your own, if you care enough to create another Discord app for this :P
|
||||
#define DISCORD_APPID "503531144395096085"
|
||||
|
||||
consvar_t cv_discordrp = {"discordrp", "On", CV_SAVE|CV_CALL, CV_OnOff, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
//
|
||||
// DRPC_Handle's
|
||||
|
@ -181,6 +184,14 @@ void DRPC_UpdatePresence(void)
|
|||
DiscordRichPresence discordPresence;
|
||||
memset(&discordPresence, 0, sizeof(discordPresence));
|
||||
|
||||
if (!cv_discordrp.value)
|
||||
{
|
||||
// User doesn't want to show their game information, so update with empty presence.
|
||||
// This just shows that they're playing SRB2Kart. (If that's too much, then they should disable game activity :V)
|
||||
Discord_UpdatePresence(&discordPresence);
|
||||
return;
|
||||
}
|
||||
|
||||
// Server info
|
||||
if (netgame)
|
||||
{
|
||||
|
@ -198,7 +209,7 @@ void DRPC_UpdatePresence(void)
|
|||
|
||||
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!)
|
||||
discordPresence.partyMax = cv_maxplayers.value; // Max players (TODO: another variable should hold this, so that maxplayers doesn't have to be a netvar)
|
||||
|
||||
// Grab the host's IP for joining.
|
||||
if ((join = DRPC_GetServerIP()) != NULL)
|
||||
|
@ -219,7 +230,7 @@ void DRPC_UpdatePresence(void)
|
|||
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
|
||||
{
|
||||
if (modeattacking)
|
||||
discordPresence.details = "Record Attack";
|
||||
discordPresence.details = "Time Attack";
|
||||
else
|
||||
discordPresence.details = gametype_cons_t[gametype].strvalue;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,18 @@
|
|||
/// \file discord.h
|
||||
/// \brief Discord Rich Presence handling
|
||||
|
||||
#ifndef __DISCORD__
|
||||
#define __DISCORD__
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
|
||||
#include "discord_rpc.h"
|
||||
|
||||
extern consvar_t cv_discordrp;
|
||||
|
||||
void DRPC_Init(void);
|
||||
void DRPC_UpdatePresence(void);
|
||||
|
||||
#endif
|
||||
#endif // HAVE_DISCORDRPC
|
||||
|
||||
#endif // __DISCORD__
|
||||
|
|
Loading…
Reference in a new issue