mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 04:53:12 +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:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "FileClassifier.h"
|
||||
|
||||
#include "ParkFile.h"
|
||||
#include "core/Console.hpp"
|
||||
#include "core/FileStream.h"
|
||||
#include "core/Path.hpp"
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "scenario/Scenario.h"
|
||||
#include "util/SawyerCoding.h"
|
||||
|
||||
static bool TryClassifyAsPark(OpenRCT2::IStream* stream, ClassifiedFileInfo* result);
|
||||
static bool TryClassifyAsS6(OpenRCT2::IStream* stream, ClassifiedFileInfo* result);
|
||||
static bool TryClassifyAsS4(OpenRCT2::IStream* stream, ClassifiedFileInfo* result);
|
||||
static bool TryClassifyAsTD4_TD6(OpenRCT2::IStream* stream, ClassifiedFileInfo* result);
|
||||
@@ -41,6 +43,12 @@ bool TryClassifyFile(OpenRCT2::IStream* stream, ClassifiedFileInfo* result)
|
||||
// between them is to decode it. Decoding however is currently not protected
|
||||
// against invalid compression data for that decoding algorithm and will crash.
|
||||
|
||||
// Park detection
|
||||
if (TryClassifyAsPark(stream, result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// S6 detection
|
||||
if (TryClassifyAsS6(stream, result))
|
||||
{
|
||||
@@ -62,6 +70,29 @@ bool TryClassifyFile(OpenRCT2::IStream* stream, ClassifiedFileInfo* result)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TryClassifyAsPark(OpenRCT2::IStream* stream, ClassifiedFileInfo* result)
|
||||
{
|
||||
bool success = false;
|
||||
uint64_t originalPosition = stream->GetPosition();
|
||||
try
|
||||
{
|
||||
auto magic = stream->ReadValue<uint32_t>();
|
||||
if (magic == OpenRCT2::PARK_FILE_MAGIC)
|
||||
{
|
||||
result->Type = FILE_TYPE::PARK;
|
||||
result->Version = 0;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
success = false;
|
||||
log_verbose(e.what());
|
||||
}
|
||||
stream->SetPosition(originalPosition);
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool TryClassifyAsS6(OpenRCT2::IStream* stream, ClassifiedFileInfo* result)
|
||||
{
|
||||
bool success = false;
|
||||
@@ -183,5 +214,7 @@ uint32_t get_file_extension_type(const utf8* path)
|
||||
return FILE_EXTENSION_SV6;
|
||||
if (String::Equals(extension, ".td6", true))
|
||||
return FILE_EXTENSION_TD6;
|
||||
if (String::Equals(extension, ".park", true))
|
||||
return FILE_EXTENSION_PARK;
|
||||
return FILE_EXTENSION_UNKNOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user