2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-06-26 06:11:53 +00:00

refactor: hide implementation details of zone loading processors

This commit is contained in:
Jan
2025-05-02 19:34:51 +01:00
parent eb16dfcd00
commit 955df98279
17 changed files with 608 additions and 646 deletions

View File

@ -77,7 +77,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
SetupBlock(*zoneLoader);
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorInflate>(ZoneConstants::AUTHED_CHUNK_SIZE)));
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
// Start of the XFile struct
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(8));

View File

@ -136,7 +136,7 @@ namespace
zoneLoader.AddLoadingStep(std::make_unique<StepVerifySignature>(std::move(rsa), subHeaderHashSignaturePtr, subHeaderHashPtr));
auto subHeaderCapture = std::make_unique<ProcessorCaptureData>(sizeof(DB_AuthSubHeader));
auto subHeaderCapture = processor::CreateProcessorCaptureData(sizeof(DB_AuthSubHeader));
auto* subHeaderCapturePtr = subHeaderCapture.get();
zoneLoader.AddLoadingStep(std::make_unique<StepAddProcessor>(std::move(subHeaderCapture)));
@ -155,11 +155,11 @@ namespace
zoneLoader.AddLoadingStep(std::make_unique<StepSkipBytes>(ZoneConstants::AUTHED_CHUNK_SIZE - sizeof(DB_AuthHeader)));
zoneLoader.AddLoadingStep(std::make_unique<StepAddProcessor>(
std::make_unique<ProcessorAuthedBlocks>(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
ZoneConstants::AUTHED_CHUNK_SIZE,
static_cast<unsigned>(std::extent_v<decltype(DB_AuthSubHeader::masterBlockHashes)>),
cryptography::CreateSha256(),
masterBlockHashesPtr)));
processor::CreateProcessorAuthedBlocks(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
ZoneConstants::AUTHED_CHUNK_SIZE,
static_cast<unsigned>(std::extent_v<decltype(DB_AuthSubHeader::masterBlockHashes)>),
cryptography::CreateSha256(),
masterBlockHashesPtr)));
}
} // namespace
@ -193,11 +193,11 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
// Add steps for loading the auth header which also contain the signature of the zone if it is signed.
AddAuthHeaderSteps(isSecure, isOfficial, *zoneLoader, fileName);
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorInflate>(ZoneConstants::AUTHED_CHUNK_SIZE)));
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
if (isIw4x) // IW4x has one extra byte of padding here for protection purposes
{
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorIW4xDecryption>()));
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(processor::CreateProcessorIW4xDecryption()));
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(1));
}

View File

@ -120,7 +120,7 @@ namespace
zoneLoader.AddLoadingStep(std::make_unique<StepVerifySignature>(std::move(rsa), subHeaderHashSignaturePtr, subHeaderHashPtr));
auto subHeaderCapture = std::make_unique<ProcessorCaptureData>(sizeof(DB_AuthSubHeader));
auto subHeaderCapture = processor::CreateProcessorCaptureData(sizeof(DB_AuthSubHeader));
auto* subHeaderCapturePtr = subHeaderCapture.get();
zoneLoader.AddLoadingStep(std::make_unique<StepAddProcessor>(std::move(subHeaderCapture)));
@ -139,11 +139,11 @@ namespace
zoneLoader.AddLoadingStep(std::make_unique<StepSkipBytes>(ZoneConstants::AUTHED_CHUNK_SIZE - sizeof(DB_AuthHeader)));
zoneLoader.AddLoadingStep(std::make_unique<StepAddProcessor>(
std::make_unique<ProcessorAuthedBlocks>(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
ZoneConstants::AUTHED_CHUNK_SIZE,
static_cast<unsigned>(std::extent_v<decltype(DB_AuthSubHeader::masterBlockHashes)>),
cryptography::CreateSha256(),
masterBlockHashesPtr)));
processor::CreateProcessorAuthedBlocks(ZoneConstants::AUTHED_CHUNK_COUNT_PER_GROUP,
ZoneConstants::AUTHED_CHUNK_SIZE,
static_cast<unsigned>(std::extent_v<decltype(DB_AuthSubHeader::masterBlockHashes)>),
cryptography::CreateSha256(),
masterBlockHashesPtr)));
}
} // namespace
@ -176,7 +176,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
// Add steps for loading the auth header which also contain the signature of the zone if it is signed.
AddAuthHeaderSteps(isSecure, isOfficial, *zoneLoader, fileName);
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorInflate>(ZoneConstants::AUTHED_CHUNK_SIZE)));
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
// Start of the XFile struct
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(8));

View File

@ -77,7 +77,7 @@ std::unique_ptr<ZoneLoader> ZoneLoaderFactory::CreateLoaderForHeader(ZoneHeader&
SetupBlock(*zoneLoader);
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(std::make_unique<ProcessorInflate>(ZoneConstants::AUTHED_CHUNK_SIZE)));
zoneLoader->AddLoadingStep(std::make_unique<StepAddProcessor>(processor::CreateProcessorInflate(ZoneConstants::AUTHED_CHUNK_SIZE)));
// Start of the XFile struct
zoneLoader->AddLoadingStep(std::make_unique<StepSkipBytes>(8));

View File

@ -148,7 +148,7 @@ namespace
ICapturedDataProvider* AddXChunkProcessor(const bool isEncrypted, ZoneLoader& zoneLoader, std::string& fileName)
{
ICapturedDataProvider* result = nullptr;
auto xChunkProcessor = std::make_unique<ProcessorXChunks>(ZoneConstants::STREAM_COUNT, ZoneConstants::XCHUNK_SIZE, ZoneConstants::VANILLA_BUFFER_SIZE);
auto xChunkProcessor = processor::CreateProcessorXChunks(ZoneConstants::STREAM_COUNT, ZoneConstants::XCHUNK_SIZE, ZoneConstants::VANILLA_BUFFER_SIZE);
if (isEncrypted)
{