diff --git a/src/ZoneLoading/Loading/Steps/StepDumpData.cpp b/src/ZoneLoading/Loading/Steps/StepDumpData.cpp new file mode 100644 index 00000000..2a56a244 --- /dev/null +++ b/src/ZoneLoading/Loading/Steps/StepDumpData.cpp @@ -0,0 +1,38 @@ +#include "StepDumpData.h" + +StepDumpData::StepDumpData(const unsigned int dumpCount) +{ + m_dump_count = dumpCount; +} + +void StepDumpData::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) +{ + uint8_t tempBuffer[128]; + unsigned int dumpedBytes = 0; + + FileAPI::File tempFile = FileAPI::Open("dump.dat", FileAPI::Mode::MODE_WRITE); + + while (dumpedBytes < m_dump_count) + { + unsigned int toDump; + + if (m_dump_count - dumpedBytes < sizeof(tempBuffer)) + { + toDump = m_dump_count - dumpedBytes; + } + else + { + toDump = sizeof(tempBuffer); + } + + const size_t loadedSize = stream->Load(tempBuffer, toDump); + dumpedBytes += loadedSize; + + if (loadedSize == 0) + break; + + tempFile.Write(tempBuffer, 1, loadedSize); + } + + tempFile.Close(); +} \ No newline at end of file diff --git a/src/ZoneLoading/Loading/Steps/StepDumpData.h b/src/ZoneLoading/Loading/Steps/StepDumpData.h new file mode 100644 index 00000000..021e7391 --- /dev/null +++ b/src/ZoneLoading/Loading/Steps/StepDumpData.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Loading/ILoadingStep.h" + +class StepDumpData final : public ILoadingStep +{ + unsigned int m_dump_count; + +public: + explicit StepDumpData(unsigned int dumpCount); + + void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override; +}; \ No newline at end of file