mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-18 18:57:57 -05:00
Write null memory at end of t6 fastfiles like the original linker does because the game's reader needs it for some reason
This commit is contained in:
@ -6,11 +6,12 @@ StepAddOutputProcessor::StepAddOutputProcessor(std::unique_ptr<OutputStreamProce
|
||||
{
|
||||
}
|
||||
|
||||
void StepAddOutputProcessor::PerformStep(ZoneWriter* zoneLoader, IWritingStream* stream)
|
||||
void StepAddOutputProcessor::PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream)
|
||||
{
|
||||
assert(zoneLoader != nullptr);
|
||||
assert(zoneWriter != nullptr);
|
||||
assert(m_stream_processor != nullptr);
|
||||
|
||||
zoneLoader->AddStreamProcessor(std::move(m_stream_processor));
|
||||
stream->Flush();
|
||||
zoneWriter->AddStreamProcessor(std::move(m_stream_processor));
|
||||
m_stream_processor = nullptr;
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Writing/OutputStreamProcessor.h"
|
||||
#include "Writing/IWritingStep.h"
|
||||
|
||||
class StepAddOutputProcessor final : public IWritingStep
|
||||
@ -11,5 +12,5 @@ class StepAddOutputProcessor final : public IWritingStep
|
||||
public:
|
||||
explicit StepAddOutputProcessor(std::unique_ptr<OutputStreamProcessor> streamProcessor);
|
||||
|
||||
void PerformStep(ZoneWriter* zoneLoader, IWritingStream* stream) override;
|
||||
void PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream) override;
|
||||
};
|
||||
|
17
src/ZoneWriting/Writing/Steps/StepAlign.cpp
Normal file
17
src/ZoneWriting/Writing/Steps/StepAlign.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "StepAlign.h"
|
||||
|
||||
StepAlign::StepAlign(const size_t alignTo, const uint8_t alignValue)
|
||||
: m_align_to(alignTo),
|
||||
m_align_value(alignValue)
|
||||
{
|
||||
}
|
||||
|
||||
void StepAlign::PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream)
|
||||
{
|
||||
const auto pos = stream->Pos();
|
||||
const auto targetPos = (pos + m_align_to - 1) / m_align_to * m_align_to;
|
||||
const auto valueCount = static_cast<size_t>(targetPos - pos);
|
||||
|
||||
for(auto i = 0u; i < valueCount; i++)
|
||||
stream->Write(&m_align_value, sizeof(m_align_value));
|
||||
}
|
17
src/ZoneWriting/Writing/Steps/StepAlign.h
Normal file
17
src/ZoneWriting/Writing/Steps/StepAlign.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Writing/IWritingStep.h"
|
||||
|
||||
class StepAlign final : public IWritingStep
|
||||
{
|
||||
size_t m_align_to;
|
||||
uint8_t m_align_value;
|
||||
|
||||
public:
|
||||
StepAlign(size_t alignTo, uint8_t alignValue);
|
||||
|
||||
void PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream) override;
|
||||
};
|
12
src/ZoneWriting/Writing/Steps/StepRemoveOutputProcessor.cpp
Normal file
12
src/ZoneWriting/Writing/Steps/StepRemoveOutputProcessor.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "StepRemoveOutputProcessor.h"
|
||||
|
||||
StepRemoveOutputProcessor::StepRemoveOutputProcessor(OutputStreamProcessor* streamProcessor)
|
||||
: m_stream_processor(streamProcessor)
|
||||
{
|
||||
}
|
||||
|
||||
void StepRemoveOutputProcessor::PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream)
|
||||
{
|
||||
stream->Flush();
|
||||
zoneWriter->RemoveStreamProcessor(m_stream_processor);
|
||||
}
|
14
src/ZoneWriting/Writing/Steps/StepRemoveOutputProcessor.h
Normal file
14
src/ZoneWriting/Writing/Steps/StepRemoveOutputProcessor.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Writing/OutputStreamProcessor.h"
|
||||
#include "Writing/IWritingStep.h"
|
||||
|
||||
class StepRemoveOutputProcessor final : public IWritingStep
|
||||
{
|
||||
OutputStreamProcessor* m_stream_processor;
|
||||
|
||||
public:
|
||||
explicit StepRemoveOutputProcessor(OutputStreamProcessor* streamProcessor);
|
||||
|
||||
void PerformStep(ZoneWriter* zoneWriter, IWritingStream* stream) override;
|
||||
};
|
Reference in New Issue
Block a user