From deeafc5a6086966728ef6f23b4ea9684218486d1 Mon Sep 17 00:00:00 2001 From: janisozaur Date: Wed, 11 May 2016 13:25:21 +0200 Subject: [PATCH] Add `--silent-breakpad` switch, fixes #3535 (#3544) --- src/cmdline/RootCommands.cpp | 14 +++++++++++++- src/openrct2.c | 1 + src/platform/crash.cpp | 9 ++++++++- src/platform/crash.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cmdline/RootCommands.cpp b/src/cmdline/RootCommands.cpp index 23fa0ac0b2..32c1e2045e 100644 --- a/src/cmdline/RootCommands.cpp +++ b/src/cmdline/RootCommands.cpp @@ -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); diff --git a/src/openrct2.c b/src/openrct2.c index 21bad9ecb4..40c946e26a 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -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; diff --git a/src/platform/crash.cpp b/src/platform/crash.cpp index 2c8f4a91a6..41ae935751 100644 --- a/src/platform/crash.cpp +++ b/src/platform/crash.cpp @@ -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, diff --git a/src/platform/crash.h b/src/platform/crash.h index 178c99a1ea..4825223a73 100644 --- a/src/platform/crash.h +++ b/src/platform/crash.h @@ -23,6 +23,7 @@ typedef void * CExceptionHandler; extern "C" { #endif + extern bool gOpenRCT2SilentBreakpad; CExceptionHandler crash_init(); #ifdef __cplusplus }