diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 51f08419..dcd85156 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -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 - return; -#endif + 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); } // called one time at init diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5efe3088..8959486e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -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. diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1e158808..2c0ed142 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -151,6 +151,8 @@ extern consvar_t cv_skipmapcheck; extern consvar_t cv_sleep; +extern consvar_t cv_discordinvites; + typedef enum { XD_NAMEANDCOLOR = 1, diff --git a/src/discord.c b/src/discord.c index 236c801b..eaf595c4 100644 --- a/src/discord.c +++ b/src/discord.c @@ -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) diff --git a/src/discord.h b/src/discord.h index 97c5557b..a6bb1134 100644 --- a/src/discord.h +++ b/src/discord.h @@ -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);