Added support for loading dependencies of EVNT and STRG

This commit is contained in:
parax0
2016-07-27 03:24:15 -06:00
parent 7f2cac6216
commit 11a7b86120
5 changed files with 103 additions and 30 deletions

View File

@@ -256,6 +256,7 @@ CResource* CResourceEntry::Load(IInputStream& rInput)
switch (mType)
{
case eAnimation: mpResource = CAnimationLoader::LoadANIM(rInput, this); break;
case eAnimEventData: mpResource = CUnsupportedFormatLoader::LoadEVNT(rInput, this); break;
case eAnimSet: mpResource = CAnimSetLoader::LoadANCSOrCHAR(rInput, this); break;
case eArea: mpResource = CAreaLoader::LoadMREA(rInput, this); break;
case eDependencyGroup: mpResource = CDependencyGroupLoader::LoadDGRP(rInput, this); break;

View File

@@ -41,6 +41,33 @@ public:
return TWideString();
}
CDependencyTree* BuildDependencyTree() const
{
// The only dependencies STRGs have is they can reference FONTs with the &font=; formatting tag
CDependencyTree *pTree = new CDependencyTree(ID());
EIDLength IDLength = (Game() <= eEchoes ? e32Bit : e64Bit);
for (u32 iLang = 0; iLang < mLangTables.size(); iLang++)
{
const SLangTable& rkTable = mLangTables[iLang];
for (u32 iStr = 0; iStr < rkTable.Strings.size(); iStr++)
{
static const TWideString skTag = L"&font=";
const TWideString& rkStr = rkTable.Strings[iStr];
for (u32 FontIdx = rkStr.IndexOfPhrase(*skTag); FontIdx != -1; FontIdx = rkStr.IndexOfPhrase(*skTag, FontIdx + 1))
{
u32 IDStart = FontIdx + skTag.Size();
TWideString StrFontID = rkStr.SubString(IDStart, IDLength * 2);
pTree->AddDependency( CAssetID::FromString(StrFontID) );
}
}
}
return pTree;
}
};
#endif // CSTRINGTABLE_H

View File

@@ -12,6 +12,50 @@ CDependencyGroup* CUnsupportedFormatLoader::LoadCSNG(IInputStream& rCSNG, CResou
return pGroup;
}
CDependencyGroup* CUnsupportedFormatLoader::LoadEVNT(IInputStream& rEVNT, CResourceEntry *pEntry)
{
u32 Version = rEVNT.ReadLong();
ASSERT(Version == 1 || Version == 2);
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
// Loop Events
u32 NumLoopEvents = rEVNT.ReadLong();
for (u32 iLoop = 0; iLoop < NumLoopEvents; iLoop++)
{
rEVNT.Seek(0x2, SEEK_CUR);
rEVNT.ReadString();
rEVNT.Seek(0x1C, SEEK_CUR);
}
// User Events
u32 NumUserEvents = rEVNT.ReadLong();
for (u32 iUser = 0; iUser < NumUserEvents; iUser++)
{
rEVNT.Seek(0x2, SEEK_CUR);
rEVNT.ReadString();
rEVNT.Seek(0x1F, SEEK_CUR);
rEVNT.ReadString();
}
// Effect Events
u32 NumEffectEvents = rEVNT.ReadLong();
for (u32 iFX = 0; iFX < NumEffectEvents; iFX++)
{
rEVNT.Seek(0x2, SEEK_CUR);
rEVNT.ReadString();
rEVNT.Seek(0x23, SEEK_CUR);
pGroup->AddDependency(rEVNT.ReadLong());
rEVNT.ReadString();
rEVNT.Seek(0x8, SEEK_CUR);
}
return pGroup;
}
CDependencyGroup* CUnsupportedFormatLoader::LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry)
{
u32 Magic = rHINT.ReadLong();

View File

@@ -12,6 +12,7 @@ class CUnsupportedFormatLoader
public:
static CDependencyGroup* LoadCSNG(IInputStream& rCSNG, CResourceEntry *pEntry);
static CDependencyGroup* LoadEVNT(IInputStream& rEVNT, CResourceEntry *pEntry);
static CDependencyGroup* LoadHINT(IInputStream& rHINT, CResourceEntry *pEntry);
static CDependencyGroup* LoadMAPW(IInputStream& rMAPW, CResourceEntry *pEntry);
static CDependencyGroup* LoadMAPU(IInputStream& rMAPU, CResourceEntry *pEntry);