2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-15 23:37:02 +00:00

All cooked resources extracting; decompression bug-fixes

This commit is contained in:
Jack Andersen
2015-07-17 18:33:38 -10:00
parent 94d84d8991
commit dea341d27b
22 changed files with 564 additions and 168 deletions

View File

@@ -21,8 +21,7 @@ PAKBridge::PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPar
std::string PAKBridge::getLevelString() const
{
std::string retval;
std::set<HECL::SystemString> worldNames;
std::set<std::string, CaseInsensitiveCompare> uniq;
for (const PAK::Entry& entry : m_pak.m_entries)
{
if (entry.type == Retro::MLVL)
@@ -36,16 +35,18 @@ std::string PAKBridge::getLevelString() const
PAKEntryReadStream rs = nameEnt->beginReadStream(m_node);
STRG mlvlName;
mlvlName.read(rs);
worldNames.emplace(mlvlName.getSystemString(ENGL, 0));
uniq.insert(mlvlName.getUTF8(ENGL, 0));
}
}
}
for (const std::string& name : worldNames)
std::string retval;
bool comma = false;
for (const std::string& str : uniq)
{
if (retval.size())
if (comma)
retval += _S(", ");
retval += name;
comma = true;
retval += str;
}
return retval;
}
@@ -53,20 +54,35 @@ std::string PAKBridge::getLevelString() const
ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry)
{
if (entry.type == Retro::STRG)
return {STRG::Extract<STRG>, ".strg"};
return {STRG::Extract, ".as"};
return {};
}
bool PAKBridge::extractResources(const HECL::ProjectPath& dirOut)
bool PAKBridge::extractResources(const HECL::ProjectPath& workingOut,
const HECL::ProjectPath& cookedOut,
bool force)
{
for (const std::pair<UniqueID64, PAK::Entry*>& item : m_pak.m_idMap)
{
PAKEntryReadStream s;
ResExtractor extractor = LookupExtractor(*item.second);
if (extractor.func)
{
PAKEntryReadStream strgIn = item.second->beginReadStream(m_node);
HECL::ProjectPath resPath(dirOut, m_pak.bestEntryName(*item.second) + extractor.fileExt);
extractor.func(strgIn, resPath);
HECL::ProjectPath workPath(workingOut, m_pak.bestEntryName(*item.second) + extractor.fileExt);
if (force || workPath.getPathType() == HECL::ProjectPath::PT_NONE)
{
s = item.second->beginReadStream(m_node);
extractor.func(s, workPath);
}
}
HECL::ProjectPath cookPath(cookedOut, m_pak.bestEntryName(*item.second));
if (force || cookPath.getPathType() == HECL::ProjectPath::PT_NONE)
{
if (!s)
s = item.second->beginReadStream(m_node);
FILE* fout = HECL::Fopen(cookPath.getAbsolutePath().c_str(), _S("wb"));
fwrite(s.data(), 1, s.length(), fout);
fclose(fout);
}
}
return true;