Add `--silent-breakpad` switch, fixes #3535 (#3544)

This commit is contained in:
janisozaur 2016-05-11 13:25:21 +02:00 committed by Ted John
parent 62a7dd927e
commit deeafc5a60
4 changed files with 23 additions and 2 deletions

View File

@ -20,6 +20,7 @@ extern "C"
{
#include "../config.h"
#include "../openrct2.h"
#include "../platform/crash.h"
}
#include "../core/Console.hpp"
@ -48,6 +49,13 @@ static uint32 _port = 0;
static utf8 * _password = nullptr;
static utf8 * _userDataPath = nullptr;
static utf8 * _openrctDataPath = nullptr;
static bool _silentBreakpad = false;
#ifdef USE_BREAKPAD
#define IMPLIES_SILENT_BREAKPAD ", implies --silent-breakpad"
#else
#define IMPLIES_SILENT_BREAKPAD
#endif // USE_BREAKPAD
static const CommandLineOptionDefinition StandardOptions[]
{
@ -57,13 +65,16 @@ static const CommandLineOptionDefinition StandardOptions[]
{ CMDLINE_TYPE_SWITCH, &_all, 'a', "all", "show help for all commands" },
{ CMDLINE_TYPE_SWITCH, &_about, NAC, "about", "show information about " OPENRCT2_NAME },
{ CMDLINE_TYPE_SWITCH, &_verbose, NAC, "verbose", "log verbose messages" },
{ CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" },
{ CMDLINE_TYPE_SWITCH, &_headless, NAC, "headless", "run " OPENRCT2_NAME " headless" IMPLIES_SILENT_BREAKPAD },
#ifndef DISABLE_NETWORK
{ CMDLINE_TYPE_INTEGER, &_port, NAC, "port", "port to use for hosting or joining a server" },
#endif
{ CMDLINE_TYPE_STRING, &_password, NAC, "password", "password needed to join the server" },
{ CMDLINE_TYPE_STRING, &_userDataPath, NAC, "user-data-path", "path to the user data directory (containing config.ini)" },
{ CMDLINE_TYPE_STRING, &_openrctDataPath, NAC, "openrct-data-path", "path to the OpenRCT2 data directory (containing languages)" },
#ifdef USE_BREAKPAD
{ CMDLINE_TYPE_SWITCH, &_silentBreakpad, NAC, "silent-breakpad", "make breakpad crash reporting silent" },
#endif // USE_BREAKPAD
OptionTableEnd
};
@ -160,6 +171,7 @@ exitcode_t CommandLine::HandleCommandDefault()
}
gOpenRCT2Headless = _headless;
gOpenRCT2SilentBreakpad = _silentBreakpad || _headless;
if (_userDataPath != NULL) {
String::Set(gCustomUserDataPath, sizeof(gCustomUserDataPath), _userDataPath);

View File

@ -59,6 +59,7 @@ utf8 gCustomPassword[MAX_PATH] = { 0 };
bool gOpenRCT2Headless = false;
bool gOpenRCT2ShowChangelog;
bool gOpenRCT2SilentBreakpad;
/** If set, will end the OpenRCT2 game loop. Intentially private to this module so that the flag can not be set back to 0. */
int _finished;

View File

@ -52,7 +52,10 @@ static bool OnCrash(const wchar_t * dumpPath,
{
constexpr const char * DumpFailedMessage = "Failed to create the dump. Nothing left to do. Please file an issue with OpenRCT2 on Github and provide latest save.";
printf("%s\n", DumpFailedMessage);
MessageBoxA(NULL, DumpFailedMessage, OPENRCT2_NAME, MB_OK | MB_ICONERROR);
if (!gOpenRCT2SilentBreakpad)
{
MessageBoxA(NULL, DumpFailedMessage, OPENRCT2_NAME, MB_OK | MB_ICONERROR);
}
return succeeded;
}
@ -77,6 +80,10 @@ static bool OnCrash(const wchar_t * dumpPath,
SDL_RWclose(rw);
}
if (gOpenRCT2SilentBreakpad)
{
return succeeded;
}
constexpr const wchar_t * MessageFormat = L"A crash has occurred and dump was created at\n%s.\n\nPlease create an issue with OpenRCT2 on Github and provide the dump and save.\n\nVersion: %s\nCommit: %s";
wchar_t message[MAX_PATH * 2];
swprintf_s(message,

View File

@ -23,6 +23,7 @@ typedef void * CExceptionHandler;
extern "C"
{
#endif
extern bool gOpenRCT2SilentBreakpad;
CExceptionHandler crash_init();
#ifdef __cplusplus
}