Added basic support for tracking DUMB dependencies
This commit is contained in:
parent
f6fd78af14
commit
efa85036c2
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
case eArea: pRes = CAreaLoader::LoadMREA(rInput, pEntry); break;
|
||||
case eAudioGroup: pRes = CAudioGroupLoader::LoadAGSC(rInput, pEntry); break;
|
||||
case eAudioLookupTable: pRes = CAudioGroupLoader::LoadATBL(rInput, pEntry); break;
|
||||
case eBinaryData: pRes = CUnsupportedFormatLoader::LoadDUMB(rInput, pEntry); break;
|
||||
case eDependencyGroup: pRes = CDependencyGroupLoader::LoadDGRP(rInput, pEntry); break;
|
||||
case eDynamicCollision: pRes = CCollisionLoader::LoadDCLN(rInput, pEntry); break;
|
||||
case eFont: pRes = CFontLoader::LoadFONT(rInput, pEntry); break;
|
||||
|
|
|
@ -13,6 +13,48 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadCSNG(IInputStream& rCSNG, CResou
|
|||
return pGroup;
|
||||
}
|
||||
|
||||
CDependencyGroup* CUnsupportedFormatLoader::LoadDUMB(IInputStream& rDUMB, CResourceEntry *pEntry)
|
||||
{
|
||||
// Check for HIER, which needs special handling
|
||||
if (CFourCC(rDUMB.PeekLong()) == "HIER")
|
||||
return LoadHIER(rDUMB, pEntry);
|
||||
|
||||
// Load other DUMB file. DUMB files don't have a set format - they're different between different files
|
||||
std::vector<u8> Data(rDUMB.Size());
|
||||
rDUMB.ReadBytes(Data.data(), Data.size());
|
||||
|
||||
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
|
||||
u32 MaxIndex = (pEntry->Game() <= eEchoes ? Data.size() - 3 : Data.size() - 7);
|
||||
CAssetID ID;
|
||||
|
||||
for (u32 iByte = 0; iByte < MaxIndex; iByte++)
|
||||
{
|
||||
if (pEntry->Game() <= eEchoes)
|
||||
{
|
||||
ID = ( (Data[iByte+0] << 24) |
|
||||
(Data[iByte+1] << 16) |
|
||||
(Data[iByte+2] << 8) |
|
||||
(Data[iByte+3] << 0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ID = ( ((u64) Data[iByte+0] << 56) |
|
||||
((u64) Data[iByte+1] << 48) |
|
||||
((u64) Data[iByte+2] << 40) |
|
||||
((u64) Data[iByte+3] << 32) |
|
||||
((u64) Data[iByte+4] << 24) |
|
||||
((u64) Data[iByte+5] << 16) |
|
||||
((u64) Data[iByte+6] << 8) |
|
||||
((u64) Data[iByte+7] << 0) );
|
||||
}
|
||||
|
||||
if (gpResourceStore->IsResourceRegistered(ID))
|
||||
pGroup->AddDependency(ID);
|
||||
}
|
||||
|
||||
return pGroup;
|
||||
}
|
||||
|
||||
CDependencyGroup* CUnsupportedFormatLoader::LoadFRME(IInputStream& rFRME, CResourceEntry *pEntry)
|
||||
{
|
||||
u32 Version = rFRME.ReadLong();
|
||||
|
@ -223,6 +265,25 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadFSM2(IInputStream& rFSM2, CResou
|
|||
return pOut;
|
||||
}
|
||||
|
||||
CDependencyGroup* CUnsupportedFormatLoader::LoadHIER(IInputStream& rHIER, CResourceEntry *pEntry)
|
||||
{
|
||||
CFourCC Magic = rHIER.ReadLong();
|
||||
ASSERT(Magic == "HIER");
|
||||
|
||||
u32 NumNodes = rHIER.ReadLong();
|
||||
CDependencyGroup *pOut = new CDependencyGroup(pEntry);
|
||||
|
||||
for (u32 iNode = 0; iNode < NumNodes; iNode++)
|
||||
{
|
||||
// NOTE: The SCAN ID isn't considered a real dependency!
|
||||
pOut->AddDependency( rHIER.ReadLong() );
|
||||
rHIER.ReadString();
|
||||
rHIER.Seek(0x8, SEEK_CUR);
|
||||
}
|
||||
|
||||
return pOut;
|
||||
}
|
||||
|
||||
CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry)
|
||||
{
|
||||
u32 Magic = rHINT.ReadLong();
|
||||
|
|
|
@ -12,8 +12,10 @@ class CUnsupportedFormatLoader
|
|||
|
||||
public:
|
||||
static CDependencyGroup* LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadDUMB(IInputStream& rDUMB, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadFRME(IInputStream& rFRME, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadFSM2(IInputStream& rFSM2, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadHIER(IInputStream& rHIER, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadMAPW(IInputStream& rMAPW, CResourceEntry *pEntry);
|
||||
static CDependencyGroup* LoadMAPU(IInputStream& rMAPU, CResourceEntry *pEntry);
|
||||
|
|
|
@ -79,9 +79,7 @@
|
|||
</properties>
|
||||
</struct>
|
||||
<property ID="0x008BECAB" type="asset" extensions="PART"/>
|
||||
<property ID="0xF3AF8417" type="long">
|
||||
<default>-1</default>
|
||||
</property>
|
||||
<property ID="0xF3AF8417" type="sound"/>
|
||||
<property ID="0xDADC5BC9" type="float">
|
||||
<default>2.0</default>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue