2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 17:47:43 +00:00

began doExtract method

This commit is contained in:
Jack Andersen
2015-07-15 15:57:34 -10:00
parent a4d1fdbcfa
commit 07ae1e7379
31 changed files with 274 additions and 64 deletions

View File

@@ -1,4 +1,5 @@
#include <utility>
#include <stdio.h>
#define NOD_ATHENA 1
#include "SpecBase.hpp"
@@ -9,6 +10,8 @@
namespace Retro
{
static LogVisor::LogModule Log("Retro::SpecMP1");
struct SpecMP1 : SpecBase
{
bool checkStandaloneID(const char* id) const
@@ -95,7 +98,7 @@ struct SpecMP1 : SpecBase
m_orderedPaks[dpak.node.getName()] = &dpak;
/* Assemble extract report */
for (std::pair<std::string, DiscPAK*> item : m_orderedPaks)
for (const std::pair<std::string, DiscPAK*>& item : m_orderedPaks)
{
rep.childOpts.emplace_back();
ExtractReport& childRep = rep.childOpts.back();
@@ -205,8 +208,36 @@ struct SpecMP1 : SpecBase
return true;
}
bool extractFromDisc()
bool extractFromDisc(NOD::DiscBase& disc, const HECL::Database::Project& project)
{
HECL::ProjectPath mp1Path(project.getProjectRootPath(), "MP1");
for (const DiscPAK& pak : m_paks)
{
const std::string& name = pak.node.getName();
std::string::const_iterator extit = name.end() - 4;
std::string baseName(name.begin(), extit);
HECL::ProjectPath pakPath(mp1Path, baseName);
for (const std::pair<UniqueID32, DNAMP1::PAK::Entry*>& item : pak.pak.m_idMap)
{
if (item.second->type == STRG)
{
DNAMP1::STRG strg;
PAKEntryReadStream strgIn = item.second->beginReadStream(pak.node);
strg.read(strgIn);
HECL::SystemChar strgPath[1024];
HECL::SNPrintf(strgPath, 1024, _S("%s/%08X.strg"), pakPath.getAbsolutePath().c_str(), item.second->id.toUint32());
std::ofstream strgOut(strgPath);
strg.writeAngelScript(strgOut);
}
}
}
return true;
}
bool checkFromProject(HECL::Database::Project& proj)