mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-05-22 18:50:36 -04:00
lib: insert padding when listing objects too
Fixes a number of repacking issues with larger SI files
This commit is contained in:
parent
9452a41a71
commit
c0bfa09e35
3 changed files with 38 additions and 0 deletions
|
@ -449,6 +449,13 @@ Interleaf::Error Interleaf::Write(FileBase *f) const
|
||||||
|
|
||||||
void Interleaf::WriteObject(FileBase *f, const Object *o) 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());
|
||||||
|
}
|
||||||
|
|
||||||
RIFF::Chk mxob = RIFF::BeginChunk(f, RIFF::MxOb);
|
RIFF::Chk mxob = RIFF::BeginChunk(f, RIFF::MxOb);
|
||||||
|
|
||||||
f->WriteU16(o->type_);
|
f->WriteU16(o->type_);
|
||||||
|
|
|
@ -277,6 +277,35 @@ size_t Object::GetFileBodySize() const
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Object::CalculateMaximumDiskSize() const
|
||||||
|
{
|
||||||
|
size_t s = 0;
|
||||||
|
|
||||||
|
s += 108;
|
||||||
|
s += presenter_.size() + 1;
|
||||||
|
s += name_.size() + 1;
|
||||||
|
s += extra_.size();
|
||||||
|
|
||||||
|
if (type_ != MxOb::Presenter && type_ != MxOb::World && type_ != MxOb::Animation) {
|
||||||
|
s += filename_.size() + 1;
|
||||||
|
s += 24;
|
||||||
|
|
||||||
|
if (filetype_ == MxOb::WAV) {
|
||||||
|
s += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->HasChildren()) {
|
||||||
|
s += 16;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < this->GetChildCount(); i++) {
|
||||||
|
s += static_cast<Object*>(this->GetChildAt(i))->CalculateMaximumDiskSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
Object *Object::FindSubObjectWithID(uint32_t id)
|
Object *Object::FindSubObjectWithID(uint32_t id)
|
||||||
{
|
{
|
||||||
if (this->id() == id) {
|
if (this->id() == id) {
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
const std::string &filename() const { return filename_; }
|
const std::string &filename() const { return filename_; }
|
||||||
const ChunkedData &data() const { return data_; }
|
const ChunkedData &data() const { return data_; }
|
||||||
|
|
||||||
|
size_t CalculateMaximumDiskSize() const;
|
||||||
|
|
||||||
Object *FindSubObjectWithID(uint32_t id);
|
Object *FindSubObjectWithID(uint32_t id);
|
||||||
|
|
||||||
MxOb::Type type_;
|
MxOb::Type type_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue