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

Get parks loading from ZIP working

This commit is contained in:
Ted John
2016-11-12 17:41:46 +00:00
parent 0c51dee94d
commit fb89826280
5 changed files with 112 additions and 26 deletions

View File

@@ -19,6 +19,7 @@
#include <zip.h>
#include <vector>
#include "../core/Collections.hpp"
#include "../core/Guard.hpp"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
@@ -77,6 +78,33 @@ extern "C"
Memory::Free(seq->Saves);
}
}
TitleSequenceParkHandle * TitleSequenceGetParkHandle(TitleSequence * seq, size_t index)
{
int error;
zip_t * zip = zip_open(seq->Path, ZIP_RDONLY, &error);
if (zip == nullptr)
{
// Unable to open zip
return nullptr;
}
Guard::Assert(index < seq->NumSaves, "Invalid park save index.");
utf8 * filename = seq->Saves[index];
auto handle = Memory::Allocate<TitleSequenceParkHandle>();
handle->Data = GetZipFileData(zip, filename, &handle->DataSize);
handle->RWOps = SDL_RWFromMem(handle->Data, (int)handle->DataSize);
handle->IsScenario = String::Equals(Path::GetExtension(filename), ".sc6", true);
return handle;
}
void TitleSequenceCloseParkHandle(TitleSequenceParkHandle * handle)
{
SDL_RWclose(handle->RWOps);
Memory::Free(handle->Data);
Memory::Free(handle);
}
}
static std::vector<utf8 *> GetSaves(zip_t * zip)