mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-16 03:23:15 +01:00
Use streams for reading title sequence scripts
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#pragma endregion
|
||||
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include "../common.h"
|
||||
#include "../core/Collections.hpp"
|
||||
#include "../core/Console.hpp"
|
||||
@@ -39,7 +38,7 @@
|
||||
static std::vector<utf8 *> GetSaves(const utf8 * path);
|
||||
static std::vector<utf8 *> GetSaves(IZipArchive * zip);
|
||||
static std::vector<TitleCommand> LegacyScriptRead(utf8 * script, size_t scriptLength, std::vector<utf8 *> saves);
|
||||
static void LegacyScriptGetLine(SDL_RWops * file, char * parts);
|
||||
static void LegacyScriptGetLine(IStream * stream, char * parts);
|
||||
static void * ReadScriptFile(const utf8 * path, size_t * outSize);
|
||||
static utf8 * LegacyScriptWrite(TitleSequence * seq);
|
||||
|
||||
@@ -392,10 +391,11 @@ static std::vector<utf8 *> GetSaves(IZipArchive * zip)
|
||||
static std::vector<TitleCommand> LegacyScriptRead(utf8 * script, size_t scriptLength, std::vector<utf8 *> saves)
|
||||
{
|
||||
std::vector<TitleCommand> commands;
|
||||
SDL_RWops * file = SDL_RWFromMem(script, (sint32)scriptLength);
|
||||
do {
|
||||
auto fs = MemoryStream(script, scriptLength);
|
||||
do
|
||||
{
|
||||
char parts[3 * 128], *token, *part1, *part2;
|
||||
LegacyScriptGetLine(file, parts);
|
||||
LegacyScriptGetLine(&fs, parts);
|
||||
|
||||
token = &parts[0 * 128];
|
||||
part1 = &parts[1 * 128];
|
||||
@@ -466,13 +466,12 @@ static std::vector<TitleCommand> LegacyScriptRead(utf8 * script, size_t scriptLe
|
||||
{
|
||||
commands.push_back(command);
|
||||
}
|
||||
} while (SDL_RWtell(file) < (sint32)scriptLength);
|
||||
SDL_RWclose(file);
|
||||
|
||||
}
|
||||
while (fs.GetPosition() < scriptLength);
|
||||
return commands;
|
||||
}
|
||||
|
||||
static void LegacyScriptGetLine(SDL_RWops * file, char * parts)
|
||||
static void LegacyScriptGetLine(IStream * stream, char * parts)
|
||||
{
|
||||
for (sint32 i = 0; i < 3; i++)
|
||||
{
|
||||
@@ -486,7 +485,7 @@ static void LegacyScriptGetLine(SDL_RWops * file, char * parts)
|
||||
for (; part < 3;)
|
||||
{
|
||||
sint32 c = 0;
|
||||
if (SDL_RWread(file, &c, 1, 1) != 1)
|
||||
if (stream->TryRead(&c, 1) != 1)
|
||||
{
|
||||
c = EOF;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
struct SDL_RWops;
|
||||
|
||||
typedef struct TitleCommand
|
||||
{
|
||||
uint8 Type;
|
||||
|
||||
Reference in New Issue
Block a user