1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

Start work on loading

This commit is contained in:
Ted John
2018-12-15 12:46:32 +00:00
parent c264bc7b72
commit fbc120feba
7 changed files with 236 additions and 7 deletions

View File

@@ -17,6 +17,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 +42,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 +69,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 == 0x4B524150)
{
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;