1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Save .park in crash code

This commit is contained in:
Ted John
2021-04-02 21:09:34 +01:00
parent fce02c21c3
commit 9fe4cea07e
4 changed files with 32 additions and 23 deletions

View File

@@ -7,6 +7,8 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "ParkFile.h"
#include "Cheats.h"
#include "Context.h"
#include "GameState.h"
@@ -1245,6 +1247,14 @@ namespace OpenRCT2
}
} // namespace OpenRCT2
void ParkFileExporter::Export(std::string_view path)
{
map_reorganise_elements();
auto parkFile = std::make_unique<OpenRCT2::ParkFile>();
parkFile->Save(path);
}
enum : uint32_t
{
S6_SAVE_FLAG_EXPORT = 1 << 0,

14
src/openrct2/ParkFile.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include <string_view>
#include <vector>
struct ObjectRepositoryItem;
class ParkFileExporter
{
public:
std::vector<const ObjectRepositoryItem*> ExportObjectsList;
void Export(std::string_view path);
};

View File

@@ -280,6 +280,7 @@
<ClInclude Include="paint\tile_element\Paint.Surface.h" />
<ClInclude Include="paint\tile_element\Paint.TileElement.h" />
<ClInclude Include="paint\VirtualFloor.h" />
<ClInclude Include="ParkFile.h" />
<ClInclude Include="ParkImporter.h" />
<ClInclude Include="peep\GuestPathfinding.h" />
<ClInclude Include="peep\Peep.h" />
@@ -876,4 +877,4 @@
<ClCompile Include="world\Wall.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>

View File

@@ -27,6 +27,7 @@
# include "../Context.h"
# include "../Game.h"
# include "../OpenRCT2.h"
# include "../ParkFile.h"
# include "../Version.h"
# include "../config/Config.h"
# include "../core/Console.hpp"
@@ -35,7 +36,6 @@
# include "../interface/Screenshot.h"
# include "../localisation/Language.h"
# include "../object/ObjectManager.h"
# include "../rct2/S6Exporter.h"
# include "../scenario/Scenario.h"
# include "../util/SawyerCoding.h"
# include "../util/Util.h"
@@ -114,12 +114,10 @@ static bool OnCrash(
wchar_t dumpFilePath[MAX_PATH];
wchar_t saveFilePath[MAX_PATH];
wchar_t configFilePath[MAX_PATH];
wchar_t saveFilePathGZIP[MAX_PATH];
wchar_t recordFilePathNew[MAX_PATH];
swprintf_s(dumpFilePath, std::size(dumpFilePath), L"%s\\%s.dmp", dumpPath, miniDumpId);
swprintf_s(saveFilePath, std::size(saveFilePath), L"%s\\%s.sv6", dumpPath, miniDumpId);
swprintf_s(saveFilePath, std::size(saveFilePath), L"%s\\%s.park", dumpPath, miniDumpId);
swprintf_s(configFilePath, std::size(configFilePath), L"%s\\%s.ini", dumpPath, miniDumpId);
swprintf_s(saveFilePathGZIP, std::size(saveFilePathGZIP), L"%s\\%s.sv6.gz", dumpPath, miniDumpId);
swprintf_s(recordFilePathNew, std::size(recordFilePathNew), L"%s\\%s.sv6r", dumpPath, miniDumpId);
wchar_t dumpFilePathNew[MAX_PATH];
@@ -172,7 +170,7 @@ static bool OnCrash(
auto saveFilePathUTF8 = String::ToUtf8(saveFilePath);
try
{
auto exporter = std::make_unique<S6Exporter>();
auto exporter = std::make_unique<ParkFileExporter>();
// Make sure the save is using the current viewport settings.
viewport_set_saved_view();
@@ -185,8 +183,7 @@ static bool OnCrash(
auto& objManager = ctx->GetObjectManager();
exporter->ExportObjectsList = objManager.GetPackableObjects();
exporter->Export();
exporter->SaveGame(saveFilePathUTF8.c_str());
exporter->Export(saveFilePathUTF8.c_str());
savedGameDumped = true;
}
catch (const std::exception&)
@@ -196,19 +193,7 @@ static bool OnCrash(
// Compress the save
if (savedGameDumped)
{
FILE* input = _wfopen(saveFilePath, L"rb");
FILE* dest = _wfopen(saveFilePathGZIP, L"wb");
if (util_gzip_compress(input, dest))
{
uploadFiles[L"attachment_park.sv6.gz"] = saveFilePathGZIP;
}
else
{
uploadFiles[L"attachment_park.sv6"] = saveFilePath;
}
fclose(input);
fclose(dest);
uploadFiles[L"attachment_park.park"] = saveFilePath;
}
auto configFilePathUTF8 = String::ToUtf8(configFilePath);
@@ -294,7 +279,6 @@ static bool OnCrash(
if (savedGameDumped)
{
files[numFiles++] = ILCreateFromPathW(saveFilePath);
files[numFiles++] = ILCreateFromPathW(saveFilePathGZIP);
}
if (with_record)
{
@@ -336,7 +320,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<CExceptionHandler>(exHandler);
#else // USE_BREAKPAD
#else // USE_BREAKPAD
return nullptr;
#endif // USE_BREAKPAD
}