mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-19 03:32:41 +00:00
Prevent people from hosting a discord game when discord fails
This commit is contained in:
parent
8750198750
commit
040aa92fd1
3 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "audio/external.h"
|
||||
#include "config.h"
|
||||
#include "pc/network/version.h"
|
||||
#include "pc/network/discord/discord.h"
|
||||
|
||||
#define MAIN_MENU_HEADER_TEXT "SM64 COOP"
|
||||
|
||||
|
@ -82,7 +83,12 @@ static void host_menu_draw_strings(void) {
|
|||
char warning[128];
|
||||
snprintf(warning, 127, "You must forward port '%d' in your router or use Hamachi.", configHostPort);
|
||||
print_generic_ascii_string(0, 15, warning);
|
||||
|
||||
} else if ((configNetworkSystem == 0) && gDiscordFailed) {
|
||||
f32 red = (f32)fabs(sin(gGlobalTimer / 20.0f));
|
||||
gDPSetEnvColor(gDisplayListHead++, 222, 222 * red, 222 * red, gMenuStringAlpha);
|
||||
char warning[128];
|
||||
snprintf(warning, 127, "Discord failed to initialize.");
|
||||
print_generic_ascii_string(0, 15, warning);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
static int64_t applicationId = 752700005210390568;
|
||||
struct DiscordApplication app = { 0 };
|
||||
bool gDiscordInitialized = false;
|
||||
bool gDiscordFailed = false;
|
||||
|
||||
void discord_fatal(int rc) {
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
@ -139,9 +140,13 @@ static bool ns_discord_initialize(enum NetworkType networkType) {
|
|||
params.lobby_events = discord_lobby_initialize();
|
||||
|
||||
int rc = DiscordCreate(DISCORD_VERSION, ¶ms, &app.core);
|
||||
if (rc) {
|
||||
gDiscordFailed = false;
|
||||
if (networkType != NT_NONE) {
|
||||
DISCORD_REQUIRE(rc);
|
||||
} else if (rc) {
|
||||
LOG_ERROR("DiscordCreate failed: %d", rc);
|
||||
custom_menu_error("Could not detect Discord.\n\nTry closing the game,\nrestarting Discord,\nand opening the game again.");
|
||||
gDiscordFailed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ void discord_fatal(int rc);
|
|||
|
||||
extern struct NetworkSystem gNetworkSystemDiscord;
|
||||
extern bool gDiscordInitialized;
|
||||
extern bool gDiscordFailed;
|
||||
|
||||
struct DiscordApplication {
|
||||
struct IDiscordCore* core;
|
||||
|
|
Loading…
Reference in a new issue