From a2cbec78f95f9a539401e99e25e541b5c05dc562 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 16 Dec 2024 23:51:59 +0100 Subject: [PATCH] assballs --- src/Makefile | 3 ++- src/discord.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index dd87f70b9..837f43be1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -87,7 +87,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... MINGW=1 SDL=1 WINDOWSHELL=1 - HAVE_DISCORDRPC=0 + HAVE_DISCORDRPC=1 NOUPX=1 else # if you on the *nix @@ -140,6 +140,7 @@ endif ifdef LINUX64 LINUX=1 NONX86=1 +HAVE_DISCORDRPC=1 # LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium endif diff --git a/src/discord.c b/src/discord.c index cd7dafa8f..1430da6a4 100644 --- a/src/discord.c +++ b/src/discord.c @@ -10,11 +10,13 @@ /// \file discord.h /// \brief Discord Rich Presence handling -#ifdef HAVE_DISCORDRPC +//#ifdef HAVE_DISCORDRPC #include +#include "i_time.h" #include "i_system.h" +#include "r_main.h" #include "d_clisrv.h" #include "d_netcmd.h" #include "i_net.h" @@ -428,6 +430,56 @@ static void DRPC_EmptyRequests(void) } } +static char gamemodes[256] = ""; + +static void append_to_string(char *buffer, const char *mod_name) +{ + if (strlen(buffer) > 0) { + strcat(buffer, " -"); + } + strcat(buffer, mod_name); +} + +static void DRPC_UpdateGameModes(void) +{ + consvar_t *weathermodactive; + consvar_t *friendmodactive; + consvar_t *eliminationactive; + consvar_t *driftnitroactive; + + consvar_t *slipstreamactive; + consvar_t *booststackactive; + consvar_t *airbrakeactive; + + if (renderisnewtic && (I_GetTime() % TICRATE*20) == 0) + { + weathermodactive = CV_FindVar("weathermod"); + friendmodactive = CV_FindVar("fr_enabled"); + eliminationactive = CV_FindVar("elimination"); + driftnitroactive = CV_FindVar("driftnitro"); + + slipstreamactive = CV_FindVar("slipstream_enabled"); + booststackactive = CV_FindVar("booststack"); + airbrakeactive = CV_FindVar("wa_airbrake"); + + const boolean techactive = ((!driftnitroactive->value) && slipstreamactive->value && booststackactive->value && airbrakeactive->value); //this combination is only active with tech lel + + if (weathermodactive->value) + append_to_string(gamemodes, "Weathermod"); + + if (friendmodactive->value) + append_to_string(gamemodes, "Friendmod"); + + if (eliminationactive->value) + append_to_string(gamemodes, "Elimination"); + + if (driftnitroactive->value) + append_to_string(gamemodes, "DriftNitro"); + else if (techactive) + append_to_string(gamemodes, "Tech"); + } +} + /*-------------------------------------------------- void DRPC_UpdatePresence(void) @@ -532,8 +584,10 @@ void DRPC_UpdatePresence(void) discordPresence.details = "Time Attack"; else { + DRPC_UpdateGameModes(); + snprintf(detailstr, 48, "%s%s%s", - gametype_cons_t[gametype].strvalue, + (strlen(gamemodes) > 0) ? gamemodes : gametype_cons_t[gametype].strvalue, (gametype == GT_RACE) ? va(" | %s", kartspeed_cons_t[gamespeed].strvalue) : "", (encoremode == true) ? " | Encore" : "" ); @@ -682,4 +736,4 @@ void DRPC_UpdatePresence(void) Discord_UpdatePresence(&discordPresence); } -#endif // HAVE_DISCORDRPC +//#endif // HAVE_DISCORDRPC