diff --git a/DataSpec/SpecBase.cpp b/DataSpec/SpecBase.cpp index 8316d111e..d0c4cf8d2 100644 --- a/DataSpec/SpecBase.cpp +++ b/DataSpec/SpecBase.cpp @@ -792,6 +792,11 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da pakOut.close(); } +void SpecBase::interruptCook() +{ + cancelBackgroundIndex(); +} + hecl::ProjectPath SpecBase::getCookedPath(const hecl::ProjectPath& working, bool pcTarget) const { const hecl::Database::DataSpecEntry* spec = &getOriginalSpec(); @@ -1269,6 +1274,10 @@ void SpecBase::backgroundIndexRecursiveProc(const hecl::ProjectPath& dir, /* Enumerate all items */ for (const hecl::DirectoryEnumerator::Entry& ent : dEnum) { + /* bail if cancelled by client */ + if (!m_backgroundRunning) + break; + hecl::ProjectPath path(dir, ent.m_name); if (ent.m_isDir) backgroundIndexRecursiveProc(path, cacheWriter, nameWriter, level + 1); @@ -1287,10 +1296,6 @@ void SpecBase::backgroundIndexRecursiveProc(const hecl::ProjectPath& dir, /* Index the regular file */ addFileToIndex(path, cacheWriter); } - - /* bail if cancelled by client */ - if (!m_backgroundRunning) - break; } } @@ -1323,6 +1328,9 @@ void SpecBase::backgroundIndexProc() size_t loadIdx = 0; for (const auto& child : cacheReader.getRootNode()->m_mapChildren) { + if (!m_backgroundRunning) + return; + const athena::io::YAMLNode& node = *child.second; unsigned long id = strtoul(child.first.c_str(), nullptr, 16); hecl::FourCC type(node.m_seqChildren.at(0)->m_scalarString.c_str()); diff --git a/DataSpec/SpecBase.hpp b/DataSpec/SpecBase.hpp index b0e304b0b..fb26a5a31 100644 --- a/DataSpec/SpecBase.hpp +++ b/DataSpec/SpecBase.hpp @@ -53,6 +53,8 @@ struct SpecBase : hecl::Database::IDataSpec bool fast, hecl::blender::Token& btok, const hecl::MultiProgressPrinter& progress, hecl::ClientProcess* cp); + void interruptCook(); + /* Extract handlers */ virtual bool checkStandaloneID(const char* id) const=0; virtual bool checkFromStandaloneDisc(nod::DiscBase& disc, diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 40fc7153f..69128f326 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -1313,7 +1313,7 @@ struct SpecMP1 : SpecBase auto layerIt = area.depLayers.cbegin(); while (it != area.deps.cend()) { - if (layerIt != area.depLayers.cend() && it - area.deps.cbegin() == *layerIt) + while (layerIt != area.depLayers.cend() && it - area.deps.cbegin() == *layerIt) { strippedDepLayers.push_back(atUint32(strippedDeps.size())); ++layerIt; diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 30ac73f0e..455d72626 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -363,6 +363,7 @@ void CGameGlobalObjects::AddPaksAndFactories() fmgr->AddFactory(FOURCC('MAPA'), FFactoryFunc(FMapAreaFactory)); fmgr->AddFactory(FOURCC('MAPU'), FFactoryFunc(FMapUniverseFactory)); fmgr->AddFactory(FOURCC('AFSM'), FFactoryFunc(FAiFiniteStateMachineFactory)); + fmgr->AddFactory(FOURCC('PATH'), FMemFactoryFunc(FPathFindAreaFactory)); } } diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 937501d9c..ca72252b9 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -1313,22 +1313,19 @@ void CGameArea::VerifyTokenList(CStateManager& stateMgr) if (xac_deps2.empty()) return; - u32 lastOff = 0; - int lidx = 0; - for (u32 off : xbc_layerDepOffsets) + auto end = xac_deps2.end(); + for (int lidx = int(xbc_layerDepOffsets.size() - 1) ; lidx >= 0 ; --lidx) { + auto begin = xac_deps2.begin() + xbc_layerDepOffsets[lidx]; if (stateMgr.LayerState()->IsLayerActive(x4_selfIdx, lidx)) { - auto it = xac_deps2.begin() + lastOff; - auto end = xac_deps2.begin() + off; - for (; it != end ; ++it) + for (auto it = begin ; it != end ; ++it) { xdc_tokens.push_back(g_SimplePool->GetObj(*it)); xdc_tokens.back().Lock(); } } - lastOff = off; - ++lidx; + end = begin; } } diff --git a/Runtime/World/CPathFindArea.cpp b/Runtime/World/CPathFindArea.cpp index 9d071d011..4d82ef78b 100644 --- a/Runtime/World/CPathFindArea.cpp +++ b/Runtime/World/CPathFindArea.cpp @@ -5,6 +5,8 @@ namespace urde { +static logvisor::Module Log("CPathFindArea"); + CPFAreaOctree::CPFAreaOctree(CMemoryInStream& in) { x0_isLeaf = in.readUint32Big(); @@ -137,6 +139,10 @@ CPFArea::CPFArea(std::unique_ptr&& buf, u32 len) { CMemoryInStream r(buf.get(), len); + u32 version = r.readUint32Big(); + if (version != 4) + Log.report(logvisor::Fatal, "Unexpected PATH version %d, should be 4", version); + u32 numNodes = r.readUint32Big(); x140_nodes.reserve(numNodes); for (u32 i=0 ; i