CDependencyTree: Make use of size_t where applicable
This commit is contained in:
parent
13f0ca07ef
commit
9ed81480cc
|
@ -46,8 +46,8 @@ public:
|
||||||
static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type);
|
static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
uint32 NumChildren() const { return mChildren.size(); }
|
size_t NumChildren() const { return mChildren.size(); }
|
||||||
IDependencyNode* ChildByIndex(uint32 Index) const { return mChildren[Index].get(); }
|
IDependencyNode* ChildByIndex(size_t Index) const { return mChildren[Index].get(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic dependency tree; this class is sufficient for most resource types.
|
// Basic dependency tree; this class is sufficient for most resource types.
|
||||||
|
@ -130,14 +130,14 @@ public:
|
||||||
class CScriptInstanceDependency : public IDependencyNode
|
class CScriptInstanceDependency : public IDependencyNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
uint mObjectType = 0;
|
uint32 mObjectType = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EDependencyNodeType Type() const override;
|
EDependencyNodeType Type() const override;
|
||||||
void Serialize(IArchive& rArc) override;
|
void Serialize(IArchive& rArc) override;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
uint ObjectType() const { return mObjectType; }
|
uint32 ObjectType() const { return mObjectType; }
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static std::unique_ptr<CScriptInstanceDependency> BuildTree(CScriptObject *pInstance);
|
static std::unique_ptr<CScriptInstanceDependency> BuildTree(CScriptObject *pInstance);
|
||||||
|
@ -151,7 +151,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSetCharacterDependency() = default;
|
CSetCharacterDependency() = default;
|
||||||
CSetCharacterDependency(uint32 SetIndex) : mCharSetIndex(SetIndex) {}
|
explicit CSetCharacterDependency(uint32 SetIndex) : mCharSetIndex(SetIndex) {}
|
||||||
|
|
||||||
EDependencyNodeType Type() const override;
|
EDependencyNodeType Type() const override;
|
||||||
void Serialize(IArchive& rArc) override;
|
void Serialize(IArchive& rArc) override;
|
||||||
|
@ -217,8 +217,8 @@ public:
|
||||||
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const;
|
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
uint32 NumScriptLayers() const { return mLayerOffsets.size(); }
|
size_t NumScriptLayers() const { return mLayerOffsets.size(); }
|
||||||
uint32 ScriptLayerOffset(uint32 LayerIdx) const { return mLayerOffsets[LayerIdx]; }
|
uint32 ScriptLayerOffset(size_t LayerIdx) const { return mLayerOffsets[LayerIdx]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CDEPENDENCYTREE
|
#endif // CDEPENDENCYTREE
|
||||||
|
|
|
@ -85,10 +85,10 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 L
|
||||||
|
|
||||||
// Only examine dependencies of the particular layer specified by the caller
|
// Only examine dependencies of the particular layer specified by the caller
|
||||||
const bool IsLastLayer = mLayerIndex == pTree->NumScriptLayers() - 1;
|
const bool IsLastLayer = mLayerIndex == pTree->NumScriptLayers() - 1;
|
||||||
const uint32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
|
const size_t StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
|
||||||
const uint32 EndIdx = IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1);
|
const size_t EndIdx = IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1);
|
||||||
|
|
||||||
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
for (size_t iInst = StartIdx; iInst < EndIdx; iInst++)
|
||||||
ParseDependencyNode(pTree->ChildByIndex(iInst));
|
ParseDependencyNode(pTree->ChildByIndex(iInst));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +165,14 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||||
auto* pDep = static_cast<CResourceDependency*>(pNode);
|
auto* pDep = static_cast<CResourceDependency*>(pNode);
|
||||||
CResourceEntry* pEntry = mpStore->FindEntry(pDep->ID());
|
CResourceEntry* pEntry = mpStore->FindEntry(pDep->ID());
|
||||||
|
|
||||||
if (pEntry && pEntry->ResourceType() == EResourceType::Scan)
|
if (pEntry != nullptr && pEntry->ResourceType() == EResourceType::Scan)
|
||||||
{
|
{
|
||||||
ParseDependencyNode(pEntry->Dependencies());
|
ParseDependencyNode(pEntry->Dependencies());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Look for sub-dependencies of the current node
|
else // Look for sub-dependencies of the current node
|
||||||
{
|
{
|
||||||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (size_t iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
ParseDependencyNode(pNode->ChildByIndex(iChild));
|
ParseDependencyNode(pNode->ChildByIndex(iChild));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||||
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (size_t iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
||||||
|
|
||||||
if (Type == EDependencyNodeType::ScriptInstance)
|
if (Type == EDependencyNodeType::ScriptInstance)
|
||||||
|
@ -400,38 +400,38 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(mpAreaEntry->Dependencies());
|
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(mpAreaEntry->Dependencies());
|
||||||
|
|
||||||
// Fill area base used assets set (don't actually add to list yet)
|
// Fill area base used assets set (don't actually add to list yet)
|
||||||
uint32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren());
|
const size_t BaseEndIndex = pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren();
|
||||||
|
|
||||||
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
for (size_t iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||||
{
|
{
|
||||||
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
const auto* pRes = static_cast<const CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||||
ASSERT(pRes->Type() == EDependencyNodeType::Resource);
|
ASSERT(pRes->Type() == EDependencyNodeType::Resource);
|
||||||
mBaseUsedAssets.insert(pRes->ID());
|
mBaseUsedAssets.insert(pRes->ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get dependencies of each layer
|
// Get dependencies of each layer
|
||||||
for (uint32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
|
for (size_t iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
|
||||||
{
|
{
|
||||||
mLayerUsedAssets.clear();
|
mLayerUsedAssets.clear();
|
||||||
mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr);
|
mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr);
|
||||||
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
||||||
|
|
||||||
bool IsLastLayer = (iLyr == pTree->NumScriptLayers() - 1);
|
const bool IsLastLayer = iLyr == pTree->NumScriptLayers() - 1;
|
||||||
uint32 StartIdx = pTree->ScriptLayerOffset(iLyr);
|
const size_t StartIdx = pTree->ScriptLayerOffset(iLyr);
|
||||||
uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1));
|
const size_t EndIdx = IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1);
|
||||||
|
|
||||||
for (uint32 iChild = StartIdx; iChild < EndIdx; iChild++)
|
for (size_t iChild = StartIdx; iChild < EndIdx; iChild++)
|
||||||
{
|
{
|
||||||
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
const IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
||||||
|
|
||||||
if (pNode->Type() == EDependencyNodeType::ScriptInstance)
|
if (pNode->Type() == EDependencyNodeType::ScriptInstance)
|
||||||
{
|
{
|
||||||
auto* pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
const auto* pInst = static_cast<const CScriptInstanceDependency*>(pNode);
|
||||||
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
||||||
|
|
||||||
for (uint32 iDep = 0; iDep < pInst->NumChildren(); iDep++)
|
for (size_t iDep = 0; iDep < pInst->NumChildren(); iDep++)
|
||||||
{
|
{
|
||||||
auto* pDep = static_cast<CPropertyDependency*>(pInst->ChildByIndex(iDep));
|
const auto* pDep = static_cast<const CPropertyDependency*>(pInst->ChildByIndex(iDep));
|
||||||
|
|
||||||
// For MP3, exclude the CMDL/CSKR properties for the suit assets - only include default character assets
|
// For MP3, exclude the CMDL/CSKR properties for the suit assets - only include default character assets
|
||||||
if (mGame == EGame::Corruption && mIsPlayerActor)
|
if (mGame == EGame::Corruption && mIsPlayerActor)
|
||||||
|
@ -456,7 +456,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
}
|
}
|
||||||
else if (pNode->Type() == EDependencyNodeType::Resource)
|
else if (pNode->Type() == EDependencyNodeType::Resource)
|
||||||
{
|
{
|
||||||
CResourceDependency *pResDep = static_cast<CResourceDependency*>(pNode);
|
const auto* pResDep = static_cast<const CResourceDependency*>(pNode);
|
||||||
AddDependency(pResDep->ID(), rAssetsOut, pAudioGroupsOut);
|
AddDependency(pResDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -471,9 +471,9 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
mLayerUsedAssets.clear();
|
mLayerUsedAssets.clear();
|
||||||
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
||||||
|
|
||||||
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
for (size_t iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||||
{
|
{
|
||||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
const auto* pDep = static_cast<const CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||||
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,12 +541,12 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
|
|
||||||
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
if (Type == EDependencyNodeType::Resource || Type == EDependencyNodeType::ScriptProperty || Type == EDependencyNodeType::CharacterProperty)
|
||||||
{
|
{
|
||||||
const auto* pDep = static_cast<CResourceDependency*>(pNode);
|
const auto* pDep = static_cast<const CResourceDependency*>(pNode);
|
||||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||||
}
|
}
|
||||||
else if (Type == EDependencyNodeType::AnimEvent)
|
else if (Type == EDependencyNodeType::AnimEvent)
|
||||||
{
|
{
|
||||||
const auto* pDep = static_cast<CAnimEventDependency*>(pNode);
|
const auto* pDep = static_cast<const CAnimEventDependency*>(pNode);
|
||||||
const uint32 CharIndex = pDep->CharIndex();
|
const uint32 CharIndex = pDep->CharIndex();
|
||||||
|
|
||||||
if (CharIndex == UINT32_MAX || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
if (CharIndex == UINT32_MAX || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
||||||
|
@ -557,7 +557,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
||||||
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
||||||
|
|
||||||
const auto *pChar = static_cast<CSetCharacterDependency*>(pNode);
|
const auto *pChar = static_cast<const CSetCharacterDependency*>(pNode);
|
||||||
const uint32 SetIndex = pChar->CharSetIndex();
|
const uint32 SetIndex = pChar->CharSetIndex();
|
||||||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
||||||
}
|
}
|
||||||
|
@ -573,7 +573,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
|
|
||||||
if (ParseChildren)
|
if (ParseChildren)
|
||||||
{
|
{
|
||||||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (size_t iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut);
|
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -653,7 +653,7 @@ void CAssetDependencyListBuilder::EvaluateDependencyNode(CResourceEntry* pCurEnt
|
||||||
|
|
||||||
if (ParseChildren)
|
if (ParseChildren)
|
||||||
{
|
{
|
||||||
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (size_t iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), Out);
|
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), Out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue