refactor: fix x64 compilation for ZoneLoading

This commit is contained in:
Jan
2025-04-26 11:45:33 +01:00
committed by Jan Laupetin
parent de43e33dcd
commit 3b00c1d45b
13 changed files with 75 additions and 79 deletions

View File

@ -50,20 +50,20 @@ public:
size_t Load(void* buffer, const size_t length)
{
m_stream.next_out = static_cast<Bytef*>(buffer);
m_stream.avail_out = length;
m_stream.avail_out = static_cast<unsigned>(length);
while (m_stream.avail_out > 0)
{
if (m_stream.avail_in == 0)
{
m_stream.avail_in = m_base->m_base_stream->Load(m_buffer.get(), m_buffer_size);
m_stream.avail_in = static_cast<unsigned>(m_base->m_base_stream->Load(m_buffer.get(), m_buffer_size));
m_stream.next_in = m_buffer.get();
if (m_stream.avail_in == 0) // EOF
return length - m_stream.avail_out;
}
auto ret = inflate(&m_stream, Z_SYNC_FLUSH);
const auto ret = inflate(&m_stream, Z_SYNC_FLUSH);
if (ret < 0)
throw InvalidCompressionException();

View File

@ -78,7 +78,7 @@ public:
m_is_loading = false;
}
uint8_t* GetInputBuffer() const
[[nodiscard]] uint8_t* GetInputBuffer() const
{
return m_input_buffer;
}
@ -140,9 +140,9 @@ class ProcessorXChunks::ProcessorXChunksImpl
bool m_eof_reached;
unsigned int m_eof_stream;
void AdvanceStream(const unsigned int streamNum)
void AdvanceStream(const unsigned streamNum)
{
assert(streamNum >= 0 && streamNum < m_streams.size());
assert(streamNum < m_streams.size());
if (m_eof_reached)
return;
@ -203,8 +203,8 @@ class ProcessorXChunks::ProcessorXChunksImpl
m_initialized_streams = true;
m_vanilla_buffer_offset = static_cast<size_t>(m_base->m_base_stream->Pos());
const unsigned int streamCount = m_streams.size();
for (unsigned int streamNum = 0; streamNum < streamCount; streamNum++)
const auto streamCount = static_cast<unsigned>(m_streams.size());
for (auto streamNum = 0u; streamNum < streamCount; streamNum++)
{
AdvanceStream(streamNum);
}
@ -214,7 +214,7 @@ class ProcessorXChunks::ProcessorXChunksImpl
m_streams[0]->GetOutput(&m_current_chunk, &m_current_chunk_size);
}
bool EndOfStream() const
[[nodiscard]] bool EndOfStream() const
{
return m_eof_reached && m_eof_stream == m_current_stream;
}

View File

@ -6,10 +6,10 @@ const uint64_t StepAllocXBlocks::MAX_XBLOCK_SIZE = 0x3C000000;
void StepAllocXBlocks::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
{
const unsigned int blockCount = zoneLoader->m_blocks.size();
const auto blockCount = static_cast<unsigned>(zoneLoader->m_blocks.size());
auto* blockSizes = new xblock_size_t[blockCount];
stream->Load(blockSizes, sizeof(xblock_size_t) * blockCount);
const auto blockSizes = std::make_unique<xblock_size_t[]>(blockCount);
stream->Load(blockSizes.get(), sizeof(xblock_size_t) * blockCount);
uint64_t totalMemory = 0;
for (unsigned int block = 0; block < blockCount; block++)
@ -26,6 +26,4 @@ void StepAllocXBlocks::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* strea
{
zoneLoader->m_blocks[block]->Alloc(blockSizes[block]);
}
delete[] blockSizes;
}

View File

@ -2,21 +2,21 @@
#include <fstream>
StepDumpData::StepDumpData(const unsigned int dumpCount)
StepDumpData::StepDumpData(const size_t dumpCount)
: m_dump_count(dumpCount)
{
m_dump_count = dumpCount;
}
void StepDumpData::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
{
uint8_t tempBuffer[128];
unsigned int dumpedBytes = 0;
auto dumpedBytes = 0uz;
std::ofstream tempFile("dump.dat", std::fstream::out | std::fstream::binary);
while (dumpedBytes < m_dump_count)
{
unsigned int toDump;
size_t toDump;
if (m_dump_count - dumpedBytes < sizeof(tempBuffer))
{
@ -33,7 +33,7 @@ void StepDumpData::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
if (loadedSize == 0)
break;
tempFile.write(reinterpret_cast<char*>(tempBuffer), loadedSize);
tempFile.write(reinterpret_cast<char*>(tempBuffer), static_cast<std::streamsize>(loadedSize));
}
tempFile.close();

View File

@ -4,10 +4,11 @@
class StepDumpData final : public ILoadingStep
{
unsigned int m_dump_count;
public:
explicit StepDumpData(unsigned int dumpCount);
explicit StepDumpData(size_t dumpCount);
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
private:
size_t m_dump_count;
};

View File

@ -1,18 +1,18 @@
#include "StepSkipBytes.h"
StepSkipBytes::StepSkipBytes(const unsigned int skipCount)
StepSkipBytes::StepSkipBytes(const size_t skipCount)
: m_skip_count(skipCount)
{
m_skip_count = skipCount;
}
void StepSkipBytes::PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream)
{
uint8_t tempBuffer[128];
unsigned int skippedBytes = 0;
auto skippedBytes = 0uz;
while (skippedBytes < m_skip_count)
{
unsigned int toSkip;
size_t toSkip;
if (m_skip_count - skippedBytes < sizeof(tempBuffer))
{

View File

@ -4,10 +4,11 @@
class StepSkipBytes final : public ILoadingStep
{
unsigned int m_skip_count;
public:
explicit StepSkipBytes(unsigned int skipCount);
explicit StepSkipBytes(size_t skipCount);
void PerformStep(ZoneLoader* zoneLoader, ILoadingStream* stream) override;
private:
size_t m_skip_count;
};