mirror of
https://github.com/isledecomp/SIEdit.git
synced 2024-11-27 01:25:45 -05:00
correctly write padding for MxSts
This commit is contained in:
parent
cc4534c999
commit
4009e0c278
2 changed files with 15 additions and 6 deletions
|
@ -404,6 +404,9 @@ Interleaf::Error Interleaf::Write(FileBase *f) const
|
|||
continue;
|
||||
}
|
||||
|
||||
size_t maxSz = child->CalculateMaximumDiskSize() + kMinimumChunkSize;
|
||||
WritePaddingIfNecessary(f, maxSz);
|
||||
|
||||
uint32_t mxst_offset = f->pos();
|
||||
|
||||
f->seek(size_t(offset_table_pos) + i * sizeof(uint32_t));
|
||||
|
@ -455,12 +458,7 @@ Interleaf::Error Interleaf::Write(FileBase *f) const
|
|||
|
||||
void Interleaf::WriteObject(FileBase *f, const Object *o) const
|
||||
{
|
||||
size_t projected_end = f->pos() + o->CalculateMaximumDiskSize();
|
||||
size_t this_buf = f->pos()/m_BufferSize;
|
||||
size_t end_buf = projected_end/m_BufferSize;
|
||||
if (this_buf != end_buf) {
|
||||
WritePadding(f, (end_buf * m_BufferSize) - f->pos());
|
||||
}
|
||||
WritePaddingIfNecessary(f, o->CalculateMaximumDiskSize());
|
||||
|
||||
RIFF::Chk mxob = RIFF::BeginChunk(f, RIFF::MxOb);
|
||||
|
||||
|
@ -747,4 +745,14 @@ void Interleaf::WritePadding(FileBase *f, uint32_t size) const
|
|||
f->WriteBytes(b);
|
||||
}
|
||||
|
||||
void Interleaf::WritePaddingIfNecessary(FileBase *f, size_t projectedWrite) const
|
||||
{
|
||||
size_t projected_end = f->pos() + projectedWrite;
|
||||
size_t this_buf = f->pos()/m_BufferSize;
|
||||
size_t end_buf = projected_end/m_BufferSize;
|
||||
if (this_buf != end_buf) {
|
||||
WritePadding(f, (end_buf * m_BufferSize) - f->pos());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ private:
|
|||
void WriteSubChunkInternal(FileBase *f, uint16_t flags, uint32_t object, uint32_t time, uint32_t data_sz, const bytearray &data) const;
|
||||
|
||||
void WritePadding(FileBase *f, uint32_t size) const;
|
||||
void WritePaddingIfNecessary(FileBase *f, size_t projectedWrite) const;
|
||||
|
||||
Info m_Info;
|
||||
|
||||
|
|
Loading…
Reference in a new issue