From 7d3e7db2b7dbe7c43081d61844061c9a75bfd0e8 Mon Sep 17 00:00:00 2001 From: Buggem's Fedora PC <66670928+Buggem@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:28:30 +1100 Subject: [PATCH] Avoid segfault if Discord is not detected, remove useless headerfiles --- desktop_version/src/DiscordNetwork.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/desktop_version/src/DiscordNetwork.c b/desktop_version/src/DiscordNetwork.c index a4236cd7..e9ec6baa 100644 --- a/desktop_version/src/DiscordNetwork.c +++ b/desktop_version/src/DiscordNetwork.c @@ -4,12 +4,8 @@ #include #include +#include #include -#ifdef _WIN32 -#include -#else -#include -#endif #include "Vlogging.h" @@ -38,6 +34,7 @@ struct DISCORD_application { struct DiscordActivity activity; +bool discordNotDetected = false; int discordCrashes = 0; // This is here to ensure we do not get stuck in a theoratical softlock of opening and crashing Discord instances. static void* libHandle = NULL; @@ -103,6 +100,12 @@ int32_t DISCORD_init(void) return 1; } + if(app.core == NULL) + { + discordNotDetected = true; + return 0; + } + SDL_strlcpy(activity.assets.large_image, "vvvvvv", sizeof(activity.assets.large_image)); SDL_strlcpy(activity.assets.large_text, "Outside Dimension VVVVVV", sizeof(activity.assets.large_text)); @@ -116,6 +119,10 @@ int32_t DISCORD_init(void) } void DISCORD_REQUIRE(int x) { + if(discordNotDetected) + { + return; + } if(discordCrashes > DISCORD_CRASH_LIMIT) { DISCORD_shutdown();