Added basic support for tracking DUMB dependencies

This commit is contained in:
parax0
2016-12-03 14:32:41 -07:00
parent f6fd78af14
commit efa85036c2
7 changed files with 90 additions and 15 deletions

View File

@@ -313,7 +313,7 @@ CResourceEntry* CResourceStore::FindEntry(const TWideString& rkPath) const
bool CResourceStore::IsResourceRegistered(const CAssetID& rkID) const
{
return FindEntry(rkID) == nullptr;
return FindEntry(rkID) != nullptr;
}
CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType Type, const TWideString& rkDir, const TWideString& rkFileName)

View File

@@ -26,6 +26,12 @@ bool CCharacterUsageMap::IsAnimationUsed(const CAssetID& rkID, CSetAnimationDepe
return false;
}
void CCharacterUsageMap::FindUsagesForAsset(CResourceEntry *pEntry)
{
Clear();
ParseDependencyNode(pEntry->Dependencies());
}
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry)
{
ASSERT(pEntry->ResourceType() == eArea);
@@ -43,10 +49,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
{
// We only need to search forward from this area to other areas that both use the same character(s) + have duplicates enabled
mUsageMap.clear();
mStillLookingIDs.clear();
mLayerIndex = -1;
mIsInitialArea = true;
Clear();
for (u32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++)
{
@@ -64,10 +67,8 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex)
{
mUsageMap.clear();
mStillLookingIDs.clear();
Clear();
mLayerIndex = LayerIndex;
mIsInitialArea = true;
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(pAreaEntry->Dependencies());
ASSERT(pTree->Type() == eDNT_Area);
@@ -81,6 +82,14 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 Laye
ParseDependencyNode(pTree->ChildByIndex(iInst));
}
void CCharacterUsageMap::Clear()
{
mUsageMap.clear();
mStillLookingIDs.clear();
mLayerIndex = -1;
mIsInitialArea = true;
}
#include "Core/Resource/Animation/CAnimSet.h"
void CCharacterUsageMap::DebugPrintContents()
@@ -178,7 +187,7 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkRes.ID);
if (!pEntry) continue;
if (rkRes.Name.EndsWith("NODEPEND"))
if (rkRes.Name.EndsWith("NODEPEND") || rkRes.Type == "CSNG")
{
rOut.push_back(rkRes.ID);
continue;
@@ -186,13 +195,15 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
if (rkRes.Type == "MLVL")
{
CResourceEntry *pWorldEntry = gpResourceStore->FindEntry(rkRes.ID);
ASSERT(pWorldEntry);
mpWorld = (CWorld*) pWorldEntry->Load();
mpWorld = (CWorld*) pEntry->Load();
ASSERT(mpWorld);
}
else
mCharacterUsageMap.FindUsagesForAsset(pEntry);
AddDependency(nullptr, rkRes.ID, rOut);
mpWorld = nullptr;
}
}
}

View File

@@ -20,9 +20,11 @@ public:
CCharacterUsageMap() : mLayerIndex(-1), mIsInitialArea(true), mCurrentAreaAllowsDupes(false) {}
bool IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const;
bool IsAnimationUsed(const CAssetID& rkID, CSetAnimationDependency *pAnim) const;
void FindUsagesForAsset(CResourceEntry *pEntry);
void FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry);
void FindUsagesForArea(CWorld *pWorld, u32 AreaIndex);
void FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex);
void Clear();
void DebugPrintContents();
protected: