1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Add new .park save format

Co-authored-by: Gymnasiast <Gymnasiast@users.noreply.github.com>
Co-authored-by: duncanspumpkin <duncanspumpkin@users.noreply.github.com>
Co-authored-by: ZehMatt <Zehmatt@users.noreply.github.com>
Co-authored-by: Broxzier <Broxzier@users.noreply.github.com>
This commit is contained in:
IntelOrca
2021-10-27 14:21:14 +02:00
committed by Gymnasiast
parent e9e8dceca7
commit 34128dc262
112 changed files with 7281 additions and 4243 deletions

View File

@@ -495,7 +495,6 @@ namespace OpenRCT2
#endif
}
gCurrentTicks = 0;
input_reset_place_obj_modifier();
viewport_init_all();
@@ -573,7 +572,8 @@ namespace OpenRCT2
_drawingEngine = nullptr;
}
bool LoadParkFromFile(const std::string& path, bool loadTitleScreenOnFail) final override
bool LoadParkFromFile(
const std::string& path, bool loadTitleScreenOnFail = false, bool asScenario = false) final override
{
log_verbose("Context::LoadParkFromFile(%s)", path.c_str());
try
@@ -582,7 +582,7 @@ namespace OpenRCT2
{
auto data = DecryptSea(fs::u8path(path));
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
if (!LoadParkFromStream(&ms, path, loadTitleScreenOnFail))
if (!LoadParkFromStream(&ms, path, loadTitleScreenOnFail, asScenario))
{
throw std::runtime_error(".sea file may have been renamed.");
}
@@ -590,7 +590,7 @@ namespace OpenRCT2
}
auto fs = FileStream(path, FILE_MODE_OPEN);
if (!LoadParkFromStream(&fs, path, loadTitleScreenOnFail))
if (!LoadParkFromStream(&fs, path, loadTitleScreenOnFail, asScenario))
{
return false;
}
@@ -609,7 +609,9 @@ namespace OpenRCT2
return false;
}
bool LoadParkFromStream(IStream* stream, const std::string& path, bool loadTitleScreenFirstOnFail) final override
bool LoadParkFromStream(
IStream* stream, const std::string& path, bool loadTitleScreenFirstOnFail = false,
bool asScenario = false) final override
{
try
{
@@ -619,13 +621,17 @@ namespace OpenRCT2
throw std::runtime_error("Unable to detect file type");
}
if (info.Type != FILE_TYPE::SAVED_GAME && info.Type != FILE_TYPE::SCENARIO)
if (info.Type != FILE_TYPE::PARK && info.Type != FILE_TYPE::SAVED_GAME && info.Type != FILE_TYPE::SCENARIO)
{
throw std::runtime_error("Invalid file type.");
}
std::unique_ptr<IParkImporter> parkImporter;
if (info.Version <= FILE_TYPE_S4_CUTOFF)
if (info.Type == FILE_TYPE::PARK)
{
parkImporter = ParkImporter::CreateParkFile(*_objectRepository);
}
else if (info.Version <= FILE_TYPE_S4_CUTOFF)
{
// Save is an S4 (RCT1 format)
parkImporter = ParkImporter::CreateS4();
@@ -656,7 +662,7 @@ namespace OpenRCT2
#ifndef DISABLE_NETWORK
bool sendMap = false;
#endif
if (info.Type == FILE_TYPE::SAVED_GAME)
if (!asScenario && (info.Type == FILE_TYPE::PARK || info.Type == FILE_TYPE::SAVED_GAME))
{
#ifndef DISABLE_NETWORK
if (_network.GetMode() == NETWORK_MODE_CLIENT)