Display instructions on how to fix Discord error to user

This commit is contained in:
MysterD 2020-10-11 18:10:54 -07:00
parent adb7fe86eb
commit 342a048e0e
2 changed files with 64 additions and 46 deletions

View File

@ -8,6 +8,7 @@
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include <winuser.h>
#else
#include <unistd.h>
#define MAX_PATH 1024
@ -19,6 +20,62 @@ static int64_t applicationId = 752700005210390568;
struct DiscordApplication app = { 0 };
bool gDiscordInitialized = false;
void discord_fatal(int rc) {
#if defined(_WIN32) || defined(_WIN64)
char errorMessage[132] = { 0 };
snprintf(errorMessage, 132, "Discord threw an error.\r\n\r\nTo fix: \r\n1. Close the game.\r\n2. Restart Discord.\r\n3. Start the game.\r\n\r\nRC: %d", rc);
int msgboxID = MessageBox(NULL,
errorMessage,
"Fatal Discord Error",
MB_ICONERROR | MB_OK | MB_DEFBUTTON1
);
exit(1);
#else
assert(rc != DiscordResult_ServiceUnavailable);
assert(rc != DiscordResult_InvalidVersion);
assert(rc != DiscordResult_LockFailed);
assert(rc != DiscordResult_InternalError);
assert(rc != DiscordResult_InvalidPayload);
assert(rc != DiscordResult_InvalidCommand);
assert(rc != DiscordResult_InvalidPermissions);
assert(rc != DiscordResult_NotFetched);
assert(rc != DiscordResult_NotFound);
assert(rc != DiscordResult_Conflict);
assert(rc != DiscordResult_InvalidSecret);
assert(rc != DiscordResult_InvalidJoinSecret);
assert(rc != DiscordResult_NoEligibleActivity);
assert(rc != DiscordResult_InvalidInvite);
assert(rc != DiscordResult_NotAuthenticated);
assert(rc != DiscordResult_InvalidAccessToken);
assert(rc != DiscordResult_ApplicationMismatch);
assert(rc != DiscordResult_InvalidDataUrl);
assert(rc != DiscordResult_InvalidBase64);
assert(rc != DiscordResult_NotFiltered);
assert(rc != DiscordResult_LobbyFull);
assert(rc != DiscordResult_InvalidFilename);
assert(rc != DiscordResult_InvalidFileSize);
assert(rc != DiscordResult_InvalidEntitlement);
assert(rc != DiscordResult_NotInstalled);
assert(rc != DiscordResult_NotRunning);
assert(rc != DiscordResult_InsufficientBuffer);
assert(rc != DiscordResult_PurchaseCanceled);
assert(rc != DiscordResult_InvalidGuild);
assert(rc != DiscordResult_InvalidEvent);
assert(rc != DiscordResult_InvalidChannel);
assert(rc != DiscordResult_InvalidOrigin);
assert(rc != DiscordResult_RateLimited);
assert(rc != DiscordResult_OAuth2Error);
assert(rc != DiscordResult_SelectChannelTimeout);
assert(rc != DiscordResult_SelectVoiceForceRequired);
assert(rc != DiscordResult_CaptureShortcutAlreadyListening);
assert(rc != DiscordResult_UnauthorizedForAchievement);
assert(rc != DiscordResult_InvalidGiftCode);
assert(rc != DiscordResult_PurchaseError);
assert(rc != DiscordResult_TransactionAborted);
assert(rc == DiscordResult_Ok);
#endif
}
static void set_instance_env_variable(void) {
// set local instance id
char environmentVariables[64] = { 0 };

View File

@ -14,53 +14,14 @@
#endif
#include "../network.h"
void discord_fatal(int rc);
// disgusting but descriptive
#define DISCORD_REQUIRE(x) { \
enum EDiscordResult DISCORD_REQUIRE_RC = x; \
if (DISCORD_REQUIRE_RC != DiscordResult_Ok) { \
assert(DISCORD_REQUIRE_RC != DiscordResult_ServiceUnavailable); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidVersion); \
assert(DISCORD_REQUIRE_RC != DiscordResult_LockFailed); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InternalError); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidPayload); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidCommand); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidPermissions); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotFetched); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotFound); \
assert(DISCORD_REQUIRE_RC != DiscordResult_Conflict); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidSecret); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidJoinSecret); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NoEligibleActivity); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidInvite); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotAuthenticated); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidAccessToken); \
assert(DISCORD_REQUIRE_RC != DiscordResult_ApplicationMismatch); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidDataUrl); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidBase64); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotFiltered); \
assert(DISCORD_REQUIRE_RC != DiscordResult_LobbyFull); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidFilename); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidFileSize); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidEntitlement); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotInstalled); \
assert(DISCORD_REQUIRE_RC != DiscordResult_NotRunning); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InsufficientBuffer); \
assert(DISCORD_REQUIRE_RC != DiscordResult_PurchaseCanceled); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidGuild); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidEvent); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidChannel); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidOrigin); \
assert(DISCORD_REQUIRE_RC != DiscordResult_RateLimited); \
assert(DISCORD_REQUIRE_RC != DiscordResult_OAuth2Error); \
assert(DISCORD_REQUIRE_RC != DiscordResult_SelectChannelTimeout); \
assert(DISCORD_REQUIRE_RC != DiscordResult_SelectVoiceForceRequired); \
assert(DISCORD_REQUIRE_RC != DiscordResult_CaptureShortcutAlreadyListening); \
assert(DISCORD_REQUIRE_RC != DiscordResult_UnauthorizedForAchievement); \
assert(DISCORD_REQUIRE_RC != DiscordResult_InvalidGiftCode); \
assert(DISCORD_REQUIRE_RC != DiscordResult_PurchaseError); \
assert(DISCORD_REQUIRE_RC != DiscordResult_TransactionAborted); \
assert(DISCORD_REQUIRE_RC == DiscordResult_Ok); \
} \
#define DISCORD_REQUIRE(x) { \
enum EDiscordResult DISCORD_REQUIRE_RC = x; \
if (DISCORD_REQUIRE_RC != DiscordResult_Ok) { \
discord_fatal(DISCORD_REQUIRE_RC); \
} \
}
extern struct NetworkSystem gNetworkSystemDiscord;