diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 6ac59f67a2..d0f739970e 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1128,6 +1128,7 @@ namespace OpenRCT2 DIRID::SEQUENCE, DIRID::REPLAY, DIRID::LOG_DESYNCS, + DIRID::CRASH, }); } diff --git a/src/openrct2/PlatformEnvironment.cpp b/src/openrct2/PlatformEnvironment.cpp index 59480787a7..ba48098177 100644 --- a/src/openrct2/PlatformEnvironment.cpp +++ b/src/openrct2/PlatformEnvironment.cpp @@ -228,6 +228,7 @@ const char * PlatformEnvironment::DirectoryNamesOpenRCT2[] = "heightmap", // HEIGHTMAP "replay", // REPLAY "desyncs", // DESYNCS + "crash", // CRASH }; const char * PlatformEnvironment::FileNames[] = diff --git a/src/openrct2/PlatformEnvironment.h b/src/openrct2/PlatformEnvironment.h index ad8dd64428..91f3a47779 100644 --- a/src/openrct2/PlatformEnvironment.h +++ b/src/openrct2/PlatformEnvironment.h @@ -49,6 +49,7 @@ namespace OpenRCT2 HEIGHTMAP, // Contains heightmap data. REPLAY, // Contains recorded replays. LOG_DESYNCS, // Contains desync reports. + CRASH, // Contains crash dumps. }; enum class PATHID diff --git a/src/openrct2/platform/Crash.cpp b/src/openrct2/platform/Crash.cpp index c3fe60b9ff..c1768fece5 100644 --- a/src/openrct2/platform/Crash.cpp +++ b/src/openrct2/platform/Crash.cpp @@ -27,10 +27,12 @@ # include "../Context.h" # include "../Game.h" # include "../OpenRCT2.h" +# include "../PlatformEnvironment.h" # include "../Version.h" # include "../config/Config.h" # include "../core/Console.hpp" # include "../core/Guard.hpp" +# include "../core/Path.hpp" # include "../core/String.hpp" # include "../interface/Screenshot.h" # include "../localisation/Language.h" @@ -54,6 +56,8 @@ const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE); # define BACKTRACE_TOKEN L"742b8d9d70c52df663e4f2449f90039cf9406f89e57ecb90b0f086ba16e33d20" +using namespace OpenRCT2; + // Note: uploading gzipped crash dumps manually requires specifying // 'Content-Encoding: gzip' header in HTTP request, but we cannot do that, // so just hope the file name with '.gz' suffix is enough. @@ -319,9 +323,10 @@ static bool OnCrash( static std::wstring GetDumpDirectory() { - char userDirectory[MAX_PATH]; - platform_get_user_directory(userDirectory, nullptr, sizeof(userDirectory)); - auto result = String::ToWideChar(userDirectory); + auto env = GetContext()->GetPlatformEnvironment(); + auto crashPath = env->GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::CRASH); + + auto result = String::ToWideChar(crashPath.c_str()); return result; } @@ -337,7 +342,7 @@ CExceptionHandler crash_init() auto exHandler = new google_breakpad::ExceptionHandler( GetDumpDirectory(), 0, OnCrash, 0, google_breakpad::ExceptionHandler::HANDLER_ALL, MiniDumpWithDataSegs, PipeName, 0); return reinterpret_cast(exHandler); -#else // USE_BREAKPAD +#else // USE_BREAKPAD return nullptr; #endif // USE_BREAKPAD }