2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 14:24:56 +00:00

Initial DNAMP3 fixes various missing loader imps

This commit is contained in:
2018-07-08 16:03:35 -07:00
parent ef1f9d564c
commit 56a48cd624
22 changed files with 418 additions and 17 deletions

View File

@@ -264,8 +264,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK& pak, const PAK::En
{
switch (entry.type)
{
case SBIG('CAUD'):
return {CAUD::Extract, {_S(".yaml")}};
// case SBIG('CAUD'):
// return {CAUD::Extract, {_S(".yaml")}};
case SBIG('STRG'):
return {STRG::Extract, {_S(".yaml")}};
case SBIG('TXTR'):

View File

@@ -157,7 +157,9 @@ struct SpecMP2 : SpecBase
m_cookPath(project.getProjectCookedPath(SpecEntMP2), _S("MP2")),
m_pakRouter(*this, m_workPath, m_cookPath),
m_idRestorer({project.getProjectWorkingPath(), "MP2/!original_ids.yaml"}, project)
{}
{
setThreadProject();
}
void buildPaks(nod::Node& root,
const std::vector<hecl::SystemString>& args,

View File

@@ -25,6 +25,90 @@ static logvisor::Module Log("urde::SpecMP3");
extern hecl::Database::DataSpecEntry SpecEntMP3;
extern hecl::Database::DataSpecEntry SpecEntMP3ORIG;
static const std::unordered_set<uint64_t> IndividualOrigIDs =
{
};
struct OriginalIDs
{
static void Generate(PAKRouter<DNAMP3::PAKBridge>& pakRouter, hecl::Database::Project& project)
{
std::unordered_set<UniqueID64> addedIDs;
std::vector<UniqueID64> originalIDs;
pakRouter.enumerateResources([&](const DNAMP3::PAK::Entry* ent) {
if (ent->type == FOURCC('MLVL') ||
ent->type == FOURCC('SCAN') ||
ent->type == FOURCC('MREA') ||
IndividualOrigIDs.find(ent->id.toUint64()) != IndividualOrigIDs.end())
{
if (addedIDs.find(ent->id) == addedIDs.cend())
{
addedIDs.insert(ent->id);
originalIDs.push_back(ent->id);
}
}
return true;
});
std::sort(originalIDs.begin(), originalIDs.end());
athena::io::YAMLDocWriter yamlW("MP3OriginalIDs");
for (const UniqueID64& id : originalIDs)
{
hecl::ProjectPath path = pakRouter.getWorking(id);
yamlW.writeString(id.toString().c_str(), path.getRelativePathUTF8());
}
hecl::ProjectPath path(project.getProjectWorkingPath(), "MP3/!original_ids.yaml");
path.makeDirChain(false);
athena::io::FileWriter fileW(path.getAbsolutePath());
yamlW.finish(&fileW);
}
static void Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
{
hecl::Database::Project& project = inPath.getProject();
athena::io::YAMLDocReader r;
athena::io::FileReader fr(inPath.getAbsolutePath());
if (!fr.isOpen() || !r.parse(&fr))
return;
std::vector<std::pair<UniqueID64, UniqueID64>> originalIDs;
originalIDs.reserve(r.getRootNode()->m_mapChildren.size());
for (const auto& node : r.getRootNode()->m_mapChildren)
{
char* end = const_cast<char*>(node.first.c_str());
u32 id = strtoul(end, &end, 16);
if (end != node.first.c_str() + 8)
continue;
hecl::ProjectPath path(project.getProjectWorkingPath(), node.second->m_scalarString.c_str());
originalIDs.push_back(std::make_pair(id, path.hash().val32()));
}
std::sort(originalIDs.begin(), originalIDs.end(),
[](const std::pair<UniqueID64, UniqueID64>& a, const std::pair<UniqueID64, UniqueID64>& b) {
return a.first < b.first;
});
athena::io::FileWriter w(outPath.getAbsolutePath());
w.writeUint32Big(originalIDs.size());
for (const auto& idPair : originalIDs)
{
idPair.first.write(w);
idPair.second.write(w);
}
std::sort(originalIDs.begin(), originalIDs.end(),
[](const std::pair<UniqueID64, UniqueID64>& a, const std::pair<UniqueID64, UniqueID64>& b) {
return a.second < b.second;
});
for (const auto& idPair : originalIDs)
{
idPair.second.write(w);
idPair.first.write(w);
}
}
};
struct SpecMP3 : SpecBase
{
bool checkStandaloneID(const char* id) const
@@ -52,6 +136,13 @@ struct SpecMP3 : SpecBase
hecl::ProjectPath m_feWorkPath;
hecl::ProjectPath m_feCookPath;
PAKRouter<DNAMP3::PAKBridge> m_fePakRouter;
IDRestorer<UniqueID64> m_idRestorer;
void setThreadProject()
{
SpecBase::setThreadProject();
UniqueIDBridge::SetIDRestorer(&m_idRestorer);
}
SpecMP3(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: SpecBase(specEntry, project, pc),
@@ -60,7 +151,11 @@ struct SpecMP3 : SpecBase
m_pakRouter(*this, m_workPath, m_cookPath),
m_feWorkPath(project.getProjectWorkingPath(), _S("fe")),
m_feCookPath(project.getProjectCookedPath(SpecEntMP3), _S("fe")),
m_fePakRouter(*this, m_feWorkPath, m_feCookPath) {}
m_fePakRouter(*this, m_feWorkPath, m_feCookPath),
m_idRestorer({project.getProjectWorkingPath(), "MP3/!original_ids.yaml"}, project)
{
setThreadProject();
}
void buildPaks(nod::Node& root,
const std::vector<hecl::SystemString>& args,
@@ -419,6 +514,9 @@ struct SpecMP3 : SpecBase
}
process.waitUntilComplete();
/* Generate original ID mapping for MLVL and SCAN entries - marks complete project */
OriginalIDs::Generate(m_pakRouter, m_project);
}
if (doMPTFE)
@@ -595,6 +693,21 @@ struct SpecMP3 : SpecBase
FCookProgress progress)
{
}
UniqueID64 newToOriginal(urde::CAssetId id) const
{
if (UniqueID64 origId = m_idRestorer.newToOriginal({id.Value(), true}))
return {origId.toUint64(), true};
return {uint32_t(id.Value()), true};
}
urde::CAssetId originalToNew(UniqueID64 id) const
{
if (UniqueID64 newId = m_idRestorer.originalToNew(id))
return newId.toUint64();
return id.toUint64();
}
};
hecl::Database::DataSpecEntry SpecEntMP3