mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Always have XD_DISCORD defined, so that people compiling without Discord support can connect to servers that do.
This commit is contained in:
parent
3c128660b4
commit
3d5d5ad8b5
4 changed files with 38 additions and 48 deletions
|
@ -81,6 +81,7 @@ static void Got_RandomSeed(UINT8 **cp, INT32 playernum);
|
|||
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Teamchange(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Clearscores(UINT8 **cp, INT32 playernum);
|
||||
static void Got_DiscordInfo(UINT8 **cp, INT32 playernum);
|
||||
|
||||
static void PointLimit_OnChange(void);
|
||||
static void TimeLimit_OnChange(void);
|
||||
|
@ -713,9 +714,7 @@ void D_RegisterServerCommands(void)
|
|||
|
||||
CV_RegisterVar(&cv_dummyconsvar);
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
RegisterNetXCmd(XD_DISCORD, DRPC_RecieveDiscordInfo);
|
||||
#endif
|
||||
RegisterNetXCmd(XD_DISCORD, Got_DiscordInfo);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
@ -5696,3 +5695,30 @@ static void KartEliminateLast_OnChange(void)
|
|||
if (G_RaceGametype() && cv_karteliminatelast.value)
|
||||
P_CheckRacers();
|
||||
}
|
||||
|
||||
void Got_DiscordInfo(UINT8 **p, INT32 playernum)
|
||||
{
|
||||
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
|
||||
{
|
||||
// protect against hacked/buggy client
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
{
|
||||
XBOXSTATIC UINT8 buf[2];
|
||||
|
||||
buf[0] = (UINT8)playernum;
|
||||
buf[1] = KICK_MSG_CON_FAIL;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't do anything with the information if we don't have Discord RP support
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
discordInfo.maxPlayers = READUINT8(*p);
|
||||
discordInfo.joinsAllowed = (boolean)READUINT8(*p);
|
||||
discordInfo.everyoneCanInvite = (boolean)READUINT8(*p);
|
||||
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -178,12 +178,10 @@ typedef enum
|
|||
XD_MODIFYVOTE, // 23
|
||||
XD_PICKVOTE, // 24
|
||||
XD_REMOVEPLAYER,// 25
|
||||
XD_DISCORD, // 26
|
||||
#ifdef HAVE_BLUA
|
||||
XD_LUACMD, // 26
|
||||
XD_LUAVAR, // 27
|
||||
#endif
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
XD_DISCORD, // 28
|
||||
XD_LUACMD, // 27
|
||||
XD_LUAVAR, // 28
|
||||
#endif
|
||||
MAXNETXCMD
|
||||
} netxcmd_t;
|
||||
|
|
|
@ -351,35 +351,6 @@ void DRPC_SendDiscordInfo(void)
|
|||
SendNetXCmd(XD_DISCORD, &buf, 3);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_RecieveDiscordInfo(UINT8 **p, INT32 playernum)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void DRPC_RecieveDiscordInfo(UINT8 **p, INT32 playernum)
|
||||
{
|
||||
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
|
||||
{
|
||||
// protect against hacked/buggy client
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
{
|
||||
XBOXSTATIC UINT8 buf[2];
|
||||
|
||||
buf[0] = (UINT8)playernum;
|
||||
buf[1] = KICK_MSG_CON_FAIL;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
discordInfo.maxPlayers = READUINT8(*p);
|
||||
discordInfo.joinsAllowed = (boolean)READUINT8(*p);
|
||||
discordInfo.everyoneCanInvite = (boolean)READUINT8(*p);
|
||||
|
||||
DRPC_UpdatePresence();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
/*--------------------------------------------------
|
||||
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
|
||||
|
@ -547,7 +518,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: another variable should hold this, so that maxplayers doesn't have to be a netvar)
|
||||
discordPresence.partyMax = discordInfo.maxPlayers; // Max players
|
||||
|
||||
if (DRPC_InvitesAreAllowed() == true)
|
||||
{
|
||||
|
@ -566,6 +537,11 @@ void DRPC_UpdatePresence(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Reset discord info if you're not in a place that uses it!
|
||||
// Important for if you join a server that compiled without HAVE_DISCORDRPC,
|
||||
// so that you don't ever end up using bad information from another server.
|
||||
memset(&discordInfo, 0, sizeof(discordInfo));
|
||||
|
||||
// Offline info
|
||||
if (Playing())
|
||||
discordPresence.state = "Offline";
|
||||
|
|
|
@ -76,16 +76,6 @@ void DRPC_Init(void);
|
|||
void DRPC_SendDiscordInfo(void);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_RecieveDiscordInfo(UINT8 **p, INT32 playernum);
|
||||
|
||||
Recieves the server's information needed for
|
||||
the rich presence state.
|
||||
--------------------------------------------------*/
|
||||
|
||||
void DRPC_RecieveDiscordInfo(UINT8 **p, INT32 playernum);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_UpdatePresence(void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue