diff --git a/DataSpec/DNACommon/DNACommon.cpp b/DataSpec/DNACommon/DNACommon.cpp index df01e6037..af8639f9e 100644 --- a/DataSpec/DNACommon/DNACommon.cpp +++ b/DataSpec/DNACommon/DNACommon.cpp @@ -8,6 +8,7 @@ namespace DataSpec logvisor::Module LogDNACommon("urde::DNACommon"); ThreadLocalPtr g_curSpec; ThreadLocalPtr g_PakRouter; +ThreadLocalPtr g_ThreadBlenderToken; ThreadLocalPtr UniqueIDBridge::s_Project; UniqueID32 UniqueID32::kInvalidId; @@ -29,7 +30,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si { if (pakRouter) { - if (!silenceWarnings) + if (!silenceWarnings && id) LogDNACommon.report(logvisor::Warning, "unable to translate %s to path", id.toString().c_str()); return {}; @@ -42,7 +43,7 @@ hecl::ProjectPath UniqueIDBridge::TranslatePakIdToPath(const IDType& id, bool si const hecl::ProjectPath* search = project->lookupBridgePath(id.toUint64()); if (!search) { - if (!silenceWarnings) + if (!silenceWarnings && id) LogDNACommon.report(logvisor::Warning, "unable to translate %s to path", id.toString().c_str()); return {}; diff --git a/DataSpec/DNACommon/DNACommon.hpp b/DataSpec/DNACommon/DNACommon.hpp index 56ce54ee9..2cda9db94 100644 --- a/DataSpec/DNACommon/DNACommon.hpp +++ b/DataSpec/DNACommon/DNACommon.hpp @@ -18,6 +18,7 @@ namespace DataSpec extern logvisor::Module LogDNACommon; extern ThreadLocalPtr g_curSpec; extern ThreadLocalPtr g_PakRouter; +extern ThreadLocalPtr g_ThreadBlenderToken; /* This comes up a great deal */ typedef athena::io::DNA BigDNA; diff --git a/DataSpec/DNACommon/PAK.cpp b/DataSpec/DNACommon/PAK.cpp index d9ef9c0ec..e13052807 100644 --- a/DataSpec/DNACommon/PAK.cpp +++ b/DataSpec/DNACommon/PAK.cpp @@ -473,14 +473,14 @@ hecl::SystemString PAKRouter::getResourceRelativePath(const EntryTyp } template -std::string PAKRouter::getBestEntryName(const EntryType& entry) const +std::string PAKRouter::getBestEntryName(const EntryType& entry, bool stdOverride) const { std::string name; for (const BRIDGETYPE& bridge : *m_bridges) { const typename BRIDGETYPE::PAKType& pak = bridge.getPAK(); - if (isShared()) + if (stdOverride && isShared()) { if (entry.type == FOURCC('MLVL')) return "!world"; @@ -499,7 +499,7 @@ std::string PAKRouter::getBestEntryName(const EntryType& entry) cons } template -std::string PAKRouter::getBestEntryName(const IDType& entry) const +std::string PAKRouter::getBestEntryName(const IDType& entry, bool stdOverride) const { std::string name; for (const BRIDGETYPE& bridge : *m_bridges) @@ -509,7 +509,7 @@ std::string PAKRouter::getBestEntryName(const IDType& entry) const if (!e) continue; - if (isShared()) + if (stdOverride && isShared()) { if (e->type == FOURCC('MLVL')) return "!world"; @@ -543,7 +543,7 @@ bool PAKRouter::extractResources(const BRIDGETYPE& pakBridge, bool f if (extractor.weight != w) continue; - std::string bestName = getBestEntryName(*item); + std::string bestName = getBestEntryName(*item, false); hecl::SystemStringView bestNameView(bestName); float thisFac = ++count / fsz; progress(bestNameView.c_str(), thisFac); diff --git a/DataSpec/DNACommon/PAK.hpp b/DataSpec/DNACommon/PAK.hpp index 2e29adcae..18db4abaa 100644 --- a/DataSpec/DNACommon/PAK.hpp +++ b/DataSpec/DNACommon/PAK.hpp @@ -200,8 +200,8 @@ public: hecl::SystemString getResourceRelativePath(const EntryType& a, const IDType& b) const; - std::string getBestEntryName(const EntryType& entry) const; - std::string getBestEntryName(const IDType& entry) const; + std::string getBestEntryName(const EntryType& entry, bool stdOverride=true) const; + std::string getBestEntryName(const IDType& entry, bool stdOverride=true) const; bool extractResources(const BRIDGETYPE& pakBridge, bool force, hecl::BlenderToken& btok, std::function progress); diff --git a/DataSpec/DNAMP1/MLVL.cpp b/DataSpec/DNAMP1/MLVL.cpp index 737c81458..07b588562 100644 --- a/DataSpec/DNAMP1/MLVL.cpp +++ b/DataSpec/DNAMP1/MLVL.cpp @@ -40,7 +40,8 @@ bool MLVL::Extract(const SpecBase& dataSpec, entry, force, fileChanged); } -bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, const World& wld) +bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, + const World& wld, hecl::BlenderToken& btok) { MLVL mlvl = {}; athena::io::FileReader reader(inPath.getWithExtension(_S(".yaml"), true).getAbsolutePath()); @@ -120,7 +121,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* Area map */ hecl::ProjectPath mapPath(area.path, _S("/!map.blend")); if (mapPath.isFile()) - mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, hecl::SharedBlenderToken)); + mapaTags.push_back(g_curSpec->BuildTagFromPath(mapPath, btok)); /* Populate area record */ mlvl.areas.emplace_back(); @@ -200,6 +201,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* Gather memory relays, scans, and dependencies */ { + g_ThreadBlenderToken.reset(&btok); std::vector depPaths; std::vector scans; for (std::unique_ptr& obj : layer.objects) @@ -221,9 +223,9 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat else if (obj->type == 0x3A) { SpecialFunction& specialFunc = static_cast(*obj); - if (specialFunc.type == ESpecialFunctionType::CinematicSkip) + if (specialFunc.function == ESpecialFunctionType::CinematicSkip) savw.skippableCutscenes.push_back(specialFunc.id); - else if (specialFunc.type == ESpecialFunctionType::ScriptLayerController) + else if (specialFunc.function == ESpecialFunctionType::ScriptLayerController) { savw.layers.emplace_back(); SAVWCommon::Layer& layer = savw.layers.back(); @@ -248,7 +250,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat if (addedPaths.find(path.hash()) == addedPaths.cend()) { addedPaths.insert(path.hash()); - urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, hecl::SharedBlenderToken); + urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok); areaOut.deps.emplace_back(tag.id, tag.type); } } @@ -300,12 +302,12 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat if (addedPaths.find(path.hash()) == addedPaths.cend()) { addedPaths.insert(path.hash()); - urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, hecl::SharedBlenderToken); + urde::SObjectTag tag = g_curSpec->BuildTagFromPath(path, btok); areaOut.deps.emplace_back(tag.id, tag.type); } } - urde::SObjectTag tag = g_curSpec->BuildTagFromPath(areaPath, hecl::SharedBlenderToken); + urde::SObjectTag tag = g_curSpec->BuildTagFromPath(areaPath, btok); areaOut.deps.emplace_back(tag.id, tag.type); } @@ -330,7 +332,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat /* Write out MAPW */ { hecl::ProjectPath mapwCooked = - mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, hecl::SharedBlenderToken)); + mapwPath.getCookedPath(*g_curSpec->overrideDataSpec(mapwPath, nullptr, btok)); mapwCooked.makeDirChain(false); athena::io::FileWriter fo(mapwCooked.getAbsolutePath()); fo.writeUint32Big(0xDEADF00D); @@ -350,7 +352,7 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat savw.scanCount = savw.scans.size(); hecl::ProjectPath savwCooked = - savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, hecl::SharedBlenderToken)); + savwPath.getCookedPath(*g_curSpec->overrideDataSpec(savwPath, nullptr, btok)); savwCooked.makeDirChain(false); athena::io::FileWriter fo(savwCooked.getAbsolutePath()); savw.write(fo); diff --git a/DataSpec/DNAMP1/MLVL.hpp b/DataSpec/DNAMP1/MLVL.hpp index c06b114f4..216fd901c 100644 --- a/DataSpec/DNAMP1/MLVL.hpp +++ b/DataSpec/DNAMP1/MLVL.hpp @@ -153,7 +153,8 @@ struct MLVL : BigYAML static bool Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath, - const World& wld); + const World& wld, + hecl::BlenderToken& btok); }; } diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index 45478707a..f82aa2ed4 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -84,7 +84,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "from mathutils import Vector\n" "\n" "bpy.context.scene.name = '%s'\n", - pakRouter.getBestEntryName(entry).c_str()); + pakRouter.getBestEntryName(entry, false).c_str()); DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" diff --git a/DataSpec/DNAMP1/ScriptObjects/SpecialFunction.hpp b/DataSpec/DNAMP1/ScriptObjects/SpecialFunction.hpp index 5d9567348..33de89b1d 100644 --- a/DataSpec/DNAMP1/ScriptObjects/SpecialFunction.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/SpecialFunction.hpp @@ -15,7 +15,7 @@ struct SpecialFunction : IScriptObject String<-1> name; Value location; Value orientation; - Value type; + Value function; String<-1> unknown1; Value unknown2; Value unknown3; diff --git a/DataSpec/DNAMP2/MREA.cpp b/DataSpec/DNAMP2/MREA.cpp index 45e01bfa2..62fea319f 100644 --- a/DataSpec/DNAMP2/MREA.cpp +++ b/DataSpec/DNAMP2/MREA.cpp @@ -214,7 +214,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "from mathutils import Vector\n" "\n" "bpy.context.scene.name = '%s'\n", - pakRouter.getBestEntryName(entry).c_str()); + pakRouter.getBestEntryName(entry, false).c_str()); DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" diff --git a/DataSpec/DNAMP3/MREA.cpp b/DataSpec/DNAMP3/MREA.cpp index 1a12aa7d9..f7ca252c3 100644 --- a/DataSpec/DNAMP3/MREA.cpp +++ b/DataSpec/DNAMP3/MREA.cpp @@ -113,7 +113,7 @@ bool MREA::Extract(const SpecBase& dataSpec, "from mathutils import Vector\n" "\n" "bpy.context.scene.name = '%s'\n", - pakRouter.getBestEntryName(entry).c_str()); + pakRouter.getBestEntryName(entry, false).c_str()); DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath(), true); MaterialSet::RegisterMaterialProps(os); os << "# Clear Scene\n" diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index d752980cb..11a015519 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -224,6 +224,7 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath, bool fast, hecl::BlenderToken& btok, FCookProgress progress) { + cookedPath.makeDirChain(false); DataSpec::g_curSpec.reset(this); hecl::ProjectPath asBlend; @@ -364,14 +365,14 @@ void SpecBase::flattenDependencies(const UniqueID32& id, std::vector& pathsOut) { hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(id); if (path) - flattenDependencies(path, pathsOut, hecl::SharedBlenderToken); + flattenDependencies(path, pathsOut, *g_ThreadBlenderToken.get()); } bool SpecBase::canPackage(const PackagePassInfo& info) diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index ee560d78d..477ce1082 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -601,7 +601,8 @@ struct SpecMP1 : SpecBase FCookProgress progress) { BlendStream::World world = ds.compileWorld(); - DNAMP1::MLVL::Cook(out, in, world); + ds.close(); + DNAMP1::MLVL::Cook(out, in, world, btok); } void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, diff --git a/hecl b/hecl index c75c8c0a2..2beeb0cec 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit c75c8c0a28c8bbe994c56047371414e5b8f394af +Subproject commit 2beeb0cec6bf4b02e8eb494a778682d571dc7c32