1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 13:03:11 +01:00

Remove S6Exporter

This commit is contained in:
Ted John
2021-04-03 03:37:57 +01:00
parent d70abcc84e
commit 8ff525270d
8 changed files with 46 additions and 1922 deletions

View File

@@ -15,6 +15,7 @@
#include <openrct2/Game.h>
#include <openrct2/GameState.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/ParkFile.h>
#include <openrct2/ParkImporter.h>
#include <openrct2/audio/AudioContext.h>
#include <openrct2/config/Config.h>
@@ -26,8 +27,8 @@
#include <openrct2/network/network.h>
#include <openrct2/object/ObjectManager.h>
#include <openrct2/platform/platform.h>
#include <openrct2/rct2/S6Exporter.h>
#include <openrct2/ride/Ride.h>
#include <openrct2/world/MapAnimation.h>
#include <openrct2/world/Park.h>
#include <openrct2/world/Sprite.h>
#include <stdio.h>
@@ -75,7 +76,7 @@ static void GameInit(bool retainSpatialIndices)
gGameSpeed = 1;
}
static bool ImportSave(MemoryStream& stream, std::unique_ptr<IContext>& context, bool retainSpatialIndices)
static bool ImportS6(MemoryStream& stream, std::unique_ptr<IContext>& context, bool retainSpatialIndices)
{
stream.SetPosition(0);
@@ -91,14 +92,29 @@ static bool ImportSave(MemoryStream& stream, std::unique_ptr<IContext>& context,
return true;
}
static bool ImportPark(MemoryStream& stream, std::unique_ptr<IContext>& context, bool retainSpatialIndices)
{
stream.SetPosition(0);
auto& objManager = context->GetObjectManager();
auto importer = ParkImporter::CreateParkFile(context->GetObjectRepository());
auto loadResult = importer->LoadFromStream(&stream, false);
objManager.LoadObjects(loadResult.RequiredObjects);
importer->Import();
GameInit(retainSpatialIndices);
return true;
}
static bool ExportSave(MemoryStream& stream, std::unique_ptr<IContext>& context)
{
auto& objManager = context->GetObjectManager();
auto exporter = std::make_unique<S6Exporter>();
auto exporter = std::make_unique<ParkFileExporter>();
exporter->ExportObjectsList = objManager.GetPackableObjects();
exporter->Export();
exporter->SaveGame(&stream);
exporter->Export(stream);
return true;
}
@@ -499,7 +515,7 @@ TEST(S6ImportExportBasic, all)
std::string testParkPath = TestData::GetParkPath("BigMapTest.sv6");
ASSERT_TRUE(LoadFileToBuffer(importBuffer, testParkPath));
ASSERT_TRUE(ImportSave(importBuffer, context, false));
ASSERT_TRUE(ImportS6(importBuffer, context, false));
importedState = GetGameState(context);
ASSERT_NE(importedState, nullptr);
@@ -514,7 +530,7 @@ TEST(S6ImportExportBasic, all)
bool initialised = context->Initialise();
ASSERT_TRUE(initialised);
ASSERT_TRUE(ImportSave(exportBuffer, context, true));
ASSERT_TRUE(ImportPark(exportBuffer, context, true));
exportedState = GetGameState(context);
ASSERT_NE(exportedState, nullptr);
@@ -548,7 +564,7 @@ TEST(S6ImportExportAdvanceTicks, all)
std::string testParkPath = TestData::GetParkPath("BigMapTest.sv6");
ASSERT_TRUE(LoadFileToBuffer(importBuffer, testParkPath));
ASSERT_TRUE(ImportSave(importBuffer, context, false));
ASSERT_TRUE(ImportS6(importBuffer, context, false));
AdvanceGameTicks(1000, context);
ASSERT_TRUE(ExportSave(exportBuffer, context));
@@ -564,7 +580,7 @@ TEST(S6ImportExportAdvanceTicks, all)
bool initialised = context->Initialise();
ASSERT_TRUE(initialised);
ASSERT_TRUE(ImportSave(exportBuffer, context, true));
ASSERT_TRUE(ImportPark(exportBuffer, context, true));
exportedState = GetGameState(context);
ASSERT_NE(exportedState, nullptr);