Merge pull request #59 from lioncash/enum

General: Be explicit about athena's SeekOrigin type
This commit is contained in:
Phillip Stephens 2019-09-08 00:13:44 -07:00 committed by GitHub
commit 1992060927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 93 additions and 85 deletions

View File

@ -669,11 +669,12 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os, athena::io::I
} }
} }
if (s < secCount - 1) if (s < secCount - 1) {
reader.seek(secStart + secSizes[s], athena::Begin); reader.seek(secStart + secSizes[s], athena::SeekOrigin::Begin);
}
} }
reader.seek(afterHeaderPos, athena::Begin); reader.seek(afterHeaderPos, athena::SeekOrigin::Begin);
visitedDLOffsets = false; visitedDLOffsets = false;
unsigned createdUVLayers = 0; unsigned createdUVLayers = 0;
@ -989,8 +990,9 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os, athena::io::I
} }
} }
if (s < secCount - 1) if (s < secCount - 1) {
reader.seek(secStart + secSizes[s], athena::Begin); reader.seek(secStart + secSizes[s], athena::SeekOrigin::Begin);
}
} }
/* Finish Mesh */ /* Finish Mesh */
@ -1086,8 +1088,9 @@ void NameCMDL(athena::io::IStreamReader& reader, PAKRouter& pakRouter, typename
matSet.nameTextures(pakRouter, bestName.c_str(), s); matSet.nameTextures(pakRouter, bestName.c_str(), s);
} }
if (s < head.secCount - 1) if (s < head.secCount - 1) {
reader.seek(secStart + head.secSizes[s], athena::Begin); reader.seek(secStart + head.secSizes[s], athena::SeekOrigin::Begin);
}
} }
} }
@ -1545,7 +1548,7 @@ bool WriteHMDLCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& in
} }
/* Ensure final surface's alignment writes zeros */ /* Ensure final surface's alignment writes zeros */
writer.seek(-1, athena::Current); writer.seek(-1, athena::SeekOrigin::Current);
writer.writeUByte(0); writer.writeUByte(0);
writer.close(); writer.close();
return true; return true;
@ -2040,7 +2043,7 @@ void SurfaceHeader_1::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig(); aabb[1] = reader.readVec3fBig();
remAABB -= 24; remAABB -= 24;
} }
reader.seek(remAABB, athena::Current); reader.seek(remAABB, athena::SeekOrigin::Current);
/* align */ /* align */
reader.seekAlign32(); reader.seekAlign32();
} }
@ -2104,7 +2107,7 @@ void SurfaceHeader_2::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig(); aabb[1] = reader.readVec3fBig();
remAABB -= 24; remAABB -= 24;
} }
reader.seek(remAABB, athena::Current); reader.seek(remAABB, athena::SeekOrigin::Current);
/* align */ /* align */
reader.seekAlign32(); reader.seekAlign32();
} }
@ -2172,7 +2175,7 @@ void SurfaceHeader_3::Enumerate<BigDNA::Read>(typename Read::StreamT& reader) {
aabb[1] = reader.readVec3fBig(); aabb[1] = reader.readVec3fBig();
remAABB -= 24; remAABB -= 24;
} }
reader.seek(remAABB, athena::Current); reader.seek(remAABB, athena::SeekOrigin::Current);
/* unk3 */ /* unk3 */
unk3 = reader.readUByte(); unk3 = reader.readUByte();
/* align */ /* align */

View File

@ -34,15 +34,17 @@ public:
LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun")); LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun"));
} }
void seek(atInt64 pos, athena::SeekOrigin origin) override { void seek(atInt64 pos, athena::SeekOrigin origin) override {
if (origin == athena::Begin) if (origin == athena::SeekOrigin::Begin) {
m_pos = pos; m_pos = pos;
else if (origin == athena::Current) } else if (origin == athena::SeekOrigin::Current) {
m_pos += pos; m_pos += pos;
else if (origin == athena::End) } else if (origin == athena::SeekOrigin::End) {
m_pos = m_sz + pos; m_pos = m_sz + pos;
if (m_pos > m_sz) }
if (m_pos > m_sz) {
LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun")); LogDNACommon.report(logvisor::Fatal, fmt("PAK stream cursor overrun"));
} }
}
atUint64 position() const override { return m_pos; } atUint64 position() const override { return m_pos; }
atUint64 length() const override { return m_sz; } atUint64 length() const override { return m_sz; }
const atUint8* data() const { return m_buf.get(); } const atUint8* data() const { return m_buf.get(); }

View File

@ -116,7 +116,7 @@ void PAKBridge::build() {
if (worldMapEnt) { if (worldMapEnt) {
worldMapEnt->name = entry.name + "_mapw"; worldMapEnt->name = entry.name + "_mapw";
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node); PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current); rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big(); atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount); mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i) for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -46,7 +46,7 @@ void MREA::AddCMDLRigPairs(PAKEntryReadStream& rs, PAKRouter<PAKBridge>& pakRout
atUint64 secStart = rs.position(); atUint64 secStart = rs.position();
while (curSec != head.sclySecIdx) while (curSec != head.sclySecIdx)
secStart += head.secSizes[curSec++]; secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin); rs.seek(secStart, athena::SeekOrigin::Begin);
SCLY scly; SCLY scly;
scly.read(rs); scly.read(rs);
scly.addCMDLRigPairs(pakRouter, charAssoc); scly.addCMDLRigPairs(pakRouter, charAssoc);
@ -65,7 +65,7 @@ UniqueID32 MREA::GetPATHId(PAKEntryReadStream& rs) {
secStart += head.secSizes[curSec++]; secStart += head.secSizes[curSec++];
if (!head.secSizes[curSec]) if (!head.secSizes[curSec])
return {}; return {};
rs.seek(secStart, athena::Begin); rs.seek(secStart, athena::SeekOrigin::Begin);
return {rs}; return {rs};
} }
@ -231,7 +231,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = rs.position(); atUint64 secStart = rs.position();
matSet.read(rs); matSet.read(rs);
matSet.readToBlender(os, pakRouter, entry, 0); matSet.readToBlender(os, pakRouter, entry, 0);
rs.seek(secStart + head.secSizes[0], athena::Begin); rs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs; std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs); DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -241,7 +241,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader; MeshHeader mHeader;
secStart = rs.position(); secStart = rs.position();
mHeader.read(rs); mHeader.read(rs);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin); rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_1>( curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_1>(
os, rs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]); os, rs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]);
os.format(fmt( os.format(fmt(
@ -255,14 +255,14 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip AROT */ /* Skip AROT */
secStart = rs.position(); secStart = rs.position();
rs.seek(secStart + head.secSizes[curSec++], athena::Begin); rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Read SCLY layers */ /* Read SCLY layers */
secStart = rs.position(); secStart = rs.position();
SCLY scly; SCLY scly;
scly.read(rs); scly.read(rs);
scly.exportToLayerDirectories(entry, pakRouter, force); scly.exportToLayerDirectories(entry, pakRouter, force);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin); rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Read collision meshes */ /* Read collision meshes */
DeafBabe collision; DeafBabe collision;
@ -270,32 +270,32 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(rs); collision.read(rs);
DeafBabe::BlenderInit(os); DeafBabe::BlenderInit(os);
collision.sendToBlender(os); collision.sendToBlender(os);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin); rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Skip unknown section */ /* Skip unknown section */
rs.seek(head.secSizes[curSec++], athena::Current); rs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read BABEDEAD Lights as Cycles emissives */ /* Read BABEDEAD Lights as Cycles emissives */
secStart = rs.position(); secStart = rs.position();
ReadBabeDeadToBlender_1_2(os, rs); ReadBabeDeadToBlender_1_2(os, rs);
rs.seek(secStart + head.secSizes[curSec++], athena::Begin); rs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Dump VISI entities */ /* Dump VISI entities */
secStart = rs.position(); secStart = rs.position();
if (head.secSizes[curSec] && rs.readUint32Big() == 'VISI') { if (head.secSizes[curSec] && rs.readUint32Big() == 'VISI') {
{ {
rs.seek(secStart, athena::Begin); rs.seek(secStart, athena::SeekOrigin::Begin);
auto visiData = rs.readUBytes(head.secSizes[curSec]); auto visiData = rs.readUBytes(head.secSizes[curSec]);
athena::io::FileWriter visiOut(outPath.getWithExtension(_SYS_STR(".visi"), true).getAbsolutePath()); athena::io::FileWriter visiOut(outPath.getWithExtension(_SYS_STR(".visi"), true).getAbsolutePath());
visiOut.writeUBytes(visiData.get(), head.secSizes[curSec]); visiOut.writeUBytes(visiData.get(), head.secSizes[curSec]);
rs.seek(secStart + 4, athena::Begin); rs.seek(secStart + 4, athena::SeekOrigin::Begin);
} }
athena::io::YAMLDocWriter visiWriter("VISI"); athena::io::YAMLDocWriter visiWriter("VISI");
if (auto __vec = visiWriter.enterSubVector("entities")) { if (auto __vec = visiWriter.enterSubVector("entities")) {
rs.seek(18, athena::Current); rs.seek(18, athena::SeekOrigin::Current);
uint32_t entityCount = rs.readUint32Big(); uint32_t entityCount = rs.readUint32Big();
rs.seek(8, athena::Current); rs.seek(8, athena::SeekOrigin::Current);
for (uint32_t i = 0; i < entityCount; ++i) { for (uint32_t i = 0; i < entityCount; ++i) {
uint32_t entityId = rs.readUint32Big(); uint32_t entityId = rs.readUint32Big();
visiWriter.writeUint32(nullptr, entityId); visiWriter.writeUint32(nullptr, entityId);
@ -332,14 +332,14 @@ void MREA::Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter<PAKB
MaterialSet matSet; MaterialSet matSet;
matSet.read(rs); matSet.read(rs);
matSet.nameTextures(pakRouter, fmt::format(fmt("MREA_{}"), entry.id).c_str(), -1); matSet.nameTextures(pakRouter, fmt::format(fmt("MREA_{}"), entry.id).c_str(), -1);
rs.seek(secStart + head.secSizes[0], athena::Begin); rs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
/* Skip to SCLY */ /* Skip to SCLY */
atUint32 curSec = 1; atUint32 curSec = 1;
secStart = rs.position(); secStart = rs.position();
while (curSec != head.sclySecIdx) while (curSec != head.sclySecIdx)
secStart += head.secSizes[curSec++]; secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin); rs.seek(secStart, athena::SeekOrigin::Begin);
SCLY scly; SCLY scly;
scly.read(rs); scly.read(rs);
scly.nameIDs(pakRouter); scly.nameIDs(pakRouter);
@ -347,7 +347,7 @@ void MREA::Name(const SpecBase& dataSpec, PAKEntryReadStream& rs, PAKRouter<PAKB
/* Skip to PATH */ /* Skip to PATH */
while (curSec != head.pathSecIdx) while (curSec != head.pathSecIdx)
secStart += head.secSizes[curSec++]; secStart += head.secSizes[curSec++];
rs.seek(secStart, athena::Begin); rs.seek(secStart, athena::SeekOrigin::Begin);
UniqueID32 pathID(rs); UniqueID32 pathID(rs);
const nod::Node* node; const nod::Node* node;

View File

@ -13,7 +13,7 @@ void SCLY::Enumerate<BigDNA::Read>(athena::io::IStreamReader& rs) {
rs.enumerate<ScriptLayer>(layers, layerCount, [&i, this](athena::io::IStreamReader& rs, ScriptLayer& layer) { rs.enumerate<ScriptLayer>(layers, layerCount, [&i, this](athena::io::IStreamReader& rs, ScriptLayer& layer) {
atUint64 start = rs.position(); atUint64 start = rs.position();
layer.read(rs); layer.read(rs);
rs.seek(start + layerSizes[i++], athena::Begin); rs.seek(start + layerSizes[i++], athena::SeekOrigin::Begin);
}); });
} }
@ -118,11 +118,12 @@ void SCLY::ScriptLayer::Enumerate<BigDNA::Read>(athena::io::IStreamReader& rs) {
fmt(_SYS_STR("Error while reading object of type 0x{:02X}, did not read the expected amount of " fmt(_SYS_STR("Error while reading object of type 0x{:02X}, did not read the expected amount of "
"data, read 0x{:x}, expected 0x{:x}")), "data, read 0x{:x}, expected 0x{:x}")),
(atUint32)type, actualLen, len); (atUint32)type, actualLen, len);
rs.seek(start + len, athena::Begin); rs.seek(start + len, athena::SeekOrigin::Begin);
} else } else {
Log.report(logvisor::Fatal, fmt(_SYS_STR("Unable to find type 0x{:X} in object database")), (atUint32)type); Log.report(logvisor::Fatal, fmt(_SYS_STR("Unable to find type 0x{:X} in object database")), (atUint32)type);
} }
} }
}
template <> template <>
void SCLY::ScriptLayer::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& rs) { void SCLY::ScriptLayer::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& rs) {

View File

@ -86,7 +86,7 @@ void PAKBridge::build() {
std::vector<UniqueID32> mapw; std::vector<UniqueID32> mapw;
if (worldMapEnt) { if (worldMapEnt) {
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node); PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current); rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big(); atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount); mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i) for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -80,10 +80,11 @@ MREA::StreamReader::StreamReader(athena::io::IStreamReader& source, atUint32 blk
void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) { void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
atUint64 target = diff; atUint64 target = diff;
if (whence == athena::Current) if (whence == athena::SeekOrigin::Current) {
target = m_pos + diff; target = m_pos + diff;
else if (whence == athena::End) } else if (whence == athena::SeekOrigin::End) {
target = m_totalDecompLen - diff; target = m_totalDecompLen - diff;
}
if (target >= m_totalDecompLen) if (target >= m_totalDecompLen)
Log.report(logvisor::Fatal, fmt("MREA stream seek overrun")); Log.report(logvisor::Fatal, fmt("MREA stream seek overrun"));
@ -106,7 +107,7 @@ void MREA::StreamReader::seek(atInt64 diff, athena::SeekOrigin whence) {
/* Seek source if needed */ /* Seek source if needed */
if (bIdx != m_nextBlk - 1) { if (bIdx != m_nextBlk - 1) {
m_source.seek(m_blkBase + cAccum, athena::Begin); m_source.seek(m_blkBase + cAccum, athena::SeekOrigin::Begin);
m_nextBlk = bIdx; m_nextBlk = bIdx;
nextBlock(); nextBlock();
} }
@ -168,7 +169,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 decompLen = drs.length(); atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen); mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close(); mreaDecompOut.close();
drs.seek(0, athena::Begin); drs.seek(0, athena::SeekOrigin::Begin);
/* Start up blender connection */ /* Start up blender connection */
hecl::blender::Connection& conn = btok.getBlenderConnection(); hecl::blender::Connection& conn = btok.getBlenderConnection();
@ -181,12 +182,12 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
egmcOffset += head.secSizes[i]; egmcOffset += head.secSizes[i];
/* Load EGMC if possible so we can assign meshes to scanIds */ /* Load EGMC if possible so we can assign meshes to scanIds */
drs.seek(egmcOffset, athena::Begin); drs.seek(egmcOffset, athena::SeekOrigin::Begin);
UniqueID32 egmcId(drs); UniqueID32 egmcId(drs);
DNACommon::EGMC egmc; DNACommon::EGMC egmc;
pakRouter.lookupAndReadDNA(egmcId, egmc); pakRouter.lookupAndReadDNA(egmcId, egmc);
drs.seek(0, athena::Begin); drs.seek(0, athena::SeekOrigin::Begin);
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */
hecl::blender::PyOutStream os = conn.beginPythonOut(true); hecl::blender::PyOutStream os = conn.beginPythonOut(true);
@ -224,7 +225,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = drs.position(); atUint64 secStart = drs.position();
matSet.read(drs); matSet.read(drs);
matSet.readToBlender(os, pakRouter, entry, 0); matSet.readToBlender(os, pakRouter, entry, 0);
drs.seek(secStart + head.secSizes[0], athena::Begin); drs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs; std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs); DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -234,7 +235,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader; MeshHeader mHeader;
secStart = drs.position(); secStart = drs.position();
mHeader.read(drs); mHeader.read(drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_2>( curSec += DNACMDL::ReadGeomSectionsToBlender<PAKRouter<PAKBridge>, MaterialSet, RigPair, DNACMDL::SurfaceHeader_2>(
os, drs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]); os, drs, pakRouter, entry, dummy, true, true, vertAttribs, m, head.secCount, 0, &head.secSizes[curSec]);
os.format(fmt( os.format(fmt(
@ -246,25 +247,26 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
mHeader.visorFlags.disableXray() ? "True" : "False", mHeader.visorFlags.thermalLevelStr()); mHeader.visorFlags.disableXray() ? "True" : "False", mHeader.visorFlags.thermalLevelStr());
/* Seek through AROT-relation sections */ /* Seek through AROT-relation sections */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
} }
/* Skip AROT */ /* Skip AROT */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip BVH */ /* Skip BVH */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip Bitmap */ /* Skip Bitmap */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Skip SCLY (for now) */ /* Skip SCLY (for now) */
for (atUint32 l = 0; l < head.sclyLayerCount; ++l) for (atUint32 l = 0; l < head.sclyLayerCount; ++l) {
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
}
/* Skip SCGN (for now) */ /* Skip SCGN (for now) */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read collision meshes */ /* Read collision meshes */
DeafBabe collision; DeafBabe collision;
@ -272,15 +274,15 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(drs); collision.read(drs);
DeafBabe::BlenderInit(os); DeafBabe::BlenderInit(os);
collision.sendToBlender(os); collision.sendToBlender(os);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Skip unknown section */ /* Skip unknown section */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
/* Read BABEDEAD Lights as Cycles emissives */ /* Read BABEDEAD Lights as Cycles emissives */
secStart = drs.position(); secStart = drs.position();
DNAMP1::MREA::ReadBabeDeadToBlender_1_2(os, drs); DNAMP1::MREA::ReadBabeDeadToBlender_1_2(os, drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Origins to center of mass */ /* Origins to center of mass */
os << "bpy.context.view_layer.layer_collection.children['Collision'].hide_viewport = False\n" os << "bpy.context.view_layer.layer_collection.children['Collision'].hide_viewport = False\n"

View File

@ -69,7 +69,7 @@ struct MREA {
Value<atUint32> unk3SecIdx; Value<atUint32> unk3SecIdx;
Value<atUint32> egmcSecIdx; Value<atUint32> egmcSecIdx;
Value<atUint32> compressedBlockCount; Value<atUint32> compressedBlockCount;
Seek<12, athena::Current> align1; Seek<12, athena::SeekOrigin::Current> align1;
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes; Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
}; };

View File

@ -14,7 +14,7 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Read>(athena::io::IS
if (extraType == 1) if (extraType == 1)
extraFloat = reader.readFloatBig(); extraFloat = reader.readFloatBig();
else if (extraType == 2) else if (extraType == 2)
reader.seek(35, athena::Current); reader.seek(35, athena::SeekOrigin::Current);
} }
template <> template <>
@ -29,7 +29,7 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Write>(athena::io::I
if (extraType == 1) if (extraType == 1)
writer.writeFloatBig(extraFloat); writer.writeFloatBig(extraFloat);
else if (extraType == 2) else if (extraType == 2)
writer.seek(35, athena::Current); writer.seek(35, athena::SeekOrigin::Current);
} }
template <> template <>

View File

@ -90,7 +90,7 @@ void PAKBridge::build() {
std::vector<UniqueID64> mapw; std::vector<UniqueID64> mapw;
if (worldMapEnt) { if (worldMapEnt) {
PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node); PAKEntryReadStream rs = worldMapEnt->beginReadStream(m_node);
rs.seek(8, athena::Current); rs.seek(8, athena::SeekOrigin::Current);
atUint32 areaCount = rs.readUint32Big(); atUint32 areaCount = rs.readUint32Big();
mapw.reserve(areaCount); mapw.reserve(areaCount);
for (atUint32 i = 0; i < areaCount; ++i) for (atUint32 i = 0; i < areaCount; ++i)

View File

@ -84,7 +84,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 decompLen = drs.length(); atUint64 decompLen = drs.length();
mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen); mreaDecompOut.writeBytes(drs.readBytes(decompLen).get(), decompLen);
mreaDecompOut.close(); mreaDecompOut.close();
drs.seek(0, athena::Begin); drs.seek(0, athena::SeekOrigin::Begin);
/* Start up blender connection */ /* Start up blender connection */
hecl::blender::Connection& conn = btok.getBlenderConnection(); hecl::blender::Connection& conn = btok.getBlenderConnection();
@ -118,7 +118,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
atUint64 secStart = drs.position(); atUint64 secStart = drs.position();
matSet.read(drs); matSet.read(drs);
matSet.readToBlender(os, pakRouter, entry, 0); matSet.readToBlender(os, pakRouter, entry, 0);
drs.seek(secStart + head.secSizes[0], athena::Begin); drs.seek(secStart + head.secSizes[0], athena::SeekOrigin::Begin);
std::vector<DNACMDL::VertexAttributes> vertAttribs; std::vector<DNACMDL::VertexAttributes> vertAttribs;
DNACMDL::GetVertexAttributes(matSet, vertAttribs); DNACMDL::GetVertexAttributes(matSet, vertAttribs);
@ -131,16 +131,16 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
MeshHeader mHeader; MeshHeader mHeader;
secStart = drs.position(); secStart = drs.position();
mHeader.read(drs); mHeader.read(drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Surface count from here */ /* Surface count from here */
secStart = drs.position(); secStart = drs.position();
surfaceCounts.push_back(drs.readUint32Big()); surfaceCounts.push_back(drs.readUint32Big());
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
/* Seek through AROT-relation sections */ /* Seek through AROT-relation sections */
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
} }
/* Skip though WOBJs */ /* Skip though WOBJs */
@ -150,13 +150,13 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip AROT */ /* Skip AROT */
if (secIdxIt->first == FOURCC('ROCT')) { if (secIdxIt->first == FOURCC('ROCT')) {
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt; ++secIdxIt;
} }
/* Skip AABB */ /* Skip AABB */
if (secIdxIt->first == FOURCC('AABB')) { if (secIdxIt->first == FOURCC('AABB')) {
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt; ++secIdxIt;
} }
@ -173,20 +173,20 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
/* Skip DEPS */ /* Skip DEPS */
if (secIdxIt->first == FOURCC('DEPS')) { if (secIdxIt->first == FOURCC('DEPS')) {
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt; ++secIdxIt;
} }
/* Skip SOBJ (SCLY) */ /* Skip SOBJ (SCLY) */
if (secIdxIt->first == FOURCC('SOBJ')) { if (secIdxIt->first == FOURCC('SOBJ')) {
for (atUint32 l = 0; l < head.sclyLayerCount; ++l) for (atUint32 l = 0; l < head.sclyLayerCount; ++l)
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt; ++secIdxIt;
} }
/* Skip SGEN */ /* Skip SGEN */
if (secIdxIt->first == FOURCC('SGEN')) { if (secIdxIt->first == FOURCC('SGEN')) {
drs.seek(head.secSizes[curSec++], athena::Current); drs.seek(head.secSizes[curSec++], athena::SeekOrigin::Current);
++secIdxIt; ++secIdxIt;
} }
@ -197,7 +197,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
collision.read(drs); collision.read(drs);
DNAMP2::DeafBabe::BlenderInit(os); DNAMP2::DeafBabe::BlenderInit(os);
collision.sendToBlender(os); collision.sendToBlender(os);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
++secIdxIt; ++secIdxIt;
} }
@ -205,7 +205,7 @@ bool MREA::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
if (secIdxIt->first == FOURCC('LITE')) { if (secIdxIt->first == FOURCC('LITE')) {
secStart = drs.position(); secStart = drs.position();
ReadBabeDeadToBlender_3(os, drs); ReadBabeDeadToBlender_3(os, drs);
drs.seek(secStart + head.secSizes[curSec++], athena::Begin); drs.seek(secStart + head.secSizes[curSec++], athena::SeekOrigin::Begin);
++secIdxIt; ++secIdxIt;
} }
@ -231,7 +231,7 @@ bool MREA::ExtractLayerDeps(PAKEntryReadStream& rs, PAKBridge::Level::Area& area
StreamReader drs(rs, head.compressedBlockCount, head.secIndexCount); StreamReader drs(rs, head.compressedBlockCount, head.secIndexCount);
for (const std::pair<DNAFourCC, atUint32>& idx : drs.m_secIdxs) { for (const std::pair<DNAFourCC, atUint32>& idx : drs.m_secIdxs) {
if (idx.first == FOURCC('DEPS')) { if (idx.first == FOURCC('DEPS')) {
drs.seek(head.getSecOffset(idx.second), athena::Begin); drs.seek(head.getSecOffset(idx.second), athena::SeekOrigin::Begin);
DEPS deps; DEPS deps;
deps.read(drs); deps.read(drs);

View File

@ -25,7 +25,7 @@ struct MREA {
Value<atUint32> secCount; Value<atUint32> secCount;
Value<atUint32> compressedBlockCount; Value<atUint32> compressedBlockCount;
Value<atUint32> secIndexCount; Value<atUint32> secIndexCount;
Seek<20, athena::Current> align1; Seek<20, athena::SeekOrigin::Current> align1;
Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes; Vector<atUint32, AT_DNA_COUNT(secCount)> secSizes;
atUint32 getSecOffset(atUint32 idx) const { atUint32 getSecOffset(atUint32 idx) const {

View File

@ -11,11 +11,11 @@ void PAK::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
if (m_header.version != 2) if (m_header.version != 2)
Log.report(logvisor::Fatal, fmt("unexpected PAK magic")); Log.report(logvisor::Fatal, fmt("unexpected PAK magic"));
reader.seek(8, athena::Current); reader.seek(8, athena::SeekOrigin::Current);
atUint32 strgSz = reader.readUint32Big(); atUint32 strgSz = reader.readUint32Big();
reader.seek(4, athena::Current); reader.seek(4, athena::SeekOrigin::Current);
atUint32 rshdSz = reader.readUint32Big(); atUint32 rshdSz = reader.readUint32Big();
reader.seek(44, athena::Current); reader.seek(44, athena::SeekOrigin::Current);
atUint32 dataOffset = 128 + strgSz + rshdSz; atUint32 dataOffset = 128 + strgSz + rshdSz;
atUint64 strgBase = reader.position(); atUint64 strgBase = reader.position();
@ -26,7 +26,7 @@ void PAK::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
m_nameEntries.emplace_back(); m_nameEntries.emplace_back();
m_nameEntries.back().read(reader); m_nameEntries.back().read(reader);
} }
reader.seek(strgBase + strgSz, athena::Begin); reader.seek(strgBase + strgSz, athena::SeekOrigin::Begin);
atUint32 count = reader.readUint32Big(); atUint32 count = reader.readUint32Big();
m_entries.clear(); m_entries.clear();
@ -91,12 +91,12 @@ void PAK::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
atUint32 dataPad = ((dataSz + 63) & ~63) - dataSz; atUint32 dataPad = ((dataSz + 63) & ~63) - dataSz;
dataSz += dataPad; dataSz += dataPad;
writer.writeUint32Big(dataSz); writer.writeUint32Big(dataSz);
writer.seek(36, athena::Current); writer.seek(36, athena::SeekOrigin::Current);
writer.writeUint32Big((atUint32)m_nameEntries.size()); writer.writeUint32Big((atUint32)m_nameEntries.size());
for (const NameEntry& entry : m_nameEntries) for (const NameEntry& entry : m_nameEntries)
entry.write(writer); entry.write(writer);
writer.seek(strgPad, athena::Current); writer.seek(strgPad, athena::SeekOrigin::Current);
writer.writeUint32Big((atUint32)m_entries.size()); writer.writeUint32Big((atUint32)m_entries.size());
for (const auto& entry : m_entries) { for (const auto& entry : m_entries) {
@ -104,7 +104,7 @@ void PAK::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
copy.offset -= dataOffset; copy.offset -= dataOffset;
copy.write(writer); copy.write(writer);
} }
writer.seek(rshdPad, athena::Current); writer.seek(rshdPad, athena::SeekOrigin::Current);
} }
template <> template <>

View File

@ -19,7 +19,7 @@ struct PAK : BigDNA {
Value<atUint32> version; Value<atUint32> version;
Value<atUint32> headSz; Value<atUint32> headSz;
Value<atUint8> md5sum[16]; Value<atUint8> md5sum[16];
Seek<40, athena::Current> seek; Seek<40, athena::SeekOrigin::Current> seek;
} m_header; } m_header;
struct NameEntry : BigDNA { struct NameEntry : BigDNA {

View File

@ -42,7 +42,7 @@ void STRG::_read(athena::io::IStreamReader& reader) {
for (atUint32 l = 0; l < langCount; ++l) { for (atUint32 l = 0; l < langCount; ++l) {
std::vector<std::string> strs; std::vector<std::string> strs;
for (atUint32 s = 0; s < strCount; ++s) { for (atUint32 s = 0; s < strCount; ++s) {
reader.seek(strBase + strOffs[l * strCount + s], athena::Begin); reader.seek(strBase + strOffs[l * strCount + s], athena::SeekOrigin::Begin);
atUint32 len = reader.readUint32Big(); atUint32 len = reader.readUint32Big();
strs.emplace_back(reader.readString(len)); strs.emplace_back(reader.readString(len));
} }

View File

@ -1264,7 +1264,7 @@ struct SpecMP1 : SpecBase {
void writePakFileIndex(athena::io::FileWriter& w, const std::vector<urde::SObjectTag>& tags, void writePakFileIndex(athena::io::FileWriter& w, const std::vector<urde::SObjectTag>& tags,
const std::vector<std::tuple<size_t, size_t, bool>>& index, atUint64 resTableOffset) override { const std::vector<std::tuple<size_t, size_t, bool>>& index, atUint64 resTableOffset) override {
w.seek(resTableOffset, athena::Begin); w.seek(resTableOffset, athena::SeekOrigin::Begin);
auto it = tags.begin(); auto it = tags.begin();
for (const auto& item : index) { for (const auto& item : index) {

View File

@ -129,7 +129,7 @@ bool ProjectManager::openProject(hecl::SystemStringView path) {
} }
r.reset(); r.reset();
reader.seek(0, athena::Begin); reader.seek(0, athena::SeekOrigin::Begin);
if (!r.parse(&reader)) { if (!r.parse(&reader)) {
return makeProj(true); return makeProj(true);
} }