mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-26 06:11:53 +00:00
Add load argument to unlinker to load zones before trying to unlink specified zones
this allows to make sure certain ipaks are loaded before dumping
This commit is contained in:
@ -159,12 +159,13 @@ public:
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto* zone = new Zone(fileName, 0, &g_GameIW4);
|
||||
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zone, 0);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, &g_GameIW4);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_pools = std::make_unique<GameAssetPoolIW4>(zonePtr, 0);
|
||||
zone->m_language = GetZoneLanguage(fileName);
|
||||
|
||||
// File is supported. Now setup all required steps for loading this file.
|
||||
auto* zoneLoader = new ZoneLoader(zone);
|
||||
auto* zoneLoader = new ZoneLoader(std::move(zone));
|
||||
|
||||
SetupBlock(zoneLoader);
|
||||
|
||||
@ -185,7 +186,7 @@ public:
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zone, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
// Return the fully setup zoneloader
|
||||
return zoneLoader;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Game/T6/ZoneConstantsT6.h"
|
||||
@ -178,12 +179,13 @@ public:
|
||||
return nullptr;
|
||||
|
||||
// Create new zone
|
||||
auto* zone = new Zone(fileName, 0, &g_GameT6);
|
||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zone, 0);
|
||||
auto zone = std::make_unique<Zone>(fileName, 0, &g_GameT6);
|
||||
auto* zonePtr = zone.get();
|
||||
zone->m_pools = std::make_unique<GameAssetPoolT6>(zonePtr, 0);
|
||||
zone->m_language = GetZoneLanguage(fileName);
|
||||
|
||||
// File is supported. Now setup all required steps for loading this file.
|
||||
auto* zoneLoader = new ZoneLoader(zone);
|
||||
auto* zoneLoader = new ZoneLoader(std::move(zone));
|
||||
|
||||
SetupBlock(zoneLoader);
|
||||
|
||||
@ -201,7 +203,7 @@ public:
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepAllocXBlocks>());
|
||||
|
||||
// Start of the zone content
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zone, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
zoneLoader->AddLoadingStep(std::make_unique<StepLoadZoneContent>(std::make_unique<ContentLoader>(), zonePtr, ZoneConstants::OFFSET_BLOCK_BIT_COUNT, ZoneConstants::INSERT_BLOCK));
|
||||
|
||||
if (isSecure)
|
||||
{
|
||||
|
@ -1,26 +1,27 @@
|
||||
#include "ZoneLoader.h"
|
||||
#include "Exception/LoadingException.h"
|
||||
#include "LoadingFileStream.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
ZoneLoader::ZoneLoader(Zone* zone)
|
||||
#include "Exception/LoadingException.h"
|
||||
#include "LoadingFileStream.h"
|
||||
|
||||
ZoneLoader::ZoneLoader(std::unique_ptr<Zone> zone)
|
||||
: m_processor_chain_dirty(false),
|
||||
m_zone(std::move(zone))
|
||||
{
|
||||
m_zone = zone;
|
||||
m_processor_chain_dirty = false;
|
||||
}
|
||||
|
||||
ILoadingStream* ZoneLoader::BuildLoadingChain(ILoadingStream* rootStream)
|
||||
{
|
||||
auto* currentStream = rootStream;
|
||||
|
||||
for(const auto& processor : m_processors)
|
||||
for (const auto& processor : m_processors)
|
||||
{
|
||||
processor->SetBaseStream(currentStream);
|
||||
|
||||
currentStream = processor.get();
|
||||
}
|
||||
|
||||
|
||||
m_processor_chain_dirty = false;
|
||||
return currentStream;
|
||||
}
|
||||
@ -50,9 +51,9 @@ void ZoneLoader::AddStreamProcessor(std::unique_ptr<StreamProcessor> streamProce
|
||||
|
||||
void ZoneLoader::RemoveStreamProcessor(StreamProcessor* streamProcessor)
|
||||
{
|
||||
for(auto i = m_processors.begin(); i < m_processors.end(); ++i)
|
||||
for (auto i = m_processors.begin(); i < m_processors.end(); ++i)
|
||||
{
|
||||
if(i->get() == streamProcessor)
|
||||
if (i->get() == streamProcessor)
|
||||
{
|
||||
m_processors.erase(i);
|
||||
m_processor_chain_dirty = true;
|
||||
@ -61,18 +62,18 @@ void ZoneLoader::RemoveStreamProcessor(StreamProcessor* streamProcessor)
|
||||
}
|
||||
}
|
||||
|
||||
Zone* ZoneLoader::LoadZone(std::istream& stream)
|
||||
std::unique_ptr<Zone> ZoneLoader::LoadZone(std::istream& stream)
|
||||
{
|
||||
LoadingFileStream fileStream(stream);
|
||||
auto* endStream = BuildLoadingChain(&fileStream);
|
||||
|
||||
try
|
||||
{
|
||||
for(const auto& step : m_steps)
|
||||
for (const auto& step : m_steps)
|
||||
{
|
||||
step->PerformStep(this, endStream);
|
||||
|
||||
if(m_processor_chain_dirty)
|
||||
if (m_processor_chain_dirty)
|
||||
{
|
||||
endStream = BuildLoadingChain(&fileStream);
|
||||
}
|
||||
@ -83,12 +84,10 @@ Zone* ZoneLoader::LoadZone(std::istream& stream)
|
||||
const auto detailedMessage = e.DetailedMessage();
|
||||
printf("Loading fastfile failed: %s\n", detailedMessage.c_str());
|
||||
|
||||
delete m_zone;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
m_zone->Register();
|
||||
|
||||
return m_zone;
|
||||
return std::move(m_zone);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
|
||||
class ILoadingStep;
|
||||
|
||||
@ -17,14 +18,14 @@ class ZoneLoader
|
||||
|
||||
bool m_processor_chain_dirty;
|
||||
|
||||
Zone* m_zone;
|
||||
std::unique_ptr<Zone> m_zone;
|
||||
|
||||
ILoadingStream* BuildLoadingChain(ILoadingStream* rootStream);
|
||||
|
||||
public:
|
||||
std::vector<XBlock*> m_blocks;
|
||||
|
||||
explicit ZoneLoader(Zone* zone);
|
||||
explicit ZoneLoader(std::unique_ptr<Zone> zone);
|
||||
|
||||
void AddXBlock(std::unique_ptr<XBlock> block);
|
||||
void AddLoadingStep(std::unique_ptr<ILoadingStep> step);
|
||||
@ -32,5 +33,5 @@ public:
|
||||
|
||||
void RemoveStreamProcessor(StreamProcessor* streamProcessor);
|
||||
|
||||
Zone* LoadZone(std::istream& stream);
|
||||
std::unique_ptr<Zone> LoadZone(std::istream& stream);
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ IZoneLoaderFactory* ZoneLoaderFactories[]
|
||||
new T6::ZoneLoaderFactory()
|
||||
};
|
||||
|
||||
Zone* ZoneLoading::LoadZone(const std::string& path)
|
||||
std::unique_ptr<Zone> ZoneLoading::LoadZone(const std::string& path)
|
||||
{
|
||||
auto zoneName = fs::path(path).filename().replace_extension("").string();
|
||||
std::ifstream file(path, std::fstream::in | std::fstream::binary);
|
||||
@ -50,9 +50,9 @@ Zone* ZoneLoading::LoadZone(const std::string& path)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* loadedZone = zoneLoader->LoadZone(file);
|
||||
auto loadedZone = zoneLoader->LoadZone(file);
|
||||
delete zoneLoader;
|
||||
|
||||
file.close();
|
||||
return loadedZone;
|
||||
return std::move(loadedZone);
|
||||
}
|
@ -6,5 +6,5 @@
|
||||
class ZoneLoading
|
||||
{
|
||||
public:
|
||||
static Zone* LoadZone(const std::string& path);
|
||||
static std::unique_ptr<Zone> LoadZone(const std::string& path);
|
||||
};
|
||||
|
Reference in New Issue
Block a user