Renamed CUniqueID to CAssetID and heavily modified the implementation to drop 128-bit support and use a u64 internally instead of a u8[16]

This commit is contained in:
parax0
2016-07-25 03:25:22 -06:00
parent 9341c11ac8
commit 5f1b5da430
36 changed files with 285 additions and 519 deletions

View File

@@ -34,7 +34,7 @@ CGameArea::~CGameArea()
CDependencyTree* CGameArea::BuildDependencyTree() const
{
// Base dependencies
CAreaDependencyTree *pTree = new CAreaDependencyTree(ResID());
CAreaDependencyTree *pTree = new CAreaDependencyTree(ID());
for (u32 iMat = 0; iMat < mpMaterialSet->NumMaterials(); iMat++)
{

View File

@@ -106,7 +106,7 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
else
{
rSCLY.WriteLongLong(CUniqueID::skInvalidID64.ToLongLong());
rSCLY.WriteLongLong(CAssetID::skInvalidID64.ToLongLong());
rSCLY.WriteLong(0xFFFFFFFF);
}
}

View File

@@ -28,7 +28,7 @@ public:
// Accessors
inline EGame Version() const { return mGame; }
inline CUniqueID ID() const { return mCharacter.ID(); }
inline CAssetID ID() const { return mCharacter.ID(); }
inline CAnimSet* AnimSet() const { return (CAnimSet*) mCharacter.Load(); }
inline u32 CharacterIndex() const { return mCharIndex; }
inline u32 AnimIndex() const { return mAnimIndex; }

View File

@@ -6,21 +6,21 @@
class CDependencyGroup : public CResource
{
DECLARE_RESOURCE_TYPE(eDependencyGroup)
std::set<CUniqueID> mDependencies;
std::set<CAssetID> mDependencies;
public:
CDependencyGroup(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
inline void AddDependency(const CUniqueID& rkID) { mDependencies.insert(rkID); }
inline void AddDependency(CResource *pRes) { if (pRes) mDependencies.insert(pRes->ResID()); }
inline void RemoveDependency(const CUniqueID& rkID) { mDependencies.erase(rkID); }
inline void AddDependency(const CAssetID& rkID) { mDependencies.insert(rkID); }
inline void AddDependency(CResource *pRes) { if (pRes) mDependencies.insert(pRes->ID()); }
inline void RemoveDependency(const CAssetID& rkID) { mDependencies.erase(rkID); }
inline void Clear() { mDependencies.clear(); }
inline bool HasDependency(const CUniqueID& rkID) const { return mDependencies.find(rkID) != mDependencies.end(); }
inline bool HasDependency(const CAssetID& rkID) const { return mDependencies.find(rkID) != mDependencies.end(); }
inline u32 NumDependencies() const { return mDependencies.size(); }
inline CUniqueID DependencyByIndex(u32 Index) const { return *std::next(mDependencies.begin(), Index); }
inline CAssetID DependencyByIndex(u32 Index) const { return *std::next(mDependencies.begin(), Index); }
CDependencyTree* BuildDependencyTree() const
{
CDependencyTree *pTree = new CDependencyTree(ResID());
CDependencyTree *pTree = new CDependencyTree(ID());
for (auto DepIt = mDependencies.begin(); DepIt != mDependencies.end(); DepIt++)
pTree->AddDependency(*DepIt);

View File

@@ -24,7 +24,7 @@ inline float PtsToFloat(s32 Pt)
CDependencyTree* CFont::BuildDependencyTree() const
{
CDependencyTree *pOut = new CDependencyTree(ResID());
CDependencyTree *pOut = new CDependencyTree(ID());
pOut->AddDependency(mpFontTexture);
return pOut;
}

View File

@@ -5,8 +5,8 @@
#include "Core/GameProject/CDependencyTree.h"
#include "Core/GameProject/CResourceEntry.h"
#include "Core/GameProject/CResourceStore.h"
#include <Common/CAssetID.h>
#include <Common/CFourCC.h>
#include <Common/CUniqueID.h>
#include <Common/types.h>
#include <Common/TString.h>
@@ -40,12 +40,12 @@ public:
}
virtual ~CResource() {}
virtual CDependencyTree* BuildDependencyTree() const { return new CDependencyTree(ResID()); }
virtual CDependencyTree* BuildDependencyTree() const { return new CDependencyTree(ID()); }
inline CResourceEntry* Entry() const { return mpEntry; }
inline TString Source() const { return mpEntry ? mpEntry->CookedAssetPath(true).GetFileName() : ""; }
inline TString FullSource() const { return mpEntry ? mpEntry->CookedAssetPath(true) : ""; }
inline CUniqueID ResID() const { return mpEntry ? mpEntry->ID() : CUniqueID::skInvalidID64; }
inline CAssetID ID() const { return mpEntry ? mpEntry->ID() : CAssetID::skInvalidID64; }
inline EGame Game() const { return mpEntry ? mpEntry->Game() : eUnknownVersion; }
inline bool IsReferenced() const { return mRefCount > 0; }
inline void SetGame(EGame Game) { if (mpEntry) mpEntry->SetGame(Game); }

View File

@@ -3,7 +3,7 @@
#include "CResource.h"
#include "Core/GameProject/CResourceStore.h"
#include <Common/CUniqueID.h>
#include <Common/CAssetID.h>
#include <Common/CFourCC.h>
#include <Common/FileUtil.h>
@@ -23,25 +23,25 @@ public:
mIsValidPath = FileUtil::Exists(rkPath);
}
CResourceInfo(const CUniqueID& rkID, CFourCC Type)
CResourceInfo(const CAssetID& rkID, CFourCC Type)
: mIsPath(false), mIsValidPath(false)
{
mPath = rkID.ToString() + "." + Type.ToString();
}
inline CUniqueID ID() const
inline CAssetID ID() const
{
TString FileName = mPath.GetFileName(false);
if (!mIsPath)
return CUniqueID::FromString(FileName);
return CAssetID::FromString(FileName);
else
{
if (FileName.IsHexString() && (FileName.Size() == 8 || FileName.Size() == 16))
return CUniqueID::FromString(FileName);
return CAssetID::FromString(FileName);
else
return CUniqueID::skInvalidID64;
return CAssetID::skInvalidID64;
}
}

View File

@@ -45,7 +45,7 @@ public:
if (Game() >= eEchoesDemo)
Log::Warning("CScan::BuildDependencyTree not handling Echoes/Corruption dependencies");
CDependencyTree *pTree = new CDependencyTree(ResID());
CDependencyTree *pTree = new CDependencyTree(ID());
pTree->AddDependency(mpFrame);
pTree->AddDependency(mpStringTable);
return pTree;

View File

@@ -19,7 +19,7 @@ CWorld::~CWorld()
CDependencyTree* CWorld::BuildDependencyTree() const
{
CDependencyTree *pTree = new CDependencyTree(ResID());
CDependencyTree *pTree = new CDependencyTree(ID());
for (u32 iArea = 0; iArea < mAreas.size(); iArea++)
{

View File

@@ -47,7 +47,7 @@ void CMaterialCooker::WriteMatSetPrime(IOutputStream& rOut)
{
CTexture *pTex = pMat->Pass(iPass)->Texture();
if (pTex)
mTextureIDs.push_back(pTex->ResID().ToLong());
mTextureIDs.push_back(pTex->ID().ToLong());
}
}
@@ -122,7 +122,7 @@ void CMaterialCooker::WriteMaterialPrime(IOutputStream& rOut)
if (pPassTex != nullptr)
{
TexFlags |= (1 << iPass);
u32 TexID = pPassTex->ResID().ToLong();
u32 TexID = pPassTex->ID().ToLong();
for (u32 iTex = 0; iTex < mTextureIDs.size(); iTex++)
{

View File

@@ -602,7 +602,7 @@ void CAreaLoader::ReadEGMC()
{
Log::FileWrite(mpMREA->GetSourceString(), "Reading EGMC");
mpSectionMgr->ToSection(mEGMCBlockNum);
CUniqueID EGMC(*mpMREA, (mVersion <= eEchoes ? e32Bit : e64Bit));
CAssetID EGMC(*mpMREA, (mVersion <= eEchoes ? e32Bit : e64Bit));
mpArea->mpPoiToWorldMap = gpResourceStore->LoadResource(EGMC, "EGMC");
}

View File

@@ -32,7 +32,7 @@ CDependencyGroup* CDependencyGroupLoader::LoadDGRP(IInputStream& rDGRP, CResourc
u32 NumDependencies = rDGRP.ReadLong();
EGame Game = VersionTest(rDGRP, NumDependencies);
EUIDLength IDLength = (Game < eCorruptionProto ? e32Bit : e64Bit);
EIDLength IDLength = (Game < eCorruptionProto ? e32Bit : e64Bit);
CDependencyGroup *pGroup = new CDependencyGroup(pEntry);
pGroup->SetGame(Game);
@@ -40,7 +40,7 @@ CDependencyGroup* CDependencyGroupLoader::LoadDGRP(IInputStream& rDGRP, CResourc
for (u32 iDep = 0; iDep < NumDependencies; iDep++)
{
rDGRP.Seek(0x4, SEEK_CUR); // Skip dependency type
CUniqueID AssetID(rDGRP, IDLength);
CAssetID AssetID(rDGRP, IDLength);
pGroup->AddDependency(AssetID);
}

View File

@@ -110,7 +110,7 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY
{
TFileProperty *pFileCast = static_cast<TFileProperty*>(pProp);
CUniqueID ResID = (mVersion < eCorruptionProto ? rSCLY.ReadLong() : rSCLY.ReadLongLong());
CAssetID ResID = (mVersion < eCorruptionProto ? rSCLY.ReadLong() : rSCLY.ReadLongLong());
const TStringList& rkExtensions = static_cast<CFileTemplate*>(pTemp)->Extensions();
CResourceInfo Info(ResID, CFourCC(!rkExtensions.empty() ? rkExtensions.front() : "UNKN"));

View File

@@ -32,7 +32,7 @@ CModel::~CModel()
CDependencyTree* CModel::BuildDependencyTree() const
{
CDependencyTree *pTree = new CDependencyTree(ResID());
CDependencyTree *pTree = new CDependencyTree(ID());
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
{