mirror of https://github.com/AxioDL/metaforce.git
Full PAK Indexing even for partial extracts
This commit is contained in:
parent
3540a3e19a
commit
739c31d87c
|
@ -208,6 +208,25 @@ struct ResExtractor
|
||||||
unsigned weight;
|
unsigned weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Level hierarchy representation */
|
||||||
|
template <class IDType>
|
||||||
|
struct Level
|
||||||
|
{
|
||||||
|
HECL::SystemString name;
|
||||||
|
struct Area
|
||||||
|
{
|
||||||
|
HECL::SystemString name;
|
||||||
|
struct Layer
|
||||||
|
{
|
||||||
|
HECL::SystemString name;
|
||||||
|
std::unordered_set<IDType> resources;
|
||||||
|
};
|
||||||
|
std::vector<Layer> layers;
|
||||||
|
std::unordered_set<IDType> resources;
|
||||||
|
};
|
||||||
|
std::unordered_map<IDType, Area> areas;
|
||||||
|
};
|
||||||
|
|
||||||
/* PAKRouter (for detecting shared entry locations) */
|
/* PAKRouter (for detecting shared entry locations) */
|
||||||
template <class BRIDGETYPE>
|
template <class BRIDGETYPE>
|
||||||
class PAKRouter
|
class PAKRouter
|
||||||
|
|
|
@ -25,8 +25,10 @@ static bool GetNoShare(const std::string& name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node)
|
PAKBridge::PAKBridge(HECL::Database::Project& project,
|
||||||
: m_project(project), m_node(node), m_pak(false, GetNoShare(node.getName()))
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract)
|
||||||
|
: m_project(project), m_node(node), m_pak(false, GetNoShare(node.getName())), m_doExtract(doExtract)
|
||||||
{
|
{
|
||||||
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
||||||
m_pak.read(rs);
|
m_pak.read(rs);
|
||||||
|
@ -73,7 +75,7 @@ void PAKBridge::build()
|
||||||
{
|
{
|
||||||
if (entry.type == FOURCC('MLVL'))
|
if (entry.type == FOURCC('MLVL'))
|
||||||
{
|
{
|
||||||
PAKBridge::Level& level = m_levelDeps[entry.id];
|
Level& level = m_levelDeps[entry.id];
|
||||||
|
|
||||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||||
MLVL mlvl;
|
MLVL mlvl;
|
||||||
|
|
|
@ -18,26 +18,14 @@ class PAKBridge
|
||||||
const NOD::DiscBase::IPartition::Node& m_node;
|
const NOD::DiscBase::IPartition::Node& m_node;
|
||||||
PAK m_pak;
|
PAK m_pak;
|
||||||
public:
|
public:
|
||||||
struct Level
|
bool m_doExtract;
|
||||||
{
|
using Level = Level<UniqueID32>;
|
||||||
HECL::SystemString name;
|
|
||||||
struct Area
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
struct Layer
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
std::unordered_set<UniqueID32> resources;
|
|
||||||
};
|
|
||||||
std::vector<Layer> layers;
|
|
||||||
std::unordered_set<UniqueID32> resources;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID32, Area> areas;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID32, Level> m_levelDeps;
|
std::unordered_map<UniqueID32, Level> m_levelDeps;
|
||||||
HECL::SystemString m_levelString;
|
HECL::SystemString m_levelString;
|
||||||
|
|
||||||
PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node);
|
PAKBridge(HECL::Database::Project& project,
|
||||||
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract=true);
|
||||||
void build();
|
void build();
|
||||||
static ResExtractor<PAKBridge> LookupExtractor(const PAK::Entry& entry);
|
static ResExtractor<PAKBridge> LookupExtractor(const PAK::Entry& entry);
|
||||||
const std::string& getName() const {return m_node.getName();}
|
const std::string& getName() const {return m_node.getName();}
|
||||||
|
|
|
@ -22,8 +22,10 @@ static bool GetNoShare(const std::string& name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node)
|
PAKBridge::PAKBridge(HECL::Database::Project& project,
|
||||||
: m_project(project), m_node(node), m_pak(true, GetNoShare(node.getName()))
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract)
|
||||||
|
: m_project(project), m_node(node), m_pak(true, GetNoShare(node.getName())), m_doExtract(doExtract)
|
||||||
{
|
{
|
||||||
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
||||||
m_pak.read(rs);
|
m_pak.read(rs);
|
||||||
|
@ -70,7 +72,7 @@ void PAKBridge::build()
|
||||||
{
|
{
|
||||||
if (entry.type == FOURCC('MLVL'))
|
if (entry.type == FOURCC('MLVL'))
|
||||||
{
|
{
|
||||||
PAKBridge::Level& level = m_levelDeps[entry.id];
|
Level& level = m_levelDeps[entry.id];
|
||||||
|
|
||||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||||
MLVL mlvl;
|
MLVL mlvl;
|
||||||
|
|
|
@ -18,26 +18,14 @@ class PAKBridge
|
||||||
const NOD::DiscBase::IPartition::Node& m_node;
|
const NOD::DiscBase::IPartition::Node& m_node;
|
||||||
DNAMP1::PAK m_pak;
|
DNAMP1::PAK m_pak;
|
||||||
public:
|
public:
|
||||||
struct Level
|
bool m_doExtract;
|
||||||
{
|
using Level = Level<UniqueID32>;
|
||||||
HECL::SystemString name;
|
|
||||||
struct Area
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
struct Layer
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
std::unordered_set<UniqueID32> resources;
|
|
||||||
};
|
|
||||||
std::vector<Layer> layers;
|
|
||||||
std::unordered_set<UniqueID32> resources;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID32, Area> areas;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID32, Level> m_levelDeps;
|
std::unordered_map<UniqueID32, Level> m_levelDeps;
|
||||||
HECL::SystemString m_levelString;
|
HECL::SystemString m_levelString;
|
||||||
|
|
||||||
PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node);
|
PAKBridge(HECL::Database::Project& project,
|
||||||
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract=true);
|
||||||
void build();
|
void build();
|
||||||
static ResExtractor<PAKBridge> LookupExtractor(const DNAMP1::PAK::Entry& entry);
|
static ResExtractor<PAKBridge> LookupExtractor(const DNAMP1::PAK::Entry& entry);
|
||||||
const std::string& getName() const {return m_node.getName();}
|
const std::string& getName() const {return m_node.getName();}
|
||||||
|
|
|
@ -24,8 +24,10 @@ static bool GetNoShare(const std::string& name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node)
|
PAKBridge::PAKBridge(HECL::Database::Project& project,
|
||||||
: m_project(project), m_node(node), m_pak(GetNoShare(node.getName()))
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract)
|
||||||
|
: m_project(project), m_node(node), m_pak(GetNoShare(node.getName())), m_doExtract(doExtract)
|
||||||
{
|
{
|
||||||
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
NOD::AthenaPartReadStream rs(node.beginReadStream());
|
||||||
m_pak.read(rs);
|
m_pak.read(rs);
|
||||||
|
@ -79,7 +81,7 @@ void PAKBridge::build()
|
||||||
{
|
{
|
||||||
if (entry.type == FOURCC('MLVL'))
|
if (entry.type == FOURCC('MLVL'))
|
||||||
{
|
{
|
||||||
PAKBridge::Level& level = m_levelDeps[entry.id];
|
Level& level = m_levelDeps[entry.id];
|
||||||
|
|
||||||
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
PAKEntryReadStream rs = entry.beginReadStream(m_node);
|
||||||
MLVL mlvl;
|
MLVL mlvl;
|
||||||
|
|
|
@ -18,26 +18,14 @@ class PAKBridge
|
||||||
const NOD::DiscBase::IPartition::Node& m_node;
|
const NOD::DiscBase::IPartition::Node& m_node;
|
||||||
PAK m_pak;
|
PAK m_pak;
|
||||||
public:
|
public:
|
||||||
struct Level
|
bool m_doExtract;
|
||||||
{
|
using Level = Level<UniqueID64>;
|
||||||
HECL::SystemString name;
|
|
||||||
struct Area
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
struct Layer
|
|
||||||
{
|
|
||||||
HECL::SystemString name;
|
|
||||||
std::unordered_set<UniqueID64> resources;
|
|
||||||
};
|
|
||||||
std::vector<Layer> layers;
|
|
||||||
std::unordered_set<UniqueID64> resources;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID64, Area> areas;
|
|
||||||
};
|
|
||||||
std::unordered_map<UniqueID64, Level> m_levelDeps;
|
std::unordered_map<UniqueID64, Level> m_levelDeps;
|
||||||
HECL::SystemString m_levelString;
|
HECL::SystemString m_levelString;
|
||||||
|
|
||||||
PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node);
|
PAKBridge(HECL::Database::Project& project,
|
||||||
|
const NOD::DiscBase::IPartition::Node& node,
|
||||||
|
bool doExtract=true);
|
||||||
void build();
|
void build();
|
||||||
static ResExtractor<PAKBridge> LookupExtractor(const PAK::Entry& entry);
|
static ResExtractor<PAKBridge> LookupExtractor(const PAK::Entry& entry);
|
||||||
inline const std::string& getName() const {return m_node.getName();}
|
inline const std::string& getName() const {return m_node.getName();}
|
||||||
|
|
|
@ -89,8 +89,7 @@ struct SpecMP1 : SpecBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (good)
|
m_paks.emplace_back(m_project, child, good);
|
||||||
m_paks.emplace_back(m_project, child);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,6 +106,8 @@ struct SpecMP1 : SpecBase
|
||||||
/* Assemble extract report */
|
/* Assemble extract report */
|
||||||
for (const std::pair<std::string, DNAMP1::PAKBridge*>& item : m_orderedPaks)
|
for (const std::pair<std::string, DNAMP1::PAKBridge*>& item : m_orderedPaks)
|
||||||
{
|
{
|
||||||
|
if (!item.second->m_doExtract)
|
||||||
|
continue;
|
||||||
rep.childOpts.emplace_back();
|
rep.childOpts.emplace_back();
|
||||||
ExtractReport& childRep = rep.childOpts.back();
|
ExtractReport& childRep = rep.childOpts.back();
|
||||||
HECL::SystemStringView nameView(item.first);
|
HECL::SystemStringView nameView(item.first);
|
||||||
|
@ -236,6 +237,9 @@ struct SpecMP1 : SpecBase
|
||||||
for (std::pair<std::string, DNAMP1::PAKBridge*> pair : m_orderedPaks)
|
for (std::pair<std::string, DNAMP1::PAKBridge*> pair : m_orderedPaks)
|
||||||
{
|
{
|
||||||
DNAMP1::PAKBridge& pak = *pair.second;
|
DNAMP1::PAKBridge& pak = *pair.second;
|
||||||
|
if (!pak.m_doExtract)
|
||||||
|
continue;
|
||||||
|
|
||||||
const std::string& name = pak.getName();
|
const std::string& name = pak.getName();
|
||||||
HECL::SystemStringView sysName(name);
|
HECL::SystemStringView sysName(name);
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,7 @@ struct SpecMP2 : SpecBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (good)
|
m_paks.emplace_back(m_project, child, good);
|
||||||
m_paks.emplace_back(m_project, child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +103,8 @@ struct SpecMP2 : SpecBase
|
||||||
/* Assemble extract report */
|
/* Assemble extract report */
|
||||||
for (const std::pair<std::string, DNAMP2::PAKBridge*>& item : m_orderedPaks)
|
for (const std::pair<std::string, DNAMP2::PAKBridge*>& item : m_orderedPaks)
|
||||||
{
|
{
|
||||||
|
if (!item.second->m_doExtract)
|
||||||
|
continue;
|
||||||
rep.childOpts.emplace_back();
|
rep.childOpts.emplace_back();
|
||||||
ExtractReport& childRep = rep.childOpts.back();
|
ExtractReport& childRep = rep.childOpts.back();
|
||||||
HECL::SystemStringView nameView(item.first);
|
HECL::SystemStringView nameView(item.first);
|
||||||
|
@ -229,6 +230,9 @@ struct SpecMP2 : SpecBase
|
||||||
for (std::pair<std::string, DNAMP2::PAKBridge*> pair : m_orderedPaks)
|
for (std::pair<std::string, DNAMP2::PAKBridge*> pair : m_orderedPaks)
|
||||||
{
|
{
|
||||||
DNAMP2::PAKBridge& pak = *pair.second;
|
DNAMP2::PAKBridge& pak = *pair.second;
|
||||||
|
if (!pak.m_doExtract)
|
||||||
|
continue;
|
||||||
|
|
||||||
const std::string& name = pak.getName();
|
const std::string& name = pak.getName();
|
||||||
HECL::SystemStringView sysName(name);
|
HECL::SystemStringView sysName(name);
|
||||||
|
|
||||||
|
|
|
@ -111,13 +111,10 @@ struct SpecMP3 : SpecBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (good)
|
|
||||||
{
|
|
||||||
if (fe)
|
if (fe)
|
||||||
m_fePaks.emplace_back(m_project, child);
|
m_fePaks.emplace_back(m_project, child, good);
|
||||||
else
|
else
|
||||||
m_paks.emplace_back(m_project, child);
|
m_paks.emplace_back(m_project, child, good);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +144,8 @@ struct SpecMP3 : SpecBase
|
||||||
/* Assemble extract report */
|
/* Assemble extract report */
|
||||||
for (const std::pair<std::string, DNAMP3::PAKBridge*>& item : fe ? m_feOrderedPaks : m_orderedPaks)
|
for (const std::pair<std::string, DNAMP3::PAKBridge*>& item : fe ? m_feOrderedPaks : m_orderedPaks)
|
||||||
{
|
{
|
||||||
|
if (!item.second->m_doExtract)
|
||||||
|
continue;
|
||||||
rep.childOpts.emplace_back();
|
rep.childOpts.emplace_back();
|
||||||
ExtractReport& childRep = rep.childOpts.back();
|
ExtractReport& childRep = rep.childOpts.back();
|
||||||
HECL::SystemStringView nameView(item.first);
|
HECL::SystemStringView nameView(item.first);
|
||||||
|
@ -159,6 +158,12 @@ struct SpecMP3 : SpecBase
|
||||||
childRep.desc = _S("Phaaze");
|
childRep.desc = _S("Phaaze");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (!item.first.compare("Metroid8.pak"))
|
||||||
|
{
|
||||||
|
/* Space world is misnamed */
|
||||||
|
childRep.desc = _S("Space");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
childRep.desc = item.second->getLevelString();
|
childRep.desc = item.second->getLevelString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +353,8 @@ struct SpecMP3 : SpecBase
|
||||||
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_orderedPaks)
|
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_orderedPaks)
|
||||||
{
|
{
|
||||||
DNAMP3::PAKBridge& pak = *pair.second;
|
DNAMP3::PAKBridge& pak = *pair.second;
|
||||||
m_pakRouter.enterPAKBridge(pak);
|
if (!pak.m_doExtract)
|
||||||
|
continue;
|
||||||
|
|
||||||
const std::string& name = pak.getName();
|
const std::string& name = pak.getName();
|
||||||
HECL::SystemStringView sysName(name);
|
HECL::SystemStringView sysName(name);
|
||||||
|
@ -391,6 +397,9 @@ struct SpecMP3 : SpecBase
|
||||||
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_feOrderedPaks)
|
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_feOrderedPaks)
|
||||||
{
|
{
|
||||||
DNAMP3::PAKBridge& pak = *pair.second;
|
DNAMP3::PAKBridge& pak = *pair.second;
|
||||||
|
if (!pak.m_doExtract)
|
||||||
|
continue;
|
||||||
|
|
||||||
const std::string& name = pak.getName();
|
const std::string& name = pak.getName();
|
||||||
HECL::SystemStringView sysName(name);
|
HECL::SystemStringView sysName(name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue