Working MP1 extract with tags replaced with paths

This commit is contained in:
Jack Andersen 2016-03-01 15:49:21 -10:00
parent 8648dfbf10
commit 7049ab2b1d
15 changed files with 104 additions and 67 deletions

View File

@ -121,6 +121,8 @@ public:
}
void write(Athena::io::YAMLDocWriter& writer) const
{
if (!operator bool())
return;
writer.writeString(nullptr, UniqueIDBridge::TranslatePakIdToPath(*this).getRelativePathUTF8());
}
size_t binarySize(size_t __isz) const
@ -132,6 +134,7 @@ public:
bool operator!=(const UniqueID32& other) const {return m_id != other.m_id;}
bool operator==(const UniqueID32& other) const {return m_id == other.m_id;}
uint32_t toUint32() const {return m_id;}
uint64_t toUint64() const {return m_id;}
std::string toString() const
{
char buf[9];
@ -178,6 +181,8 @@ public:
}
void write(Athena::io::YAMLDocWriter& writer) const
{
if (!operator bool())
return;
writer.writeString(nullptr, UniqueIDBridge::TranslatePakIdToPath(*this).getRelativePathUTF8());
}
size_t binarySize(size_t __isz) const
@ -257,6 +262,8 @@ public:
}
void write(Athena::io::YAMLDocWriter& writer) const
{
if (!operator bool())
return;
writer.writeString(nullptr, UniqueIDBridge::TranslatePakIdToPath(*this).getRelativePathUTF8());
}
size_t binarySize(size_t __isz) const

View File

@ -260,7 +260,6 @@ public:
void build(std::vector<BRIDGETYPE>& bridges, std::function<void(float)> progress)
{
g_PakRouter = this;
m_bridges = &bridges;
m_bridgePaths.clear();
@ -304,6 +303,8 @@ public:
else
m_uniqueEntries[entry.first] = std::make_pair(bridgeIdx, entry.second);
}
else
m_uniqueEntries[entry.first] = std::make_pair(bridgeIdx, entry.second);
}
/* Add RigPairs to global map */
@ -313,10 +314,12 @@ public:
++bridgeIdx;
}
/* Add named resources to catalog YAML */
Athena::io::YAMLDocWriter catalogWriter(nullptr);
/* Add named resources to catalog YAML files */
for (BRIDGETYPE& bridge : bridges)
{
Athena::io::YAMLDocWriter catalogWriter(nullptr);
enterPAKBridge(bridge);
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
for (const auto& namedEntry : pak.m_nameEntries)
{
@ -324,18 +327,20 @@ public:
catalogWriter.writeString(nullptr, getWorking(namedEntry.id).getRelativePathUTF8().c_str());
catalogWriter.leaveSubRecord();
}
}
/* Write catalog */
HECL::SystemString catalogPath = HECL::ProjectPath(m_gameWorking, "catalog.yaml").getAbsolutePath();
FILE* catalog = HECL::Fopen(catalogPath.c_str(), _S("w"));
yaml_emitter_set_output_file(catalogWriter.getEmitter(), catalog);
catalogWriter.finish();
fclose(catalog);
/* Write catalog */
const HECL::ProjectPath& pakPath = m_bridgePaths[m_curBridgeIdx].first;
HECL::SystemString catalogPath = HECL::ProjectPath(pakPath, "catalog.yaml").getAbsolutePath();
FILE* catalog = HECL::Fopen(catalogPath.c_str(), _S("w"));
yaml_emitter_set_output_file(catalogWriter.getEmitter(), catalog);
catalogWriter.finish();
fclose(catalog);
}
}
void enterPAKBridge(const BRIDGETYPE& pakBridge)
{
g_PakRouter = this;
auto pit = m_bridgePaths.begin();
size_t bridgeIdx = 0;
for (const BRIDGETYPE& bridge : *m_bridges)
@ -353,12 +358,13 @@ public:
++bridgeIdx;
}
LogDNACommon.report(LogVisor::FatalError, "PAKBridge provided to PAKRouter::enterPAKBridge() was not part of build()");
g_PakRouter = this;
}
HECL::ProjectPath getWorking(const EntryType* entry,
const ResExtractor<BRIDGETYPE>& extractor) const
{
if (!entry)
return HECL::ProjectPath();
if (!m_pak)
LogDNACommon.report(LogVisor::FatalError,
"PAKRouter::enterPAKBridge() must be called before PAKRouter::getWorkingPath()");
@ -370,9 +376,9 @@ public:
const HECL::ProjectPath& pakPath = m_bridgePaths[m_curBridgeIdx].first;
pakPath.makeDir();
#if HECL_UCS2
HECL::SystemString entName = HECL::UTF8ToWide(m_pak->bestEntryName(*entry));
HECL::SystemString entName = HECL::UTF8ToWide(getBestEntryName(*entry));
#else
HECL::SystemString entName = m_pak->bestEntryName(*entry);
HECL::SystemString entName = getBestEntryName(*entry);
#endif
if (extractor.fileExts[0] && !extractor.fileExts[1])
entName += extractor.fileExts[0];
@ -387,9 +393,9 @@ public:
pakPath.makeDir();
HECL::ProjectPath uniquePath = entry->unique.uniquePath(pakPath);
#if HECL_UCS2
HECL::SystemString entName = HECL::UTF8ToWide(m_pak->bestEntryName(*entry));
HECL::SystemString entName = HECL::UTF8ToWide(getBestEntryName(*entry));
#else
HECL::SystemString entName = m_pak->bestEntryName(*entry);
HECL::SystemString entName = getBestEntryName(*entry);
#endif
if (extractor.fileExts[0] && !extractor.fileExts[1])
entName += extractor.fileExts[0];
@ -399,11 +405,10 @@ public:
auto sharedSearch = m_sharedEntries.find(entry->id);
if (sharedSearch != m_sharedEntries.end())
{
const HECL::ProjectPath& pakPath = m_bridgePaths[m_curBridgeIdx].first;
#if HECL_UCS2
HECL::SystemString entBase = HECL::UTF8ToWide(m_pak->bestEntryName(*entry));
HECL::SystemString entBase = HECL::UTF8ToWide(getBestEntryName(*entry));
#else
HECL::SystemString entBase = m_pak->bestEntryName(*entry);
HECL::SystemString entBase = getBestEntryName(*entry);
#endif
HECL::SystemString entName = entBase;
if (extractor.fileExts[0] && !extractor.fileExts[1])
@ -419,6 +424,8 @@ public:
HECL::ProjectPath getWorking(const EntryType* entry) const
{
if (!entry)
return HECL::ProjectPath();
return getWorking(entry, BRIDGETYPE::LookupExtractor(*entry));
}
@ -429,6 +436,8 @@ public:
HECL::ProjectPath getCooked(const EntryType* entry) const
{
if (!entry)
return HECL::ProjectPath();
if (!m_pak)
LogDNACommon.report(LogVisor::FatalError,
"PAKRouter::enterPAKBridge() must be called before PAKRouter::getCookedPath()");
@ -439,7 +448,7 @@ public:
{
const HECL::ProjectPath& pakPath = m_bridgePaths[m_curBridgeIdx].second;
pakPath.makeDir();
return HECL::ProjectPath(pakPath, m_pak->bestEntryName(*entry));
return HECL::ProjectPath(pakPath, getBestEntryName(*entry));
}
}
auto uniqueSearch = m_uniqueEntries.find(entry->id);
@ -448,13 +457,13 @@ public:
const HECL::ProjectPath& pakPath = m_bridgePaths[uniqueSearch->second.first].second;
pakPath.makeDir();
HECL::ProjectPath uniquePath = entry->unique.uniquePath(pakPath);
return HECL::ProjectPath(uniquePath, m_pak->bestEntryName(*entry));
return HECL::ProjectPath(uniquePath, getBestEntryName(*entry));
}
auto sharedSearch = m_sharedEntries.find(entry->id);
if (sharedSearch != m_sharedEntries.end())
{
m_sharedCooked.makeDir();
return HECL::ProjectPath(m_sharedCooked, m_pak->bestEntryName(*entry));
return HECL::ProjectPath(m_sharedCooked, getBestEntryName(*entry));
}
LogDNACommon.report(LogVisor::FatalError, "Unable to find entry %s", entry->id.toString().c_str());
return HECL::ProjectPath();
@ -484,21 +493,33 @@ public:
std::string getBestEntryName(const EntryType& entry) const
{
if (!m_pak)
LogDNACommon.report(LogVisor::FatalError,
"PAKRouter::enterPAKBridge() must be called before PAKRouter::getBestEntryName()");
return m_pak->bestEntryName(entry);
std::string name;
for (const BRIDGETYPE& bridge : *m_bridges)
{
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
bool named;
name = pak.bestEntryName(entry, named);
if (named)
return name;
}
return name;
}
std::string getBestEntryName(const IDType& entry) const
{
if (!m_pak)
LogDNACommon.report(LogVisor::FatalError,
"PAKRouter::enterPAKBridge() must be called before PAKRouter::getBestEntryName()");
const typename BRIDGETYPE::PAKType::Entry* e = m_pak->lookupEntry(entry);
if (!e)
return entry.toString();
return m_pak->bestEntryName(*e);
std::string name;
for (const BRIDGETYPE& bridge : *m_bridges)
{
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
const typename BRIDGETYPE::PAKType::Entry* e = pak.lookupEntry(entry);
if (!e)
continue;
bool named;
name = pak.bestEntryName(*e, named);
if (named)
return name;
}
return name;
}
bool extractResources(const BRIDGETYPE& pakBridge, bool force,

View File

@ -87,10 +87,11 @@ void PAKBridge::build()
PAKEntryReadStream rs = entry.beginReadStream(m_node);
mlvl.read(rs);
}
bool named;
#if HECL_UCS2
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry));
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry, named));
#else
level.name = m_pak.bestEntryName(entry);
level.name = m_pak.bestEntryName(entry, named);
#endif
level.areas.reserve(mlvl.areaCount);
unsigned layerIdx = 0;

View File

@ -39,7 +39,7 @@ struct MLVL : BigYAML
Value<atVec4f> transformMtx[3];
Value<atVec3f> aabb[2];
UniqueID32 areaMREAId;
UniqueID32 areaId;
Value<atUint32> areaId;
Value<atUint32> attachedAreaCount;
Vector<atUint16, DNA_COUNT(attachedAreaCount)> attachedAreas;

View File

@ -69,14 +69,18 @@ struct PAK : BigDNA
return nullptr;
}
std::string bestEntryName(const Entry& entry) const
std::string bestEntryName(const Entry& entry, bool& named) const
{
/* Prefer named entries first */
for (const NameEntry& nentry : m_nameEntries)
if (nentry.id == entry.id)
{
named = true;
return nentry.name;
}
/* Otherwise return ID format string */
named = false;
return entry.type.toString() + '_' + entry.id.toString();
}

View File

@ -23,7 +23,7 @@ struct SpecialFunction : IScriptObject
struct LayerSwitch : BigYAML
{
DECL_YAML
UniqueID32 area;
Value<atUint32> area;
Value<atUint32> layerIdx;
} layerSwitch;
Value<EPickupType> pickup;

View File

@ -81,10 +81,11 @@ void PAKBridge::build()
PAKEntryReadStream rs = entry.beginReadStream(m_node);
mlvl.read(rs);
}
bool named;
#if HECL_UCS2
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry));
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry, named));
#else
level.name = m_pak.bestEntryName(entry);
level.name = m_pak.bestEntryName(entry, named);
#endif
level.areas.reserve(mlvl.areaCount);
unsigned layerIdx = 0;

View File

@ -29,7 +29,7 @@ struct MLVL : BigYAML
Value<atVec4f> transformMtx[3];
Value<atVec3f> aabb[2];
UniqueID32 areaMREAId;
UniqueID32 areaId;
Value<atUint32> areaId;
Value<atUint32> attachedAreaCount;
Vector<atUint16, DNA_COUNT(attachedAreaCount)> attachedAreas;

View File

@ -89,10 +89,11 @@ void PAKBridge::build()
PAKEntryReadStream rs = entry.beginReadStream(m_node);
mlvl.read(rs);
}
bool named;
#if HECL_UCS2
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry));
level.name = HECL::UTF8ToWide(m_pak.bestEntryName(entry, named));
#else
level.name = m_pak.bestEntryName(entry);
level.name = m_pak.bestEntryName(entry, named);
#endif
level.areas.reserve(mlvl.areaCount);
unsigned layerIdx = 0;

View File

@ -28,7 +28,7 @@ struct MLVL : BigYAML
Value<atVec4f> transformMtx[3];
Value<atVec3f> aabb[2];
UniqueID64 areaMREAId;
UniqueID64 areaId;
Value<atUint64> areaId;
Value<atUint32> attachedAreaCount;
Vector<atUint16, DNA_COUNT(attachedAreaCount)> attachedAreas;

View File

@ -80,14 +80,18 @@ struct PAK : BigDNA
return nullptr;
}
inline std::string bestEntryName(const Entry& entry) const
inline std::string bestEntryName(const Entry& entry, bool& named) const
{
/* Prefer named entries first */
for (const NameEntry& nentry : m_nameEntries)
if (nentry.id == entry.id)
{
named = true;
return nentry.name;
}
/* Otherwise return ID format string */
named = false;
return entry.type.toString() + '_' + entry.id.toString();
}

View File

@ -219,6 +219,11 @@ struct SpecMP1 : SpecBase
{
NOD::ExtractionContext ctx = {true, force, nullptr};
m_workPath.makeDir();
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP1);
cookPath.makeDir();
m_cookPath.makeDir();
progress(_S("Indexing PAKs"), _S(""), 2, 0.0);
m_pakRouter.build(m_paks, [&progress](float factor)
{
@ -226,7 +231,6 @@ struct SpecMP1 : SpecBase
});
progress(_S("Indexing PAKs"), _S(""), 2, 1.0);
m_workPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp1OutPath(outPath, _S("MP1"));
@ -244,10 +248,6 @@ struct SpecMP1 : SpecBase
}
progress(_S("MP1 Root"), _S(""), 3, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP1);
cookPath.makeDir();
m_cookPath.makeDir();
int compIdx = 4;
prog = 0;
for (std::pair<std::string, DNAMP1::PAKBridge*> pair : m_orderedPaks)

View File

@ -209,6 +209,11 @@ struct SpecMP2 : SpecBase
{
NOD::ExtractionContext ctx = {true, force, nullptr};
m_workPath.makeDir();
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP2);
cookPath.makeDir();
m_cookPath.makeDir();
progress(_S("Indexing PAKs"), _S(""), 2, 0.0);
m_pakRouter.build(m_paks, [&progress](float factor)
{
@ -216,7 +221,6 @@ struct SpecMP2 : SpecBase
});
progress(_S("Indexing PAKs"), _S(""), 2, 1.0);
m_workPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp2OutPath(outPath, _S("MP2"));
@ -234,10 +238,6 @@ struct SpecMP2 : SpecBase
}
progress(_S("MP2 Root"), _S(""), 3, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP2);
cookPath.makeDir();
m_cookPath.makeDir();
int compIdx = 4;
prog = 0;
for (std::pair<std::string, DNAMP2::PAKBridge*> pair : m_orderedPaks)

View File

@ -339,6 +339,11 @@ struct SpecMP3 : SpecBase
}};
if (doMP3)
{
m_workPath.makeDir();
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
m_cookPath.makeDir();
progress(_S("Indexing PAKs"), _S(""), compIdx, 0.0);
m_pakRouter.build(m_paks, [&progress, &compIdx](float factor)
{
@ -346,8 +351,6 @@ struct SpecMP3 : SpecBase
});
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
HECL::ProjectPath mp3WorkPath(m_project.getProjectWorkingPath(), _S("MP3"));
mp3WorkPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp3OutPath(outPath, _S("MP3"));
@ -367,11 +370,6 @@ struct SpecMP3 : SpecBase
progress(currentTarget.c_str(), _S(""), compIdx++, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
HECL::ProjectPath mp3CookPath(cookPath, "MP3");
mp3CookPath.makeDir();
prog = 0;
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_orderedPaks)
{
@ -394,6 +392,11 @@ struct SpecMP3 : SpecBase
if (doMPTFE)
{
m_feWorkPath.makeDir();
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
m_feCookPath.makeDir();
progress(_S("Indexing PAKs"), _S(""), compIdx, 0.0);
m_fePakRouter.build(m_fePaks, [&progress, &compIdx](float factor)
{
@ -401,7 +404,6 @@ struct SpecMP3 : SpecBase
});
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
m_feWorkPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath feOutPath(outPath, _S("fe"));
@ -419,10 +421,6 @@ struct SpecMP3 : SpecBase
}
progress(currentTarget.c_str(), _S(""), compIdx++, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
m_feCookPath.makeDir();
prog = 0;
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_feOrderedPaks)
{

2
hecl

@ -1 +1 @@
Subproject commit f33c1774196a2648599b57dd3638b415dc6c77e5
Subproject commit 448e1953e1ac457aa2ab21aef3030a04aca1e53e