2016-03-02 07:29:19 +00:00
|
|
|
#include "PAK.hpp"
|
|
|
|
#include "../DNAMP1/DNAMP1.hpp"
|
|
|
|
#include "../DNAMP2/DNAMP2.hpp"
|
|
|
|
#include "../DNAMP3/DNAMP3.hpp"
|
|
|
|
|
|
|
|
namespace DataSpec
|
|
|
|
{
|
|
|
|
|
|
|
|
template <class PAKBRIDGE>
|
|
|
|
void UniqueResult::checkEntry(const PAKBRIDGE& pakBridge, const typename PAKBRIDGE::PAKType::Entry& entry)
|
|
|
|
{
|
|
|
|
UniqueResult::Type resultType = UniqueResult::Type::NotFound;
|
|
|
|
bool foundOneLayer = false;
|
2016-03-05 00:03:41 +00:00
|
|
|
const hecl::SystemString* levelName = nullptr;
|
2016-03-02 07:29:19 +00:00
|
|
|
typename PAKBRIDGE::PAKType::IDType levelId;
|
|
|
|
typename PAKBRIDGE::PAKType::IDType areaId;
|
|
|
|
unsigned layerIdx;
|
|
|
|
for (const auto& lpair : pakBridge.m_levelDeps)
|
|
|
|
{
|
|
|
|
if (entry.id == lpair.first)
|
|
|
|
{
|
|
|
|
levelName = &lpair.second.name;
|
|
|
|
resultType = UniqueResult::Type::Level;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& pair : lpair.second.areas)
|
|
|
|
{
|
|
|
|
unsigned l=0;
|
|
|
|
for (const auto& layer : pair.second.layers)
|
|
|
|
{
|
|
|
|
if (layer.resources.find(entry.id) != layer.resources.end())
|
|
|
|
{
|
|
|
|
if (foundOneLayer)
|
|
|
|
{
|
|
|
|
if (areaId == pair.first)
|
|
|
|
{
|
|
|
|
resultType = UniqueResult::Type::Area;
|
|
|
|
}
|
|
|
|
else if (levelId == lpair.first)
|
|
|
|
{
|
|
|
|
resultType = UniqueResult::Type::Level;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_type = UniqueResult::Type::Pak;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
resultType = UniqueResult::Type::Layer;
|
|
|
|
levelName = &lpair.second.name;
|
|
|
|
levelId = lpair.first;
|
|
|
|
areaId = pair.first;
|
|
|
|
layerIdx = l;
|
|
|
|
foundOneLayer = true;
|
|
|
|
}
|
|
|
|
++l;
|
|
|
|
}
|
|
|
|
if (pair.second.resources.find(entry.id) != pair.second.resources.end())
|
|
|
|
{
|
|
|
|
if (foundOneLayer)
|
|
|
|
{
|
|
|
|
if (areaId == pair.first)
|
|
|
|
{
|
|
|
|
resultType = UniqueResult::Type::Area;
|
|
|
|
}
|
|
|
|
else if (levelId == lpair.first)
|
|
|
|
{
|
|
|
|
resultType = UniqueResult::Type::Level;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_type = UniqueResult::Type::Pak;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
resultType = UniqueResult::Type::Area;
|
|
|
|
levelName = &lpair.second.name;
|
|
|
|
levelId = lpair.first;
|
|
|
|
areaId = pair.first;
|
|
|
|
foundOneLayer = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_type = resultType;
|
|
|
|
m_levelName = levelName;
|
|
|
|
if (resultType == UniqueResult::Type::Layer || resultType == UniqueResult::Type::Area)
|
|
|
|
{
|
|
|
|
const typename PAKBRIDGE::Level::Area& area = pakBridge.m_levelDeps.at(levelId).areas.at(areaId);
|
|
|
|
m_areaName = &area.name;
|
|
|
|
if (resultType == UniqueResult::Type::Layer)
|
|
|
|
{
|
|
|
|
const typename PAKBRIDGE::Level::Area::Layer& layer = area.layers[layerIdx];
|
|
|
|
m_layerName = &layer.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template void UniqueResult::checkEntry(const DNAMP1::PAKBridge& pakBridge,
|
|
|
|
const DNAMP1::PAKBridge::PAKType::Entry& entry);
|
|
|
|
template void UniqueResult::checkEntry(const DNAMP2::PAKBridge& pakBridge,
|
|
|
|
const DNAMP2::PAKBridge::PAKType::Entry& entry);
|
|
|
|
template void UniqueResult::checkEntry(const DNAMP3::PAKBridge& pakBridge,
|
|
|
|
const DNAMP3::PAKBridge::PAKType::Entry& entry);
|
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath UniqueResult::uniquePath(const hecl::ProjectPath& pakPath) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
if (m_type == Type::Pak)
|
|
|
|
return pakPath;
|
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath levelDir;
|
2016-03-02 07:29:19 +00:00
|
|
|
if (m_levelName)
|
|
|
|
levelDir.assign(pakPath, *m_levelName);
|
|
|
|
else
|
|
|
|
levelDir = pakPath;
|
|
|
|
|
|
|
|
if (m_type == Type::Area)
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath areaDir(levelDir, *m_areaName);
|
2016-03-02 07:29:19 +00:00
|
|
|
return areaDir;
|
|
|
|
}
|
|
|
|
else if (m_type == Type::Layer)
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath areaDir(levelDir, *m_areaName);
|
|
|
|
hecl::ProjectPath layerDir(areaDir, *m_layerName);
|
2016-03-02 07:29:19 +00:00
|
|
|
return layerDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
return levelDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
|
|
|
void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::function<void(float)> progress)
|
|
|
|
{
|
|
|
|
m_bridges = &bridges;
|
|
|
|
m_bridgePaths.clear();
|
|
|
|
|
|
|
|
m_uniqueEntries.clear();
|
|
|
|
m_sharedEntries.clear();
|
|
|
|
m_cmdlRigs.clear();
|
|
|
|
size_t count = 0;
|
|
|
|
float bridgesSz = bridges.size();
|
|
|
|
|
|
|
|
/* Route entries unique/shared per-pak */
|
|
|
|
size_t bridgeIdx = 0;
|
|
|
|
for (BRIDGETYPE& bridge : bridges)
|
|
|
|
{
|
|
|
|
const std::string& name = bridge.getName();
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemStringView sysName(name);
|
2016-03-02 07:29:19 +00:00
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString::const_iterator extit = sysName.sys_str().end() - 4;
|
|
|
|
hecl::SystemString baseName(sysName.sys_str().begin(), extit);
|
2016-03-02 07:29:19 +00:00
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
m_bridgePaths.emplace_back(std::make_pair(hecl::ProjectPath(m_gameWorking, baseName),
|
|
|
|
hecl::ProjectPath(m_gameCooked, baseName)));
|
2016-03-02 07:29:19 +00:00
|
|
|
|
|
|
|
/* Index this PAK */
|
|
|
|
bridge.build();
|
|
|
|
|
|
|
|
/* Add to global entry lookup */
|
|
|
|
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
|
|
|
for (const auto& entry : pak.m_idMap)
|
|
|
|
{
|
|
|
|
if (!pak.m_noShare)
|
|
|
|
{
|
|
|
|
auto sSearch = m_sharedEntries.find(entry.first);
|
|
|
|
if (sSearch != m_sharedEntries.end())
|
|
|
|
continue;
|
|
|
|
auto uSearch = m_uniqueEntries.find(entry.first);
|
|
|
|
if (uSearch != m_uniqueEntries.end())
|
|
|
|
{
|
|
|
|
m_uniqueEntries.erase(uSearch);
|
|
|
|
m_sharedEntries[entry.first] = std::make_pair(bridgeIdx, entry.second);
|
|
|
|
}
|
|
|
|
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 */
|
2016-09-19 05:29:05 +00:00
|
|
|
bridge.addCMDLRigPairs(*this, m_cmdlRigs, m_cskrCinfToCharacter);
|
2016-03-02 07:29:19 +00:00
|
|
|
|
|
|
|
progress(++count / bridgesSz);
|
|
|
|
++bridgeIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add named resources to catalog YAML files */
|
|
|
|
for (BRIDGETYPE& bridge : bridges)
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
athena::io::YAMLDocWriter catalogWriter(nullptr);
|
2016-03-02 07:29:19 +00:00
|
|
|
|
|
|
|
enterPAKBridge(bridge);
|
2016-10-01 23:20:20 +00:00
|
|
|
|
|
|
|
/* Add MAPA transforms to global map */
|
|
|
|
bridge.addMAPATransforms(*this, m_mapaTransforms, m_overrideEntries);
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
|
|
|
for (const auto& namedEntry : pak.m_nameEntries)
|
|
|
|
{
|
2016-09-19 05:29:05 +00:00
|
|
|
if (namedEntry.name == "holo_cinf")
|
|
|
|
continue; /* Problematic corner case */
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = catalogWriter.enterSubRecord(namedEntry.name.c_str()))
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
hecl::ProjectPath working = getWorking(namedEntry.id);
|
|
|
|
if (working.getAuxInfoUTF8().size())
|
|
|
|
{
|
|
|
|
if (auto v = catalogWriter.enterSubVector(nullptr))
|
|
|
|
{
|
|
|
|
catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str());
|
|
|
|
catalogWriter.writeString(nullptr, working.getAuxInfoUTF8().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
catalogWriter.writeString(nullptr, working.getRelativePathUTF8().c_str());
|
2016-09-19 05:29:05 +00:00
|
|
|
}
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write catalog */
|
2016-04-01 04:25:00 +00:00
|
|
|
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
|
|
|
const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first;
|
2017-01-17 01:23:19 +00:00
|
|
|
pakPath.makeDirChain(true);
|
2016-10-01 23:20:20 +00:00
|
|
|
hecl::SystemString catalogPath = hecl::ProjectPath(pakPath, "!catalog.yaml").getAbsolutePath();
|
2016-08-22 03:47:48 +00:00
|
|
|
athena::io::FileWriter writer(catalogPath);
|
|
|
|
catalogWriter.finish(&writer);
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
|
|
|
void PAKRouter<BRIDGETYPE>::enterPAKBridge(const BRIDGETYPE& pakBridge)
|
|
|
|
{
|
2016-04-10 04:49:02 +00:00
|
|
|
g_PakRouter.reset(this);
|
2016-03-02 07:29:19 +00:00
|
|
|
auto pit = m_bridgePaths.begin();
|
|
|
|
size_t bridgeIdx = 0;
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
if (&bridge == &pakBridge)
|
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
m_pak.reset(&pakBridge.getPAK());
|
|
|
|
m_node.reset(&pakBridge.getNode());
|
|
|
|
m_curBridgeIdx.reset(reinterpret_cast<void*>(bridgeIdx));
|
2016-03-02 07:29:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
++pit;
|
|
|
|
++bridgeIdx;
|
|
|
|
}
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
2016-03-02 07:29:19 +00:00
|
|
|
"PAKBridge provided to PAKRouter::enterPAKBridge() was not part of build()");
|
|
|
|
}
|
|
|
|
|
2016-09-19 05:29:05 +00:00
|
|
|
template <class BRIDGETYPE>
|
2016-09-19 06:08:18 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getCharacterWorking(const EntryType* entry) const
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
2016-09-19 06:08:18 +00:00
|
|
|
auto characterSearch = m_cskrCinfToCharacter.find(entry->id);
|
|
|
|
if (characterSearch != m_cskrCinfToCharacter.cend())
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
2016-09-19 06:08:18 +00:00
|
|
|
hecl::ProjectPath characterPath = getWorking(characterSearch->second.first);
|
|
|
|
if (entry->type == FOURCC('EVNT'))
|
2016-10-20 00:52:33 +00:00
|
|
|
{
|
|
|
|
hecl::SystemStringView wideStr(characterSearch->second.second);
|
|
|
|
return characterPath.getWithExtension((_S(".") + wideStr.sys_str()).c_str(), true);
|
|
|
|
}
|
2016-09-19 06:08:18 +00:00
|
|
|
return characterPath.ensureAuxInfo(characterSearch->second.second);
|
2016-09-19 05:29:05 +00:00
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getWorking(const EntryType* entry,
|
2016-03-02 07:29:19 +00:00
|
|
|
const ResExtractor<BRIDGETYPE>& extractor) const
|
|
|
|
{
|
|
|
|
if (!entry)
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath();
|
2016-10-01 23:20:20 +00:00
|
|
|
|
|
|
|
auto overrideSearch = m_overrideEntries.find(entry->id);
|
|
|
|
if (overrideSearch != m_overrideEntries.end())
|
|
|
|
return overrideSearch->second;
|
|
|
|
|
2016-04-01 04:25:00 +00:00
|
|
|
const PAKType* pak = m_pak.get();
|
|
|
|
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
2017-01-30 23:22:26 +00:00
|
|
|
if (pak && pak->m_noShare)
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const EntryType* singleSearch = pak->lookupEntry(entry->id);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (singleSearch)
|
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].first;
|
2016-03-02 07:29:19 +00:00
|
|
|
#if HECL_UCS2
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entName = hecl::UTF8ToWide(getBestEntryName(*entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
#else
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entName = getBestEntryName(*entry);
|
2016-03-02 07:29:19 +00:00
|
|
|
#endif
|
2016-09-19 05:29:05 +00:00
|
|
|
hecl::SystemString auxInfo;
|
2016-03-02 07:29:19 +00:00
|
|
|
if (extractor.fileExts[0] && !extractor.fileExts[1])
|
|
|
|
entName += extractor.fileExts[0];
|
2016-09-18 23:47:48 +00:00
|
|
|
else if (extractor.fileExts[0])
|
|
|
|
entName += _S(".*");
|
2016-09-19 06:08:18 +00:00
|
|
|
else if (hecl::ProjectPath chWork = getCharacterWorking(entry))
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
|
|
|
entName = chWork.getLastComponent();
|
|
|
|
auxInfo = chWork.getAuxInfo();
|
|
|
|
}
|
|
|
|
return hecl::ProjectPath(pakPath, entName).ensureAuxInfo(auxInfo);
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto uniqueSearch = m_uniqueEntries.find(entry->id);
|
|
|
|
if (uniqueSearch != m_uniqueEntries.end())
|
|
|
|
{
|
2016-03-09 20:44:34 +00:00
|
|
|
const BRIDGETYPE& bridge = m_bridges->at(uniqueSearch->second.first);
|
2016-03-05 00:03:41 +00:00
|
|
|
const hecl::ProjectPath& pakPath = m_bridgePaths[uniqueSearch->second.first].first;
|
2016-03-02 07:29:19 +00:00
|
|
|
#if HECL_UCS2
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entName = hecl::UTF8ToWide(getBestEntryName(*entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
#else
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entName = getBestEntryName(*entry);
|
2016-03-02 07:29:19 +00:00
|
|
|
#endif
|
2016-09-19 05:29:05 +00:00
|
|
|
hecl::SystemString auxInfo;
|
2016-03-02 07:29:19 +00:00
|
|
|
if (extractor.fileExts[0] && !extractor.fileExts[1])
|
|
|
|
entName += extractor.fileExts[0];
|
2016-09-18 23:47:48 +00:00
|
|
|
else if (extractor.fileExts[0])
|
|
|
|
entName += _S(".*");
|
2016-09-19 06:08:18 +00:00
|
|
|
else if (hecl::ProjectPath chWork = getCharacterWorking(entry))
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
|
|
|
entName = chWork.getLastComponent();
|
|
|
|
auxInfo = chWork.getAuxInfo();
|
|
|
|
}
|
2016-03-09 20:44:34 +00:00
|
|
|
if (bridge.getPAK().m_noShare)
|
|
|
|
{
|
2016-09-19 05:29:05 +00:00
|
|
|
return hecl::ProjectPath(pakPath, entName).ensureAuxInfo(auxInfo);
|
2016-03-09 20:44:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hecl::ProjectPath uniquePath = entry->unique.uniquePath(pakPath);
|
2016-09-19 05:29:05 +00:00
|
|
|
return hecl::ProjectPath(uniquePath, entName).ensureAuxInfo(auxInfo);
|
2016-03-09 20:44:34 +00:00
|
|
|
}
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto sharedSearch = m_sharedEntries.find(entry->id);
|
|
|
|
if (sharedSearch != m_sharedEntries.end())
|
|
|
|
{
|
|
|
|
#if HECL_UCS2
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entBase = hecl::UTF8ToWide(getBestEntryName(*entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
#else
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entBase = getBestEntryName(*entry);
|
2016-03-02 07:29:19 +00:00
|
|
|
#endif
|
2016-09-19 05:29:05 +00:00
|
|
|
hecl::SystemString auxInfo;
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString entName = entBase;
|
2016-03-02 07:29:19 +00:00
|
|
|
if (extractor.fileExts[0] && !extractor.fileExts[1])
|
|
|
|
entName += extractor.fileExts[0];
|
2016-09-18 23:47:48 +00:00
|
|
|
else if (extractor.fileExts[0])
|
|
|
|
entName += _S(".*");
|
2016-09-19 06:08:18 +00:00
|
|
|
else if (hecl::ProjectPath chWork = getCharacterWorking(entry))
|
2016-09-19 05:29:05 +00:00
|
|
|
{
|
|
|
|
entName = chWork.getLastComponent();
|
|
|
|
auxInfo = chWork.getAuxInfo();
|
|
|
|
}
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath sharedPath(m_sharedWorking, entName);
|
2016-09-19 05:29:05 +00:00
|
|
|
return sharedPath.ensureAuxInfo(auxInfo);
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal, "Unable to find entry %s", entry->id.toString().c_str());
|
|
|
|
return hecl::ProjectPath();
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getWorking(const EntryType* entry) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
if (!entry)
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath();
|
2016-08-31 19:58:21 +00:00
|
|
|
return getWorking(entry, BRIDGETYPE::LookupExtractor(*m_pak.get(), *entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-04-06 02:04:15 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getWorking(const IDType& id, bool silenceWarnings) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-06 02:04:15 +00:00
|
|
|
return getWorking(lookupEntry(id, nullptr, silenceWarnings, false));
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getCooked(const EntryType* entry) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
if (!entry)
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath();
|
2016-10-01 23:20:20 +00:00
|
|
|
|
|
|
|
auto overrideSearch = m_overrideEntries.find(entry->id);
|
|
|
|
if (overrideSearch != m_overrideEntries.end())
|
|
|
|
{
|
|
|
|
return overrideSearch->second.getCookedPath(
|
|
|
|
*m_dataSpec.overrideDataSpec(overrideSearch->second,
|
|
|
|
m_dataSpec.getDataSpecEntry(),
|
|
|
|
hecl::SharedBlenderToken));
|
|
|
|
}
|
|
|
|
|
2016-04-01 04:25:00 +00:00
|
|
|
const PAKType* pak = m_pak.get();
|
|
|
|
intptr_t curBridgeIdx = reinterpret_cast<intptr_t>(m_curBridgeIdx.get());
|
2017-01-30 23:22:26 +00:00
|
|
|
if (pak && pak->m_noShare)
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const EntryType* singleSearch = pak->lookupEntry(entry->id);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (singleSearch)
|
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const hecl::ProjectPath& pakPath = m_bridgePaths[curBridgeIdx].second;
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath(pakPath, getBestEntryName(*entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
auto uniqueSearch = m_uniqueEntries.find(entry->id);
|
|
|
|
if (uniqueSearch != m_uniqueEntries.end())
|
|
|
|
{
|
2016-03-09 20:44:34 +00:00
|
|
|
const BRIDGETYPE& bridge = m_bridges->at(uniqueSearch->second.first);
|
2016-03-05 00:03:41 +00:00
|
|
|
const hecl::ProjectPath& pakPath = m_bridgePaths[uniqueSearch->second.first].second;
|
2016-03-09 20:44:34 +00:00
|
|
|
if (bridge.getPAK().m_noShare)
|
|
|
|
{
|
|
|
|
return hecl::ProjectPath(pakPath, getBestEntryName(*entry));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hecl::ProjectPath uniquePath = entry->unique.uniquePath(pakPath);
|
|
|
|
return hecl::ProjectPath(uniquePath, getBestEntryName(*entry));
|
|
|
|
}
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
auto sharedSearch = m_sharedEntries.find(entry->id);
|
|
|
|
if (sharedSearch != m_sharedEntries.end())
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath(m_sharedCooked, getBestEntryName(*entry));
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal, "Unable to find entry %s", entry->id.toString().c_str());
|
|
|
|
return hecl::ProjectPath();
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-04-06 02:04:15 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getCooked(const IDType& id, bool silenceWarnings) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-06 02:04:15 +00:00
|
|
|
return getCooked(lookupEntry(id, nullptr, silenceWarnings, false));
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString PAKRouter<BRIDGETYPE>::getResourceRelativePath(const EntryType& a, const IDType& b) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const PAKType* pak = m_pak.get();
|
|
|
|
if (!pak)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
2016-03-02 07:29:19 +00:00
|
|
|
"PAKRouter::enterPAKBridge() must be called before PAKRouter::getResourceRelativePath()");
|
|
|
|
const typename BRIDGETYPE::PAKType::Entry* be = lookupEntry(b);
|
|
|
|
if (!be)
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::SystemString();
|
2016-08-31 19:58:21 +00:00
|
|
|
hecl::ProjectPath aPath = getWorking(&a, BRIDGETYPE::LookupExtractor(*pak, a));
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemString ret;
|
2016-03-02 07:29:19 +00:00
|
|
|
for (int i=0 ; i<aPath.levelCount() ; ++i)
|
|
|
|
ret += _S("../");
|
2016-08-31 19:58:21 +00:00
|
|
|
hecl::ProjectPath bPath = getWorking(be, BRIDGETYPE::LookupExtractor(*pak, *be));
|
2016-03-02 07:29:19 +00:00
|
|
|
ret += bPath.getRelativePath();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-12-25 01:36:42 +00:00
|
|
|
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const EntryType& entry, bool stdOverride) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
const typename BRIDGETYPE::PAKType& pak = bridge.getPAK();
|
2016-09-30 22:43:19 +00:00
|
|
|
|
2016-12-25 01:36:42 +00:00
|
|
|
if (stdOverride && isShared())
|
2016-09-30 22:43:19 +00:00
|
|
|
{
|
|
|
|
if (entry.type == FOURCC('MLVL'))
|
|
|
|
return "!world";
|
|
|
|
else if (entry.type == FOURCC('MREA'))
|
|
|
|
return "!area";
|
|
|
|
else if (entry.type == FOURCC('MAPA'))
|
|
|
|
return "!map";
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
bool named;
|
|
|
|
name = pak.bestEntryName(entry, named);
|
|
|
|
if (named)
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-12-25 01:36:42 +00:00
|
|
|
std::string PAKRouter<BRIDGETYPE>::getBestEntryName(const IDType& entry, bool stdOverride) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
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;
|
2016-09-30 22:43:19 +00:00
|
|
|
|
2016-12-25 01:36:42 +00:00
|
|
|
if (stdOverride && isShared())
|
2016-09-30 22:43:19 +00:00
|
|
|
{
|
|
|
|
if (e->type == FOURCC('MLVL'))
|
|
|
|
return "!world";
|
|
|
|
else if (e->type == FOURCC('MREA'))
|
|
|
|
return "!area";
|
|
|
|
else if (e->type == FOURCC('MAPA'))
|
|
|
|
return "!map";
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
bool named;
|
|
|
|
name = pak.bestEntryName(*e, named);
|
|
|
|
if (named)
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
2016-04-02 00:18:35 +00:00
|
|
|
bool PAKRouter<BRIDGETYPE>::extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::BlenderToken& btok,
|
2016-03-05 00:03:41 +00:00
|
|
|
std::function<void(const hecl::SystemChar*, float)> progress)
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
enterPAKBridge(pakBridge);
|
|
|
|
size_t count = 0;
|
|
|
|
size_t sz = m_pak->m_idMap.size();
|
|
|
|
float fsz = sz;
|
|
|
|
for (unsigned w=0 ; count<sz ; ++w)
|
|
|
|
{
|
|
|
|
for (const auto& item : m_pak->m_firstEntries)
|
|
|
|
{
|
2016-08-31 19:58:21 +00:00
|
|
|
ResExtractor<BRIDGETYPE> extractor = BRIDGETYPE::LookupExtractor(*m_pak.get(), *item);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (extractor.weight != w)
|
|
|
|
continue;
|
|
|
|
|
2016-12-25 01:36:42 +00:00
|
|
|
std::string bestName = getBestEntryName(*item, false);
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::SystemStringView bestNameView(bestName);
|
2016-03-02 07:29:19 +00:00
|
|
|
float thisFac = ++count / fsz;
|
2016-04-07 03:40:25 +00:00
|
|
|
progress(bestNameView.c_str(), thisFac);
|
2016-03-02 07:29:19 +00:00
|
|
|
|
2016-04-01 04:25:00 +00:00
|
|
|
const nod::Node* node = m_node.get();
|
|
|
|
|
2016-08-12 02:33:38 +00:00
|
|
|
hecl::ProjectPath working = getWorking(item, extractor);
|
2017-01-17 01:23:19 +00:00
|
|
|
working.makeDirChain(false);
|
2016-08-12 02:33:38 +00:00
|
|
|
hecl::ResourceLock resLk(working);
|
|
|
|
if (!resLk)
|
|
|
|
continue;
|
|
|
|
|
2017-01-17 01:23:19 +00:00
|
|
|
/* Extract to unmodified directory */
|
|
|
|
hecl::ProjectPath cooked = working.getCookedPath(m_dataSpec.getUnmodifiedSpec());
|
2016-09-18 23:47:48 +00:00
|
|
|
if (force || cooked.isNone())
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2017-01-17 01:23:19 +00:00
|
|
|
cooked.makeDirChain(false);
|
2016-04-01 04:25:00 +00:00
|
|
|
PAKEntryReadStream s = item->beginReadStream(*node);
|
2016-03-05 00:03:41 +00:00
|
|
|
FILE* fout = hecl::Fopen(cooked.getAbsolutePath().c_str(), _S("wb"));
|
2016-03-02 07:29:19 +00:00
|
|
|
fwrite(s.data(), 1, s.length(), fout);
|
|
|
|
fclose(fout);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extractor.func_a) /* Doesn't need PAKRouter access */
|
|
|
|
{
|
2016-09-25 04:03:34 +00:00
|
|
|
if (force || !extractor.IsFullyExtracted(working))
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
PAKEntryReadStream s = item->beginReadStream(*node);
|
2016-03-02 07:29:19 +00:00
|
|
|
extractor.func_a(s, working);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (extractor.func_b) /* Needs PAKRouter access */
|
|
|
|
{
|
2016-09-25 04:03:34 +00:00
|
|
|
if (force || !extractor.IsFullyExtracted(working))
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
PAKEntryReadStream s = item->beginReadStream(*node);
|
|
|
|
extractor.func_b(m_dataSpec, s, working, *this, *item, force, btok,
|
2016-03-05 00:03:41 +00:00
|
|
|
[&progress, thisFac](const hecl::SystemChar* update)
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
progress(update, thisFac);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
|
|
|
const typename BRIDGETYPE::PAKType::Entry* PAKRouter<BRIDGETYPE>::lookupEntry(const IDType& entry,
|
2016-03-05 00:03:41 +00:00
|
|
|
const nod::Node** nodeOut,
|
2016-03-02 07:29:19 +00:00
|
|
|
bool silenceWarnings,
|
|
|
|
bool currentPAK) const
|
|
|
|
{
|
|
|
|
if (!entry)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
if (!m_bridges)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
2016-03-02 07:29:19 +00:00
|
|
|
"PAKRouter::build() must be called before PAKRouter::lookupEntry()");
|
|
|
|
|
2016-04-01 04:25:00 +00:00
|
|
|
const PAKType* pak = m_pak.get();
|
|
|
|
const nod::Node* node = m_node.get();
|
|
|
|
if (pak)
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
2016-04-01 04:25:00 +00:00
|
|
|
const EntryType* ent = pak->lookupEntry(entry);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (ent)
|
|
|
|
{
|
|
|
|
if (nodeOut)
|
2016-04-01 04:25:00 +00:00
|
|
|
*nodeOut = node;
|
2016-03-02 07:29:19 +00:00
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPAK)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
#ifndef NDEBUG
|
2016-03-02 07:29:19 +00:00
|
|
|
if (!silenceWarnings)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Warning,
|
2016-03-02 07:29:19 +00:00
|
|
|
"unable to find PAK entry %s in current PAK", entry.toString().c_str());
|
2016-03-04 01:01:37 +00:00
|
|
|
#endif
|
2016-03-02 07:29:19 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
const PAKType& pak = bridge.getPAK();
|
|
|
|
const EntryType* ent = pak.lookupEntry(entry);
|
|
|
|
if (ent)
|
|
|
|
{
|
|
|
|
if (nodeOut)
|
|
|
|
*nodeOut = &bridge.getNode();
|
|
|
|
return ent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
#ifndef NDEBUG
|
2016-03-02 07:29:19 +00:00
|
|
|
if (!silenceWarnings)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Warning,
|
2016-03-02 07:29:19 +00:00
|
|
|
"unable to find PAK entry %s", entry.toString().c_str());
|
2016-03-04 01:01:37 +00:00
|
|
|
#endif
|
2016-03-02 07:29:19 +00:00
|
|
|
if (nodeOut)
|
|
|
|
*nodeOut = nullptr;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class BRIDGETYPE>
|
|
|
|
const typename PAKRouter<BRIDGETYPE>::RigPair* PAKRouter<BRIDGETYPE>::lookupCMDLRigPair(const IDType& id) const
|
|
|
|
{
|
|
|
|
auto search = m_cmdlRigs.find(id);
|
|
|
|
if (search == m_cmdlRigs.end())
|
|
|
|
return nullptr;
|
|
|
|
return &search->second;
|
|
|
|
}
|
|
|
|
|
2016-10-01 23:20:20 +00:00
|
|
|
template <class BRIDGETYPE>
|
|
|
|
const zeus::CMatrix4f* PAKRouter<BRIDGETYPE>::lookupMAPATransform(const IDType& id) const
|
|
|
|
{
|
|
|
|
auto search = m_mapaTransforms.find(id);
|
|
|
|
if (search == m_mapaTransforms.end())
|
|
|
|
return nullptr;
|
|
|
|
return &search->second;
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getAreaLayerWorking(const IDType& areaId, int layerIdx) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
if (!m_bridges)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
2016-03-02 07:29:19 +00:00
|
|
|
"PAKRouter::build() must be called before PAKRouter::getAreaLayerWorking()");
|
|
|
|
auto bridgePathIt = m_bridgePaths.cbegin();
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
for (const auto& level : bridge.m_levelDeps)
|
|
|
|
for (const auto& area : level.second.areas)
|
|
|
|
if (area.first == areaId)
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath levelPath(bridgePathIt->first, level.second.name);
|
|
|
|
hecl::ProjectPath areaPath(levelPath, area.second.name);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (layerIdx < 0)
|
|
|
|
return areaPath;
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath(areaPath, area.second.layers.at(layerIdx).name);
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
++bridgePathIt;
|
|
|
|
}
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath();
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 02:52:00 +00:00
|
|
|
template <class BRIDGETYPE>
|
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getAreaLayerWorking(const IDType& areaId, int layerIdx, bool& activeOut) const
|
|
|
|
{
|
|
|
|
activeOut = false;
|
|
|
|
if (!m_bridges)
|
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
|
|
|
"PAKRouter::build() must be called before PAKRouter::getAreaLayerWorking()");
|
|
|
|
auto bridgePathIt = m_bridgePaths.cbegin();
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
for (const auto& level : bridge.m_levelDeps)
|
|
|
|
for (const auto& area : level.second.areas)
|
|
|
|
if (area.first == areaId)
|
|
|
|
{
|
|
|
|
hecl::ProjectPath levelPath(bridgePathIt->first, level.second.name);
|
|
|
|
hecl::ProjectPath areaPath(levelPath, area.second.name);
|
|
|
|
if (layerIdx < 0)
|
|
|
|
return areaPath;
|
|
|
|
const typename Level<IDType>::Area::Layer& layer = area.second.layers.at(layerIdx);
|
|
|
|
activeOut = layer.active;
|
|
|
|
return hecl::ProjectPath(areaPath, layer.name);
|
|
|
|
}
|
|
|
|
++bridgePathIt;
|
|
|
|
}
|
|
|
|
return hecl::ProjectPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
template <class BRIDGETYPE>
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getAreaLayerCooked(const IDType& areaId, int layerIdx) const
|
2016-03-02 07:29:19 +00:00
|
|
|
{
|
|
|
|
if (!m_bridges)
|
2016-03-05 00:03:41 +00:00
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
2016-03-02 07:29:19 +00:00
|
|
|
"PAKRouter::build() must be called before PAKRouter::getAreaLayerCooked()");
|
|
|
|
auto bridgePathIt = m_bridgePaths.cbegin();
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
for (const auto& level : bridge.m_levelDeps)
|
|
|
|
for (const auto& area : level.second.areas)
|
|
|
|
if (area.first == areaId)
|
|
|
|
{
|
2016-03-05 00:03:41 +00:00
|
|
|
hecl::ProjectPath levelPath(bridgePathIt->second, level.second.name);
|
|
|
|
hecl::ProjectPath areaPath(levelPath, area.second.name);
|
2016-03-02 07:29:19 +00:00
|
|
|
if (layerIdx < 0)
|
|
|
|
return areaPath;
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath(areaPath, area.second.layers.at(layerIdx).name);
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
++bridgePathIt;
|
|
|
|
}
|
2016-03-05 00:03:41 +00:00
|
|
|
return hecl::ProjectPath();
|
2016-03-02 07:29:19 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 02:52:00 +00:00
|
|
|
template <class BRIDGETYPE>
|
|
|
|
hecl::ProjectPath PAKRouter<BRIDGETYPE>::getAreaLayerCooked(const IDType& areaId, int layerIdx, bool& activeOut) const
|
|
|
|
{
|
|
|
|
activeOut = false;
|
|
|
|
if (!m_bridges)
|
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
|
|
|
"PAKRouter::build() must be called before PAKRouter::getAreaLayerCooked()");
|
|
|
|
auto bridgePathIt = m_bridgePaths.cbegin();
|
|
|
|
for (const BRIDGETYPE& bridge : *m_bridges)
|
|
|
|
{
|
|
|
|
for (const auto& level : bridge.m_levelDeps)
|
|
|
|
for (const auto& area : level.second.areas)
|
|
|
|
if (area.first == areaId)
|
|
|
|
{
|
|
|
|
hecl::ProjectPath levelPath(bridgePathIt->second, level.second.name);
|
|
|
|
hecl::ProjectPath areaPath(levelPath, area.second.name);
|
|
|
|
if (layerIdx < 0)
|
|
|
|
return areaPath;
|
|
|
|
const typename Level<IDType>::Area::Layer& layer = area.second.layers.at(layerIdx);
|
|
|
|
activeOut = layer.active;
|
|
|
|
return hecl::ProjectPath(areaPath, layer.name);
|
|
|
|
}
|
|
|
|
++bridgePathIt;
|
|
|
|
}
|
|
|
|
return hecl::ProjectPath();
|
|
|
|
}
|
|
|
|
|
2017-01-30 23:22:26 +00:00
|
|
|
template <class BRIDGETYPE>
|
|
|
|
void PAKRouter<BRIDGETYPE>::enumerateResources(const std::function<bool(const EntryType*)>& func)
|
|
|
|
{
|
|
|
|
if (!m_bridges)
|
|
|
|
LogDNACommon.report(logvisor::Fatal,
|
|
|
|
"PAKRouter::build() must be called before PAKRouter::enumerateResources()");
|
|
|
|
for (const auto& entryPair : m_uniqueEntries)
|
|
|
|
if (!func(entryPair.second.second))
|
|
|
|
return;
|
2017-01-30 23:26:58 +00:00
|
|
|
for (const auto& entryPair : m_sharedEntries)
|
|
|
|
if (!func(entryPair.second.second))
|
|
|
|
return;
|
2017-01-30 23:22:26 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 07:29:19 +00:00
|
|
|
template class PAKRouter<DNAMP1::PAKBridge>;
|
|
|
|
template class PAKRouter<DNAMP2::PAKBridge>;
|
|
|
|
template class PAKRouter<DNAMP3::PAKBridge>;
|
|
|
|
|
|
|
|
}
|