mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix writing block header incorrectly
This commit is contained in:
parent
9b35b90a28
commit
d779dfd884
@ -179,6 +179,9 @@ public:
|
||||
m_current_block_header_offset = m_current_offset;
|
||||
m_current_block = {};
|
||||
m_current_block.countAndOffset.offset = static_cast<uint32_t>(m_file_offset);
|
||||
|
||||
// Reserve space to later write actual block header data
|
||||
GoTo(m_current_offset + sizeof(IPakDataBlockHeader));
|
||||
}
|
||||
|
||||
void WriteChunkData(const void* data, const size_t dataSize)
|
||||
@ -227,16 +230,16 @@ public:
|
||||
}
|
||||
|
||||
dataOffset += commandSize;
|
||||
m_file_offset += commandSize;
|
||||
}
|
||||
|
||||
m_file_offset += dataSize;
|
||||
}
|
||||
|
||||
void StartNewFile()
|
||||
{
|
||||
FlushBlock();
|
||||
StartNewBlock();
|
||||
|
||||
m_file_offset = 0u;
|
||||
StartNewBlock();
|
||||
m_chunk_buffer_window_start = utils::AlignToPrevious(m_current_offset, static_cast<int64_t>(ipak_consts::IPAK_CHUNK_SIZE));
|
||||
}
|
||||
|
||||
@ -250,13 +253,14 @@ public:
|
||||
const auto nameHash = T6::Common::R_HashString(imageName.c_str(), 0);
|
||||
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(imageData.get()), imageSize));
|
||||
|
||||
StartNewFile();
|
||||
const auto startOffset = m_current_block_header_offset;
|
||||
|
||||
IPakIndexEntry indexEntry;
|
||||
indexEntry.key.nameHash = nameHash;
|
||||
indexEntry.key.dataHash = dataHash & 0x1FFFFFFF;
|
||||
indexEntry.offset = static_cast<uint32_t>(m_current_offset - m_data_section_offset);
|
||||
indexEntry.offset = static_cast<uint32_t>(startOffset - m_data_section_offset);
|
||||
|
||||
StartNewFile();
|
||||
const auto startOffset = m_current_offset;
|
||||
WriteChunkData(imageData.get(), imageSize);
|
||||
const auto writtenImageSize = static_cast<size_t>(m_current_offset - startOffset);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user