mirror of
https://github.com/isledecomp/SIEdit.git
synced 2024-11-27 09:35:45 -05:00
49 lines
904 B
C++
49 lines
904 B
C++
#include "interleaf.h"
|
|
|
|
namespace si {
|
|
|
|
Interleaf::Interleaf()
|
|
{
|
|
}
|
|
|
|
bool Interleaf::Parse(Chunk *riff)
|
|
{
|
|
if (riff->id() != Chunk::TYPE_RIFF) {
|
|
return false;
|
|
}
|
|
|
|
Chunk *hd = riff->FindChildWithType(Chunk::TYPE_MxHd);
|
|
if (!hd) {
|
|
return false;
|
|
}
|
|
|
|
version_ = hd->data("Version");
|
|
if (version_ == 0) {
|
|
// Unknown version
|
|
return false;
|
|
}
|
|
|
|
buffer_size_ = hd->data("BufferSize");
|
|
buffer_count_ = hd->data("BufferCount");
|
|
|
|
Chunk *of = riff->FindChildWithType(Chunk::TYPE_MxOf);
|
|
if (!of) {
|
|
return false;
|
|
}
|
|
|
|
const Data &offset_table = of->data("Offsets");
|
|
size_t offset_count = offset_table.size() / sizeof(uint32_t);
|
|
DeleteChildren();
|
|
for (size_t i=0; i<offset_count; i++) {
|
|
Stream *o = new Stream();
|
|
Chunk *st = riff->FindChildWithOffset(offset_table[i]);
|
|
if (!o->Parse(st)) {
|
|
return false;
|
|
}
|
|
AppendChild(o);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|