mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 04:11:18 +00:00
Dedicated servers can change discordinvites without needing RPC support
This commit is contained in:
parent
6d2c7f4ae7
commit
7dea9d28b9
5 changed files with 21 additions and 48 deletions
|
@ -1671,12 +1671,7 @@ static boolean SV_SendServerConfig(INT32 node)
|
|||
|
||||
netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
|
||||
netbuffer->u.servercfg.allownewplayer = cv_allownewplayer.value;
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
netbuffer->u.servercfg.discordinvites = (boolean)cv_discordinvites.value;
|
||||
#else
|
||||
netbuffer->u.servercfg.discordinvites = false;
|
||||
#endif
|
||||
|
||||
memcpy(netbuffer->u.servercfg.server_context, server_context, 8);
|
||||
op = p = netbuffer->u.servercfg.varlengthinputs;
|
||||
|
@ -3587,11 +3582,20 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum);
|
|||
|
||||
static void Joinable_OnChange(void)
|
||||
{
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
DRPC_SendDiscordInfo();
|
||||
#else
|
||||
UINT8 buf[3];
|
||||
UINT8 *p = buf;
|
||||
UINT8 maxplayer;
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
#endif
|
||||
|
||||
maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
|
||||
|
||||
WRITEUINT8(p, maxplayer);
|
||||
WRITEUINT8(p, cv_allownewplayer.value);
|
||||
WRITEUINT8(p, cv_discordinvites.value);
|
||||
|
||||
SendNetXCmd(XD_DISCORD, &buf, 3);
|
||||
}
|
||||
|
||||
// called one time at init
|
||||
|
|
|
@ -467,6 +467,10 @@ consvar_t cv_mute = {"mute", "Off", CV_NETVAR|CV_CALL, CV_OnOff, Mute_OnChange,
|
|||
|
||||
consvar_t cv_sleep = {"cpusleep", "1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Here for dedicated servers
|
||||
static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Everyone"}, {0, NULL}};
|
||||
consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, discordinvites_cons_t, DRPC_SendDiscordInfo, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
INT16 gametype = GT_RACE; // SRB2kart
|
||||
boolean forceresetplayers = false;
|
||||
boolean deferencoremode = false;
|
||||
|
@ -1012,8 +1016,8 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_discordrp);
|
||||
CV_RegisterVar(&cv_discordstreamer);
|
||||
CV_RegisterVar(&cv_discordasks);
|
||||
CV_RegisterVar(&cv_discordinvites);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_discordinvites);
|
||||
}
|
||||
|
||||
/** Checks if a name (as received from another player) is okay.
|
||||
|
|
|
@ -151,6 +151,8 @@ extern consvar_t cv_skipmapcheck;
|
|||
|
||||
extern consvar_t cv_sleep;
|
||||
|
||||
extern consvar_t cv_discordinvites;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XD_NAMEANDCOLOR = 1,
|
||||
|
|
|
@ -41,9 +41,6 @@ consvar_t cv_discordrp = {"discordrp", "On", CV_SAVE|CV_CALL, CV_OnOff, DRPC_Upd
|
|||
consvar_t cv_discordstreamer = {"discordstreamer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_discordasks = {"discordasks", "Yes", CV_SAVE|CV_CALL, CV_YesNo, DRPC_UpdatePresence, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Everyone"}, {0, NULL}};
|
||||
consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, discordinvites_cons_t, DRPC_SendDiscordInfo, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
struct discordInfo_s discordInfo;
|
||||
|
||||
discordRequest_t *discordRequestList = NULL;
|
||||
|
@ -338,29 +335,6 @@ void DRPC_Init(void)
|
|||
DRPC_UpdatePresence();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_SendDiscordInfo(void)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
void DRPC_SendDiscordInfo(void)
|
||||
{
|
||||
UINT8 buf[3];
|
||||
UINT8 *p = buf;
|
||||
UINT8 maxplayer;
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
|
||||
|
||||
WRITEUINT8(p, maxplayer);
|
||||
WRITEUINT8(p, cv_allownewplayer.value);
|
||||
WRITEUINT8(p, cv_discordinvites.value);
|
||||
|
||||
SendNetXCmd(XD_DISCORD, &buf, 3);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
/*--------------------------------------------------
|
||||
static size_t DRPC_WriteServerIP(char *s, size_t size, size_t n, void *userdata)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
extern consvar_t cv_discordrp;
|
||||
extern consvar_t cv_discordstreamer;
|
||||
extern consvar_t cv_discordasks;
|
||||
extern consvar_t cv_discordinvites;
|
||||
|
||||
extern struct discordInfo_s {
|
||||
UINT8 maxPlayers;
|
||||
|
@ -65,16 +64,6 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest);
|
|||
void DRPC_Init(void);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_SendDiscordInfo(void);
|
||||
|
||||
Sends the server's information needed for
|
||||
the rich presence state.
|
||||
--------------------------------------------------*/
|
||||
|
||||
void DRPC_SendDiscordInfo(void);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_UpdatePresence(void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue