From 0d2f2cfd3464432e219133d2bb20afba32932f1b Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 3 Oct 2015 19:08:56 -1000 Subject: [PATCH] Initial cook tool integration --- DataSpec/DNACommon/ANCS.hpp | 2 +- DataSpec/DNACommon/ANIM.cpp | 12 +++--- DataSpec/DNACommon/CMDL.hpp | 2 +- DataSpec/DNACommon/PAK.hpp | 6 +-- DataSpec/DNAMP1/DNAMP1.cpp | 2 +- DataSpec/DNAMP1/DNAMP1.hpp | 6 +-- DataSpec/DNAMP1/PAK.cpp | 2 +- DataSpec/DNAMP1/PAK.hpp | 4 +- DataSpec/DNAMP2/DNAMP2.cpp | 2 +- DataSpec/DNAMP2/DNAMP2.hpp | 6 +-- DataSpec/DNAMP3/CMDLMaterials.cpp | 2 +- DataSpec/DNAMP3/DNAMP3.cpp | 2 +- DataSpec/DNAMP3/DNAMP3.hpp | 6 +-- DataSpec/DNAMP3/PAK.cpp | 2 +- DataSpec/DNAMP3/PAK.hpp | 4 +- DataSpec/SpecBase.cpp | 28 ++++++++++--- DataSpec/SpecBase.hpp | 25 +++++++++--- DataSpec/SpecMP1.cpp | 55 ++++++++++++++++++-------- DataSpec/SpecMP2.cpp | 54 +++++++++++++++++-------- DataSpec/SpecMP3.cpp | 65 +++++++++++++++++++++---------- NODLib | 2 +- hecl | 2 +- 22 files changed, 195 insertions(+), 96 deletions(-) diff --git a/DataSpec/DNACommon/ANCS.hpp b/DataSpec/DNACommon/ANCS.hpp index 174b47adf..37e16eb80 100644 --- a/DataSpec/DNACommon/ANCS.hpp +++ b/DataSpec/DNACommon/ANCS.hpp @@ -44,7 +44,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn, ancs.getCharacterResInfo(chResInfo); for (const auto& info : chResInfo) { - const NOD::DiscBase::IPartition::Node* node; + const NOD::Node* node; const typename PAKRouter::EntryType* cmdlE = pakRouter.lookupEntry(info.cmdl, &node, true); if (cmdlE) { diff --git a/DataSpec/DNACommon/ANIM.cpp b/DataSpec/DNACommon/ANIM.cpp index 1bbe84af3..9caf9cc1f 100644 --- a/DataSpec/DNACommon/ANIM.cpp +++ b/DataSpec/DNACommon/ANIM.cpp @@ -440,8 +440,8 @@ BitstreamWriter::write(const std::vector>& chanKeys, QuantizedRot qrCur = QuantizeRotation(*it, rotDivOut); quantizeBit(newData, qrCur.w); quantize(newData, chan.q[0], qrCur.v[0] - qrLast.v[0]); - quantize(newData, chan.q[1], qrCur.v[1] - qrLast.v[0]); - quantize(newData, chan.q[2], qrCur.v[2] - qrLast.v[0]); + quantize(newData, chan.q[1], qrCur.v[1] - qrLast.v[1]); + quantize(newData, chan.q[2], qrCur.v[2] - qrLast.v[2]); qrLast = qrCur; } break; @@ -459,8 +459,8 @@ BitstreamWriter::write(const std::vector>& chanKeys, atInt16(it->v3.vec[1] / transMultOut), atInt16(it->v3.vec[2] / transMultOut)}; quantize(newData, chan.q[0], cur[0] - last[0]); - quantize(newData, chan.q[1], cur[1] - last[0]); - quantize(newData, chan.q[2], cur[2] - last[0]); + quantize(newData, chan.q[1], cur[1] - last[1]); + quantize(newData, chan.q[2], cur[2] - last[2]); last = cur; } break; @@ -478,8 +478,8 @@ BitstreamWriter::write(const std::vector>& chanKeys, atInt16(it->v3.vec[1] * rotDivOut), atInt16(it->v3.vec[2] * rotDivOut)}; quantize(newData, chan.q[0], cur[0] - last[0]); - quantize(newData, chan.q[1], cur[1] - last[0]); - quantize(newData, chan.q[2], cur[2] - last[0]); + quantize(newData, chan.q[1], cur[1] - last[1]); + quantize(newData, chan.q[2], cur[2] - last[2]); last = cur; } break; diff --git a/DataSpec/DNACommon/CMDL.hpp b/DataSpec/DNACommon/CMDL.hpp index b4bfc4e4b..9d00e536a 100644 --- a/DataSpec/DNACommon/CMDL.hpp +++ b/DataSpec/DNACommon/CMDL.hpp @@ -151,7 +151,7 @@ void ReadMaterialSetToBlender_1_2(HECL::BlenderConnection::PyOutStream& os, for (const UniqueID32& tex : matSet.head.textureIDs) { std::string texName = pakRouter.getBestEntryName(tex); - const NOD::DiscBase::IPartition::Node* node; + const NOD::Node* node; const typename PAKRouter::EntryType* texEntry = pakRouter.lookupEntry(tex, &node); HECL::ProjectPath txtrPath = pakRouter.getWorking(texEntry); if (txtrPath.getPathType() == HECL::ProjectPath::PT_NONE) diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 66534a720..0f58cecc4 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -246,7 +246,7 @@ private: HECL::ProjectPath m_sharedWorking; HECL::ProjectPath m_sharedCooked; const PAKType* m_pak = nullptr; - const NOD::DiscBase::IPartition::Node* m_node = nullptr; + const NOD::Node* m_node = nullptr; std::unordered_map> m_uniqueEntries; std::unordered_map> m_sharedEntries; std::unordered_map m_cmdlRigs; @@ -549,7 +549,7 @@ public: } const typename BRIDGETYPE::PAKType::Entry* lookupEntry(const IDType& entry, - const NOD::DiscBase::IPartition::Node** nodeOut=nullptr, + const NOD::Node** nodeOut=nullptr, bool silenceWarnings=false) const { if (!m_bridges) @@ -586,7 +586,7 @@ public: template bool lookupAndReadDNA(const IDType& id, DNA& out, bool silenceWarnings=false) { - const NOD::DiscBase::IPartition::Node* node; + const NOD::Node* node; const EntryType* entry = lookupEntry(id, &node, silenceWarnings); if (!entry) return false; diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index c88a0a0d3..9cc7e2240 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -26,7 +26,7 @@ static bool GetNoShare(const std::string& name) } PAKBridge::PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract) : m_project(project), m_node(node), m_pak(false, GetNoShare(node.getName())), m_doExtract(doExtract) { diff --git a/DataSpec/DNAMP1/DNAMP1.hpp b/DataSpec/DNAMP1/DNAMP1.hpp index 3e50e5d08..b041aeeba 100644 --- a/DataSpec/DNAMP1/DNAMP1.hpp +++ b/DataSpec/DNAMP1/DNAMP1.hpp @@ -15,7 +15,7 @@ extern LogVisor::LogModule Log; class PAKBridge { HECL::Database::Project& m_project; - const NOD::DiscBase::IPartition::Node& m_node; + const NOD::Node& m_node; PAK m_pak; public: bool m_doExtract; @@ -24,7 +24,7 @@ public: HECL::SystemString m_levelString; PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract=true); void build(); static ResExtractor LookupExtractor(const PAK::Entry& entry); @@ -32,7 +32,7 @@ public: const HECL::SystemString& getLevelString() const {return m_levelString;} using PAKType = PAK; const PAKType& getPAK() const {return m_pak;} - const NOD::DiscBase::IPartition::Node& getNode() const {return m_node;} + const NOD::Node& getNode() const {return m_node;} void addCMDLRigPairs(std::unordered_map>& addTo) const; }; diff --git a/DataSpec/DNAMP1/PAK.cpp b/DataSpec/DNAMP1/PAK.cpp index e752d5c74..e3c99d103 100644 --- a/DataSpec/DNAMP1/PAK.cpp +++ b/DataSpec/DNAMP1/PAK.cpp @@ -73,7 +73,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const } std::unique_ptr -PAK::Entry::getBuffer(const NOD::DiscBase::IPartition::Node& pak, atUint64& szOut) const +PAK::Entry::getBuffer(const NOD::Node& pak, atUint64& szOut) const { if (compressed) { diff --git a/DataSpec/DNAMP1/PAK.hpp b/DataSpec/DNAMP1/PAK.hpp index 78d875547..70b99ac26 100644 --- a/DataSpec/DNAMP1/PAK.hpp +++ b/DataSpec/DNAMP1/PAK.hpp @@ -37,8 +37,8 @@ struct PAK : BigDNA Value offset; UniqueResult unique; - std::unique_ptr getBuffer(const NOD::DiscBase::IPartition::Node& pak, atUint64& szOut) const; - inline PAKEntryReadStream beginReadStream(const NOD::DiscBase::IPartition::Node& pak, atUint64 off=0) const + std::unique_ptr getBuffer(const NOD::Node& pak, atUint64& szOut) const; + inline PAKEntryReadStream beginReadStream(const NOD::Node& pak, atUint64 off=0) const { atUint64 sz; std::unique_ptr buf = getBuffer(pak, sz); diff --git a/DataSpec/DNAMP2/DNAMP2.cpp b/DataSpec/DNAMP2/DNAMP2.cpp index ce09fe2e2..ca8e2d41f 100644 --- a/DataSpec/DNAMP2/DNAMP2.cpp +++ b/DataSpec/DNAMP2/DNAMP2.cpp @@ -23,7 +23,7 @@ static bool GetNoShare(const std::string& name) } PAKBridge::PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract) : m_project(project), m_node(node), m_pak(true, GetNoShare(node.getName())), m_doExtract(doExtract) { diff --git a/DataSpec/DNAMP2/DNAMP2.hpp b/DataSpec/DNAMP2/DNAMP2.hpp index 190406788..bbfc1cbc0 100644 --- a/DataSpec/DNAMP2/DNAMP2.hpp +++ b/DataSpec/DNAMP2/DNAMP2.hpp @@ -15,7 +15,7 @@ extern LogVisor::LogModule Log; class PAKBridge { HECL::Database::Project& m_project; - const NOD::DiscBase::IPartition::Node& m_node; + const NOD::Node& m_node; DNAMP1::PAK m_pak; public: bool m_doExtract; @@ -24,7 +24,7 @@ public: HECL::SystemString m_levelString; PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract=true); void build(); static ResExtractor LookupExtractor(const DNAMP1::PAK::Entry& entry); @@ -33,7 +33,7 @@ public: using PAKType = DNAMP1::PAK; const PAKType& getPAK() const {return m_pak;} - const NOD::DiscBase::IPartition::Node& getNode() const {return m_node;} + const NOD::Node& getNode() const {return m_node;} void addCMDLRigPairs(std::unordered_map>& addTo) const; }; diff --git a/DataSpec/DNAMP3/CMDLMaterials.cpp b/DataSpec/DNAMP3/CMDLMaterials.cpp index fff2c24fd..0f7665f4e 100644 --- a/DataSpec/DNAMP3/CMDLMaterials.cpp +++ b/DataSpec/DNAMP3/CMDLMaterials.cpp @@ -116,7 +116,7 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream& if (txtrId) { std::string texName = pakRouter.getBestEntryName(txtrId); - const NOD::DiscBase::IPartition::Node* node; + const NOD::Node* node; const PAK::Entry* texEntry = pakRouter.lookupEntry(txtrId, &node); HECL::ProjectPath txtrPath = pakRouter.getWorking(texEntry); if (txtrPath.getPathType() == HECL::ProjectPath::PT_NONE) diff --git a/DataSpec/DNAMP3/DNAMP3.cpp b/DataSpec/DNAMP3/DNAMP3.cpp index 583fcbca4..31364b2bb 100644 --- a/DataSpec/DNAMP3/DNAMP3.cpp +++ b/DataSpec/DNAMP3/DNAMP3.cpp @@ -25,7 +25,7 @@ static bool GetNoShare(const std::string& name) } PAKBridge::PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract) : m_project(project), m_node(node), m_pak(GetNoShare(node.getName())), m_doExtract(doExtract) { diff --git a/DataSpec/DNAMP3/DNAMP3.hpp b/DataSpec/DNAMP3/DNAMP3.hpp index 01599ca4f..463b94e23 100644 --- a/DataSpec/DNAMP3/DNAMP3.hpp +++ b/DataSpec/DNAMP3/DNAMP3.hpp @@ -15,7 +15,7 @@ extern LogVisor::LogModule Log; class PAKBridge { HECL::Database::Project& m_project; - const NOD::DiscBase::IPartition::Node& m_node; + const NOD::Node& m_node; PAK m_pak; public: bool m_doExtract; @@ -24,7 +24,7 @@ public: HECL::SystemString m_levelString; PAKBridge(HECL::Database::Project& project, - const NOD::DiscBase::IPartition::Node& node, + const NOD::Node& node, bool doExtract=true); void build(); static ResExtractor LookupExtractor(const PAK::Entry& entry); @@ -33,7 +33,7 @@ public: using PAKType = PAK; inline const PAKType& getPAK() const {return m_pak;} - inline const NOD::DiscBase::IPartition::Node& getNode() const {return m_node;} + inline const NOD::Node& getNode() const {return m_node;} void addCMDLRigPairs(std::unordered_map>& addTo) const; }; diff --git a/DataSpec/DNAMP3/PAK.cpp b/DataSpec/DNAMP3/PAK.cpp index 37c4edafd..7c554c93a 100644 --- a/DataSpec/DNAMP3/PAK.cpp +++ b/DataSpec/DNAMP3/PAK.cpp @@ -98,7 +98,7 @@ void PAK::write(Athena::io::IStreamWriter& writer) const writer.seek(rshdPad, Athena::Current); } -std::unique_ptr PAK::Entry::getBuffer(const NOD::DiscBase::IPartition::Node& pak, atUint64& szOut) const +std::unique_ptr PAK::Entry::getBuffer(const NOD::Node& pak, atUint64& szOut) const { if (compressed) { diff --git a/DataSpec/DNAMP3/PAK.hpp b/DataSpec/DNAMP3/PAK.hpp index 6ca01fe8f..34248795a 100644 --- a/DataSpec/DNAMP3/PAK.hpp +++ b/DataSpec/DNAMP3/PAK.hpp @@ -46,8 +46,8 @@ struct PAK : BigDNA Value offset; UniqueResult unique; - std::unique_ptr getBuffer(const NOD::DiscBase::IPartition::Node& pak, atUint64& szOut) const; - inline PAKEntryReadStream beginReadStream(const NOD::DiscBase::IPartition::Node& pak, atUint64 off=0) const + std::unique_ptr getBuffer(const NOD::Node& pak, atUint64& szOut) const; + inline PAKEntryReadStream beginReadStream(const NOD::Node& pak, atUint64 off=0) const { atUint64 sz; std::unique_ptr buf = getBuffer(pak, sz); diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 562bc335b..3cb69c85a 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -7,7 +7,7 @@ namespace Retro static LogVisor::LogModule Log("Retro::SpecBase"); -bool SpecBase::canExtract(const ExtractPassInfo& info, std::list& reps) +bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector& reps) { m_disc = NOD::OpenDiscFromImage(info.srcpath.c_str(), m_isWii); if (!m_disc) @@ -54,7 +54,7 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress) { /* Extract update partition for repacking later */ const HECL::SystemString& target = m_project.getProjectWorkingPath().getAbsolutePath(); - NOD::DiscBase::IPartition* update = m_disc->getUpdatePartition(); + NOD::Partition* update = m_disc->getUpdatePartition(); NOD::ExtractionContext ctx = {true, info.force, nullptr}; if (update) @@ -75,10 +75,10 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress) if (!m_standalone) { progress(_S("Trilogy Files"), _S(""), 1, 0.0); - NOD::DiscBase::IPartition* data = m_disc->getDataPartition(); - const NOD::DiscBase::IPartition::Node& root = data->getFSTRoot(); - for (const NOD::DiscBase::IPartition::Node& child : root) - if (child.getKind() == NOD::DiscBase::IPartition::Node::NODE_FILE) + NOD::Partition* data = m_disc->getDataPartition(); + const NOD::Node& root = data->getFSTRoot(); + for (const NOD::Node& child : root) + if (child.getKind() == NOD::Node::NODE_FILE) child.extractToDirectory(target, ctx); progress(_S("Trilogy Files"), _S(""), 1, 1.0); } @@ -88,6 +88,8 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress) bool SpecBase::canCook(const HECL::ProjectPath& path) { + if (!checkPathPrefix(path)) + return false; if (HECL::IsPathBlend(path)) { HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); @@ -110,8 +112,22 @@ bool SpecBase::canCook(const HECL::ProjectPath& path) return false; } +using Mesh = HECL::BlenderConnection::DataStream::Mesh; + void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath) { + if (HECL::IsPathBlend(path)) + { + HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); + if (!conn.openBlend(path.getAbsolutePath())) + return; + if (conn.getBlendType() == HECL::BlenderConnection::TypeMesh) + { + HECL::BlenderConnection::DataStream ds = conn.beginData(); + Mesh mesh = ds.compileMesh(); + ds.close(); + } + } } bool SpecBase::canPackage(const PackagePassInfo& info) diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index d73bab4f0..b3776bf79 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -5,13 +5,15 @@ #include #include +#include "BlenderConnection.hpp" namespace Retro { struct SpecBase : HECL::Database::IDataSpec { - bool canExtract(const ExtractPassInfo& info, std::list& reps); + /* HECL Adaptors */ + bool canExtract(const ExtractPassInfo& info, std::vector& reps); void doExtract(const ExtractPassInfo& info, FProgress progress); bool canCook(const HECL::ProjectPath& path); @@ -22,20 +24,33 @@ struct SpecBase : HECL::Database::IDataSpec std::unordered_set& implicitsOut); void doPackage(const PackagePassInfo& info); + /* Extract handlers */ virtual bool checkStandaloneID(const char* id) const=0; virtual bool checkFromStandaloneDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps)=0; + const std::vector& args, + std::vector& reps)=0; virtual bool checkFromTrilogyDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps)=0; + const std::vector& args, + std::vector& reps)=0; virtual bool extractFromDisc(NOD::DiscBase& disc, bool force, FProgress progress)=0; + /* Basic path check (game directory matching) */ + virtual bool checkPathPrefix(const HECL::ProjectPath& path)=0; + + /* Pre-cook handlers */ virtual bool validateYAMLDNAType(FILE* fp) const=0; + /* Cook handlers */ + using BlendStream = HECL::BlenderConnection::DataStream; + virtual void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; + virtual void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; + virtual void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; + virtual void cookYAML(FILE* in, const HECL::ProjectPath& out) const=0; + + const HECL::ProjectPath& getMasterShaderPath() const {return m_masterShader;} SpecBase(HECL::Database::Project& project) diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 37ee72144..883f6dd7e 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -23,7 +23,7 @@ struct SpecMP1 : SpecBase return false; } - std::vector m_nonPaks; + std::vector m_nonPaks; std::vector m_paks; std::map m_orderedPaks; @@ -37,13 +37,13 @@ struct SpecMP1 : SpecBase m_cookPath(project.getProjectCookedPath(SpecEntMP1), _S("MP1")), m_pakRouter(*this, m_workPath, m_cookPath) {} - void buildPaks(NOD::DiscBase::IPartition::Node& root, - const std::list& args, + void buildPaks(NOD::Node& root, + const std::vector& args, ExtractReport& rep) { m_nonPaks.clear(); m_paks.clear(); - for (const NOD::DiscBase::IPartition::Node& child : root) + for (const NOD::Node& child : root) { bool isPak = false; const std::string& name = child.getName(); @@ -107,6 +107,7 @@ struct SpecMP1 : SpecBase m_orderedPaks[dpak.getName()] = &dpak; /* Assemble extract report */ + rep.childOpts.reserve(m_orderedPaks.size()); for (const std::pair& item : m_orderedPaks) { if (!item.second->m_doExtract) @@ -121,10 +122,10 @@ struct SpecMP1 : SpecBase bool checkFromStandaloneDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); + NOD::Partition* partition = disc.getDataPartition(); std::unique_ptr dolBuf = partition->getDOLBuf(); const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19; @@ -144,7 +145,7 @@ struct SpecMP1 : SpecBase } /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); + NOD::Node& root = partition->getFSTRoot(); buildPaks(root, args, rep); return true; @@ -152,10 +153,10 @@ struct SpecMP1 : SpecBase bool checkFromTrilogyDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { - std::list mp1args; + std::vector mp1args; bool doExtract = false; if (args.size()) { @@ -167,6 +168,7 @@ struct SpecMP1 : SpecBase if (!lowerArg.compare(0, 3, _S("mp1"))) { doExtract = true; + mp1args.reserve(args.size()); size_t slashPos = arg.find(_S('/')); if (slashPos == HECL::SystemString::npos) slashPos = arg.find(_S('\\')); @@ -181,9 +183,9 @@ struct SpecMP1 : SpecBase if (!doExtract) return false; - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); - NOD::DiscBase::IPartition::Node::DirectoryIterator dolIt = root.find("rs5mp1_p.dol"); + NOD::Partition* partition = disc.getDataPartition(); + NOD::Node& root = partition->getFSTRoot(); + NOD::Node::DirectoryIterator dolIt = root.find("rs5mp1_p.dol"); if (dolIt == root.end()) return false; @@ -203,7 +205,7 @@ struct SpecMP1 : SpecBase } /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node::DirectoryIterator mp1It = root.find("MP1"); + NOD::Node::DirectoryIterator mp1It = root.find("MP1"); if (mp1It == root.end()) return false; buildPaks(*mp1It, mp1args, rep); @@ -229,7 +231,7 @@ struct SpecMP1 : SpecBase HECL::SystemStringView nameView(name); progress(_S("MP1 Root"), nameView.sys_str().c_str(), 3, prog / (float)m_nonPaks.size()); }; - for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks) + for (const NOD::Node* node : m_nonPaks) { node->extractToDirectory(m_workPath.getAbsolutePath(), ctx); prog++; @@ -263,6 +265,11 @@ struct SpecMP1 : SpecBase return true; } + bool checkPathPrefix(const HECL::ProjectPath& path) + { + return path.getRelativePath().compare(0, 4, "MP1/") == 0; + } + bool validateYAMLDNAType(FILE* fp) const { if (BigYAML::ValidateFromYAMLFile(fp)) @@ -271,6 +278,22 @@ struct SpecMP1 : SpecBase return true; return false; } + + void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookYAML(FILE* in, const HECL::ProjectPath& out) const + { + } }; HECL::Database::DataSpecEntry SpecEntMP1 = diff --git a/DataSpec/SpecMP2.cpp b/DataSpec/SpecMP2.cpp index a0ad30469..cc27f24ad 100644 --- a/DataSpec/SpecMP2.cpp +++ b/DataSpec/SpecMP2.cpp @@ -21,7 +21,7 @@ struct SpecMP2 : SpecBase return false; } - std::vector m_nonPaks; + std::vector m_nonPaks; std::vector m_paks; std::map m_orderedPaks; @@ -35,13 +35,13 @@ struct SpecMP2 : SpecBase m_cookPath(project.getProjectCookedPath(SpecEntMP2), _S("MP2")), m_pakRouter(*this, m_workPath, m_cookPath) {} - void buildPaks(NOD::DiscBase::IPartition::Node& root, - const std::list& args, + void buildPaks(NOD::Node& root, + const std::vector& args, ExtractReport& rep) { m_nonPaks.clear(); m_paks.clear(); - for (const NOD::DiscBase::IPartition::Node& child : root) + for (const NOD::Node& child : root) { bool isPak = false; const std::string& name = child.getName(); @@ -118,10 +118,10 @@ struct SpecMP2 : SpecBase bool checkFromStandaloneDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); + NOD::Partition* partition = disc.getDataPartition(); std::unique_ptr dolBuf = partition->getDOLBuf(); const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19; if (!buildInfo) @@ -137,7 +137,7 @@ struct SpecMP2 : SpecBase rep.desc += _S(" (") + buildView + _S(")"); /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); + NOD::Node& root = partition->getFSTRoot(); buildPaks(root, args, rep); return true; @@ -145,10 +145,10 @@ struct SpecMP2 : SpecBase bool checkFromTrilogyDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { - std::list mp2args; + std::vector mp2args; bool doExtract = false; if (args.size()) { @@ -160,6 +160,7 @@ struct SpecMP2 : SpecBase if (!lowerArg.compare(0, 3, _S("mp2"))) { doExtract = true; + mp2args.reserve(args.size()); size_t slashPos = arg.find(_S('/')); if (slashPos == HECL::SystemString::npos) slashPos = arg.find(_S('\\')); @@ -174,9 +175,9 @@ struct SpecMP2 : SpecBase if (!doExtract) return false; - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); - NOD::DiscBase::IPartition::Node::DirectoryIterator dolIt = root.find("rs5mp2_p.dol"); + NOD::Partition* partition = disc.getDataPartition(); + NOD::Node& root = partition->getFSTRoot(); + NOD::Node::DirectoryIterator dolIt = root.find("rs5mp2_p.dol"); if (dolIt == root.end()) return false; @@ -196,7 +197,7 @@ struct SpecMP2 : SpecBase } /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node::DirectoryIterator mp2It = root.find("MP2"); + NOD::Node::DirectoryIterator mp2It = root.find("MP2"); if (mp2It == root.end()) return false; buildPaks(*mp2It, mp2args, rep); @@ -221,7 +222,7 @@ struct SpecMP2 : SpecBase HECL::SystemStringView nameView(name); progress(_S("MP2 Root"), nameView.sys_str().c_str(), 3, prog / (float)m_nonPaks.size()); }; - for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks) + for (const NOD::Node* node : m_nonPaks) { node->extractToDirectory(m_workPath.getAbsolutePath(), ctx); prog++; @@ -255,6 +256,11 @@ struct SpecMP2 : SpecBase return true; } + bool checkPathPrefix(const HECL::ProjectPath& path) + { + return path.getRelativePath().compare(0, 4, "MP2/") == 0; + } + bool validateYAMLDNAType(FILE* fp) const { if (BigYAML::ValidateFromYAMLFile(fp)) @@ -263,6 +269,22 @@ struct SpecMP2 : SpecBase return true; return false; } + + void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookYAML(FILE* in, const HECL::ProjectPath& out) const + { + } }; HECL::Database::DataSpecEntry SpecEntMP2 diff --git a/DataSpec/SpecMP3.cpp b/DataSpec/SpecMP3.cpp index d3071ac78..4a785ca5f 100644 --- a/DataSpec/SpecMP3.cpp +++ b/DataSpec/SpecMP3.cpp @@ -24,7 +24,7 @@ struct SpecMP3 : SpecBase } bool doMP3 = false; - std::vector m_nonPaks; + std::vector m_nonPaks; std::vector m_paks; std::map m_orderedPaks; @@ -34,7 +34,7 @@ struct SpecMP3 : SpecBase /* These are populated when extracting MPT's frontend (uses MP3's DataSpec) */ bool doMPTFE = false; - std::vector m_feNonPaks; + std::vector m_feNonPaks; std::vector m_fePaks; std::map m_feOrderedPaks; @@ -51,8 +51,8 @@ struct SpecMP3 : SpecBase m_feCookPath(project.getProjectCookedPath(SpecEntMP3), _S("fe")), m_fePakRouter(*this, m_feWorkPath, m_feCookPath) {} - void buildPaks(NOD::DiscBase::IPartition::Node& root, - const std::list& args, + void buildPaks(NOD::Node& root, + const std::vector& args, ExtractReport& rep, bool fe) { @@ -66,7 +66,7 @@ struct SpecMP3 : SpecBase m_nonPaks.clear(); m_paks.clear(); } - for (const NOD::DiscBase::IPartition::Node& child : root) + for (const NOD::Node& child : root) { bool isPak = false; const std::string& name = child.getName(); @@ -174,11 +174,11 @@ struct SpecMP3 : SpecBase bool checkFromStandaloneDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { doMP3 = true; - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); + NOD::Partition* partition = disc.getDataPartition(); std::unique_ptr dolBuf = partition->getDOLBuf(); const char* buildInfo = (char*)memmem(dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16) + 19; if (!buildInfo) @@ -198,7 +198,7 @@ struct SpecMP3 : SpecBase rep.desc += _S(" (") + buildView + _S(")"); /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); + NOD::Node& root = partition->getFSTRoot(); buildPaks(root, args, rep, false); return true; @@ -206,11 +206,11 @@ struct SpecMP3 : SpecBase bool checkFromTrilogyDisc(NOD::DiscBase& disc, const HECL::SystemString& regstr, - const std::list& args, - std::list& reps) + const std::vector& args, + std::vector& reps) { - std::list mp3args; - std::list feargs; + std::vector mp3args; + std::vector feargs; if (args.size()) { /* Needs filter */ @@ -221,6 +221,7 @@ struct SpecMP3 : SpecBase if (!lowerArg.compare(0, 3, _S("mp3"))) { doMP3 = true; + mp3args.reserve(args.size()); size_t slashPos = arg.find(_S('/')); if (slashPos == HECL::SystemString::npos) slashPos = arg.find(_S('\\')); @@ -236,6 +237,7 @@ struct SpecMP3 : SpecBase if (!lowerArg.compare(0, 2, _S("fe"))) { doMPTFE = true; + feargs.reserve(args.size()); size_t slashPos = arg.find(_S('/')); if (slashPos == HECL::SystemString::npos) slashPos = arg.find(_S('\\')); @@ -253,13 +255,13 @@ struct SpecMP3 : SpecBase if (!doMP3 && !doMPTFE) return false; - NOD::DiscGCN::IPartition* partition = disc.getDataPartition(); - NOD::DiscBase::IPartition::Node& root = partition->getFSTRoot(); + NOD::Partition* partition = disc.getDataPartition(); + NOD::Node& root = partition->getFSTRoot(); /* MP3 extract */ if (doMP3) { - NOD::DiscBase::IPartition::Node::DirectoryIterator dolIt = root.find("rs5mp3_p.dol"); + NOD::Node::DirectoryIterator dolIt = root.find("rs5mp3_p.dol"); if (dolIt == root.end()) return false; @@ -285,7 +287,7 @@ struct SpecMP3 : SpecBase /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node::DirectoryIterator mp3It = root.find("MP3"); + NOD::Node::DirectoryIterator mp3It = root.find("MP3"); if (mp3It == root.end()) return false; buildPaks(*mp3It, mp3args, rep, false); @@ -294,7 +296,7 @@ struct SpecMP3 : SpecBase /* MPT Frontend extract */ if (doMPTFE) { - NOD::DiscBase::IPartition::Node::DirectoryIterator dolIt = root.find("rs5fe_p.dol"); + NOD::Node::DirectoryIterator dolIt = root.find("rs5fe_p.dol"); if (dolIt == root.end()) return false; @@ -314,7 +316,7 @@ struct SpecMP3 : SpecBase } /* Iterate PAKs and build level options */ - NOD::DiscBase::IPartition::Node::DirectoryIterator feIt = root.find("fe"); + NOD::Node::DirectoryIterator feIt = root.find("fe"); if (feIt == root.end()) return false; buildPaks(*feIt, feargs, rep, true); @@ -352,7 +354,7 @@ struct SpecMP3 : SpecBase nodeCount = m_nonPaks.size(); // TODO: Make this more granular - for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks) + for (const NOD::Node* node : m_nonPaks) { node->extractToDirectory(mp3WorkPath.getAbsolutePath(), ctx); prog++; @@ -402,7 +404,7 @@ struct SpecMP3 : SpecBase nodeCount = m_feNonPaks.size(); // TODO: Make this more granular - for (const NOD::DiscBase::IPartition::Node* node : m_feNonPaks) + for (const NOD::Node* node : m_feNonPaks) { node->extractToDirectory(m_feWorkPath.getAbsolutePath(), ctx); prog++; @@ -435,6 +437,11 @@ struct SpecMP3 : SpecBase return true; } + bool checkPathPrefix(const HECL::ProjectPath& path) + { + return path.getRelativePath().compare(0, 4, "MP3/") == 0; + } + bool validateYAMLDNAType(FILE* fp) const { if (BigYAML::ValidateFromYAMLFile(fp)) @@ -445,6 +452,22 @@ struct SpecMP3 : SpecBase return true; return false; } + + void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const + { + } + + void cookYAML(FILE* in, const HECL::ProjectPath& out) const + { + } }; HECL::Database::DataSpecEntry SpecEntMP3 diff --git a/NODLib b/NODLib index dc9dcdcd7..322d1c48c 160000 --- a/NODLib +++ b/NODLib @@ -1 +1 @@ -Subproject commit dc9dcdcd7930328b87d4cc495e97e6475895a2f1 +Subproject commit 322d1c48cdd2132fc9d5ffa0d1ca79469453b6df diff --git a/hecl b/hecl index e8544adf4..dd557bb7c 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit e8544adf496c1aeb2b9be212fa34cfc295e807a8 +Subproject commit dd557bb7c5a3a409988d1b24d81ddd1f66791701