mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Guard discord.h, add cvar to disable rich presence
This commit is contained in:
parent
352449010e
commit
59ebf07dd5
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)
|
#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE)
|
||||||
COM_AddCommand("dumplua", Command_Dumplua_f);
|
COM_AddCommand("dumplua", Command_Dumplua_f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DISCORDRPC
|
||||||
|
CV_RegisterVar(&cv_discordrp);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if a name (as received from another player) is okay.
|
/** Checks if a name (as received from another player) is okay.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,10 @@
|
||||||
#include "discord.h"
|
#include "discord.h"
|
||||||
#include "doomdef.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
|
// DRPC_Handle's
|
||||||
|
|
@ -181,6 +184,14 @@ void DRPC_UpdatePresence(void)
|
||||||
DiscordRichPresence discordPresence;
|
DiscordRichPresence discordPresence;
|
||||||
memset(&discordPresence, 0, sizeof(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
|
// Server info
|
||||||
if (netgame)
|
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.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.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.
|
// Grab the host's IP for joining.
|
||||||
if ((join = DRPC_GetServerIP()) != NULL)
|
if ((join = DRPC_GetServerIP()) != NULL)
|
||||||
|
|
@ -219,7 +230,7 @@ void DRPC_UpdatePresence(void)
|
||||||
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
|
if (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)
|
||||||
{
|
{
|
||||||
if (modeattacking)
|
if (modeattacking)
|
||||||
discordPresence.details = "Record Attack";
|
discordPresence.details = "Time Attack";
|
||||||
else
|
else
|
||||||
discordPresence.details = gametype_cons_t[gametype].strvalue;
|
discordPresence.details = gametype_cons_t[gametype].strvalue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,18 @@
|
||||||
/// \file discord.h
|
/// \file discord.h
|
||||||
/// \brief Discord Rich Presence handling
|
/// \brief Discord Rich Presence handling
|
||||||
|
|
||||||
|
#ifndef __DISCORD__
|
||||||
|
#define __DISCORD__
|
||||||
|
|
||||||
#ifdef HAVE_DISCORDRPC
|
#ifdef HAVE_DISCORDRPC
|
||||||
|
|
||||||
#include "discord_rpc.h"
|
#include "discord_rpc.h"
|
||||||
|
|
||||||
|
extern consvar_t cv_discordrp;
|
||||||
|
|
||||||
void DRPC_Init(void);
|
void DRPC_Init(void);
|
||||||
void DRPC_UpdatePresence(void);
|
void DRPC_UpdatePresence(void);
|
||||||
|
|
||||||
#endif
|
#endif // HAVE_DISCORDRPC
|
||||||
|
|
||||||
|
#endif // __DISCORD__
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue