mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 23:08:05 -05:00
Move XChunk processors to ZoneCommon
This commit is contained in:
@ -8,8 +8,8 @@
|
||||
#include "Game/T6/GameT6.h"
|
||||
#include "Game/T6/ZoneConstantsT6.h"
|
||||
#include "Writing/Processor/OutputProcessorXChunks.h"
|
||||
#include "Writing/Processor/XChunks/XChunkOutputProcessorDeflate.h"
|
||||
#include "Writing/Processor/XChunks/XChunkOutputProcessorSalsa20.h"
|
||||
#include "Zone/XChunk/XChunkProcessorDeflate.h"
|
||||
#include "Zone/XChunk/XChunkProcessorSalsa20Encryption.h"
|
||||
#include "Writing/Steps/StepAddOutputProcessor.h"
|
||||
#include "Writing/Steps/StepWriteXBlockSizes.h"
|
||||
#include "Writing/Steps/StepWriteZoneContentToFile.h"
|
||||
@ -77,14 +77,14 @@ public:
|
||||
if (isEncrypted)
|
||||
{
|
||||
// If zone is encrypted, the decryption is applied before the decompression. T6 Zones always use Salsa20.
|
||||
auto chunkProcessorSalsa20 = std::make_unique<XChunkOutputProcessorSalsa20>(ZoneConstants::STREAM_COUNT, m_zone->m_name, ZoneConstants::SALSA20_KEY_TREYARCH,
|
||||
auto chunkProcessorSalsa20 = std::make_unique<XChunkProcessorSalsa20Encryption>(ZoneConstants::STREAM_COUNT, m_zone->m_name, ZoneConstants::SALSA20_KEY_TREYARCH,
|
||||
sizeof(ZoneConstants::SALSA20_KEY_TREYARCH));
|
||||
result = chunkProcessorSalsa20.get();
|
||||
xChunkProcessor->AddChunkProcessor(std::move(chunkProcessorSalsa20));
|
||||
}
|
||||
|
||||
// Decompress the chunks using zlib
|
||||
xChunkProcessor->AddChunkProcessor(std::make_unique<XChunkOutputProcessorDeflate>());
|
||||
xChunkProcessor->AddChunkProcessor(std::make_unique<XChunkProcessorDeflate>());
|
||||
m_writer->AddWritingStep(std::make_unique<StepAddOutputProcessor>(std::move(xChunkProcessor)));
|
||||
|
||||
// If there is encryption, the signed data of the zone is the final hash blocks provided by the Salsa20 IV adaption algorithm
|
||||
|
@ -32,7 +32,7 @@ OutputProcessorXChunks& OutputProcessorXChunks::operator=(OutputProcessorXChunks
|
||||
return *this;
|
||||
}
|
||||
|
||||
void OutputProcessorXChunks::AddChunkProcessor(std::unique_ptr<IXChunkOutputProcessor> chunkProcessor) const
|
||||
void OutputProcessorXChunks::AddChunkProcessor(std::unique_ptr<IXChunkProcessor> chunkProcessor) const
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "Writing/OutputStreamProcessor.h"
|
||||
#include "XChunks/IXChunkOutputProcessor.h"
|
||||
#include "Zone/XChunk/IXChunkProcessor.h"
|
||||
|
||||
class OutputProcessorXChunks final : public OutputStreamProcessor
|
||||
{
|
||||
@ -19,7 +19,7 @@ public:
|
||||
OutputProcessorXChunks& operator=(const OutputProcessorXChunks& other) = delete;
|
||||
OutputProcessorXChunks& operator=(OutputProcessorXChunks&& other) noexcept;
|
||||
|
||||
void AddChunkProcessor(std::unique_ptr<IXChunkOutputProcessor> chunkProcessor) const;
|
||||
void AddChunkProcessor(std::unique_ptr<IXChunkProcessor> chunkProcessor) const;
|
||||
|
||||
void Write(const void* buffer, size_t length) override;
|
||||
int64_t Pos() override;
|
||||
|
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
class IXChunkOutputProcessor
|
||||
{
|
||||
public:
|
||||
IXChunkOutputProcessor() = default;
|
||||
virtual ~IXChunkOutputProcessor() = default;
|
||||
IXChunkOutputProcessor(const IXChunkOutputProcessor& other) = default;
|
||||
IXChunkOutputProcessor(IXChunkOutputProcessor&& other) noexcept = default;
|
||||
IXChunkOutputProcessor& operator=(const IXChunkOutputProcessor& other) = default;
|
||||
IXChunkOutputProcessor& operator=(IXChunkOutputProcessor&& other) noexcept = default;
|
||||
|
||||
virtual size_t Process(int streamNumber, const uint8_t* input, size_t inputLength, uint8_t* output, size_t outputBufferSize) = 0;
|
||||
};
|
@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
#include "IXChunkOutputProcessor.h"
|
||||
|
||||
class XChunkOutputProcessorDeflate final : public IXChunkOutputProcessor
|
||||
{
|
||||
public:
|
||||
size_t Process(int streamNumber, const uint8_t* input, size_t inputLength, uint8_t* output, size_t outputBufferSize) override;
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include "IXChunkOutputProcessor.h"
|
||||
#include "Utils/ICapturedDataProvider.h"
|
||||
|
||||
class XChunkOutputProcessorSalsa20 final : public IXChunkOutputProcessor, public ICapturedDataProvider
|
||||
{
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
|
||||
public:
|
||||
XChunkOutputProcessorSalsa20(int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
|
||||
~XChunkOutputProcessorSalsa20() override;
|
||||
XChunkOutputProcessorSalsa20(const XChunkOutputProcessorSalsa20& other) = delete;
|
||||
XChunkOutputProcessorSalsa20(XChunkOutputProcessorSalsa20&& other) noexcept = default;
|
||||
XChunkOutputProcessorSalsa20& operator=(const XChunkOutputProcessorSalsa20& other) = delete;
|
||||
XChunkOutputProcessorSalsa20& operator=(XChunkOutputProcessorSalsa20&& other) noexcept = default;
|
||||
|
||||
size_t Process(int streamNumber, const uint8_t* input, size_t inputLength, uint8_t* output, size_t outputBufferSize) override;
|
||||
void GetCapturedData(const uint8_t** pCapturedData, size_t* pSize) override;
|
||||
};
|
@ -12,5 +12,21 @@ IZoneWriterFactory* ZoneWriterFactories[]
|
||||
|
||||
bool ZoneWriting::WriteZone(std::ostream& stream, Zone* zone)
|
||||
{
|
||||
return true;
|
||||
std::unique_ptr<ZoneWriter> zoneWriter;
|
||||
for (auto* factory : ZoneWriterFactories)
|
||||
{
|
||||
if(factory->SupportsZone(zone))
|
||||
{
|
||||
zoneWriter = factory->CreateWriter(zone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneWriter == nullptr)
|
||||
{
|
||||
printf("Could not create ZoneWriter for zone '%s'.\n", zone->m_name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
return zoneWriter->WriteZone(stream);
|
||||
}
|
||||
|
Reference in New Issue
Block a user