diff --git a/src/Common/CAssetID.cpp b/src/Common/CAssetID.cpp new file mode 100644 index 00000000..78bbf2ed --- /dev/null +++ b/src/Common/CAssetID.cpp @@ -0,0 +1,93 @@ +#include "CAssetID.h" +#include "TString.h" +#include + +CAssetID::CAssetID() + : mLength(eInvalidIDLength) + , mID(0xFFFFFFFFFFFFFFFF) +{ + +} + +CAssetID::CAssetID(u64 ID) + : mID(ID) +{ + // This constructor is intended to be used with both 32-bit and 64-bit input values + // 64-bit - check for valid content in upper 32 bits (at least one bit set + one bit unset) + if ((ID & 0xFFFFFFFF00000000) && (~ID & 0xFFFFFFFF00000000)) + mLength = e64Bit; + + // 32-bit + else + { + mLength = e32Bit; + mID &= 0xFFFFFFFF; + } +} + +CAssetID::CAssetID(u64 ID, EIDLength Length) + : mID(ID) + , mLength(Length) +{ + if (Length == e32Bit) + mID &= 0xFFFFFFFF; +} + +CAssetID::CAssetID(const char* pkID) +{ + *this = CAssetID::FromString(pkID); +} + +CAssetID::CAssetID(IInputStream& rInput, EIDLength Length) + : mLength(Length) +{ + if (Length == e32Bit) mID = (u64) rInput.ReadLong(); + else mID = rInput.ReadLongLong(); +} + +TString CAssetID::ToString() const +{ + if (mLength == e32Bit) + return TString::FromInt32(ToLong(), 8, 16); + else + return TString::FromInt64(ToLongLong(), 8, 16); +} + +bool CAssetID::IsValid() const +{ + if (mLength == e32Bit) + return (*this != skInvalidID32); + + else if (mLength == e64Bit) + return (*this != skInvalidID64); + + else return false; +} + +// ************ STATIC ************ +CAssetID CAssetID::FromString(const TString& rkString) +{ + // If the input is a hex ID in string form, then preserve it... otherwise, generate an ID by hashing the string + TString Name = rkString.GetFileName(false); + u32 NameLength = Name.Length(); + + if (Name.IsHexString()) + { + if (NameLength == 8) return CAssetID(Name.ToInt32()); + if (NameLength == 16) return CAssetID(Name.ToInt64()); + } + + return CAssetID(rkString.Hash64()); +} + +CAssetID CAssetID::RandomID() +{ + CAssetID ID; + ID.mLength = e64Bit; + ID.mID = (u64(rand()) << 32) | rand(); + return ID; +} + +// ************ STATIC MEMBER INITIALIZATION ************ +CAssetID CAssetID::skInvalidID32 = CAssetID((u64) -1, e32Bit); +CAssetID CAssetID::skInvalidID64 = CAssetID((u64) -1, e64Bit); diff --git a/src/Common/CAssetID.h b/src/Common/CAssetID.h new file mode 100644 index 00000000..25ecb6f5 --- /dev/null +++ b/src/Common/CAssetID.h @@ -0,0 +1,55 @@ +#ifndef CASSETID_H +#define CASSETID_H + +#include "TString.h" +#include "types.h" +#include + +enum EIDLength +{ + e32Bit = 4, + e64Bit = 8, + eInvalidIDLength = 0 +}; + +class CAssetID +{ + EIDLength mLength; + u64 mID; + +public: + CAssetID(); + CAssetID(u64 ID); + CAssetID(u64 ID, EIDLength Length); + CAssetID(const char* pkID); + CAssetID(IInputStream& rInput, EIDLength Length); + TString ToString() const; + bool IsValid() const; +\ + // Operators + inline void operator=(const u64& rkInput) { *this = CAssetID(rkInput); } + inline void operator=(const char *pkInput) { *this = CAssetID(pkInput); } + inline bool operator==(const CAssetID& rkOther) const { return mLength == rkOther.mLength && mID == rkOther.mID; } + inline bool operator!=(const CAssetID& rkOther) const { return mLength != rkOther.mLength || mID != rkOther.mID; } + inline bool operator>(const CAssetID& rkOther) const { return mID > rkOther.mID; } + inline bool operator>=(const CAssetID& rkOther) const { return mID >= rkOther.mID; } + inline bool operator<(const CAssetID& rkOther) const { return mID < rkOther.mID; } + inline bool operator<=(const CAssetID& rkOther) const { return mID <= rkOther.mID; } + inline bool operator==(u64 Other) const { return mID == Other; } + inline bool operator!=(u64 Other) const { return mID != Other; } + + // Accessors + inline u32 ToLong() const { return (u32) mID; } + inline u64 ToLongLong() const { return mID; } + inline EIDLength Length() const { return mLength; } + inline void SetLength(EIDLength Length) { mLength = Length; } + + // Static + static CAssetID FromString(const TString& rkString); + static CAssetID RandomID(); + + static CAssetID skInvalidID32; + static CAssetID skInvalidID64; +}; + +#endif // CASSETID_H diff --git a/src/Common/CUniqueID.cpp b/src/Common/CUniqueID.cpp deleted file mode 100644 index 79fbece4..00000000 --- a/src/Common/CUniqueID.cpp +++ /dev/null @@ -1,324 +0,0 @@ -#include "CUniqueID.h" -#include "TString.h" - -#include -#include -#include - -// this class probably isn't optimized! this may not be the best way to do things -using IOUtil::kSystemEndianness; -using IOUtil::eLittleEndian; -using IOUtil::eBigEndian; - -CUniqueID::CUniqueID() - : mLength(eInvalidUIDLength) -{ - memset(mID, 0, 16); -} - -CUniqueID::CUniqueID(u64 ID) -{ - // This constructor is intended to be used with both 32-bit and 64-bit input values - memset(mID, 0, 16); - - // 64-bit - check for valid content in upper 32 bits (at least one bit set + one bit unset) - if ((ID & 0xFFFFFFFF00000000) && (~ID & 0xFFFFFFFF00000000)) - { - memcpy(&mID, &ID, 8); - mLength = e64Bit; - } - - // 32-bit - else - { - memcpy(mID, &ID, 4); - mLength = e32Bit; - } - - // Reverse for Big Endian - if (kSystemEndianness == eBigEndian) - Reverse(); -} - -CUniqueID::CUniqueID(u64 ID, EUIDLength Length) -{ - // This constructor shouldn't be used for 128-bit - memset(mID, 0, 16); - - // 64-bit - if (Length == e64Bit || Length == e128Bit) - { - memcpy(&mID, &ID, 8); - mLength = e64Bit; - } - - // 32-bit - else - { - memcpy(mID, &ID, 4); - mLength = e32Bit; - } - - // Reverse for Big Endian - if (kSystemEndianness == eBigEndian) - Reverse(); -} - -CUniqueID::CUniqueID(u64 Part1, u64 Part2) -{ - // Constructor for 128-bit IDs - memcpy(&mID[0], &Part1, 8); - memcpy(&mID[8], &Part2, 8); - mLength = e128Bit; -} - -CUniqueID::CUniqueID(const char* pkID) -{ - *this = CUniqueID::FromString(pkID); -} - -CUniqueID::CUniqueID(IInputStream& rInput, EUIDLength Length) -{ - memset(mID, 0, 16); - rInput.ReadBytes(&mID[16 - Length], Length); - - if (Length != e128Bit) - if (kSystemEndianness == eLittleEndian) - Reverse(); - - mLength = Length; -} - -u32 CUniqueID::ToLong() const -{ - if (kSystemEndianness == eLittleEndian) - return *((u32*) mID); - else - return *((u32*) &mID[12]); -} - -u64 CUniqueID::ToLongLong() const -{ - if (kSystemEndianness == eLittleEndian) - return *((u64*) mID); - else - return *((u64*) &mID[8]); -} - -TString CUniqueID::ToString() const -{ - switch (mLength) - { - case e32Bit: - return TString::FromInt32(ToLong(), 8); - - case e64Bit: - return TString::FromInt64(ToLongLong(), 16); - - case e128Bit: - // todo: TString should have a "FromInt128" function - std::stringstream Ret; - Ret << std::hex << std::setfill('0'); - - for (u32 iByte = 0; iByte < 16; iByte++) - Ret << std::setw(2) << (u32) mID[iByte]; - - return Ret.str(); - } - - return "INVALID ID LENGTH"; -} - -void CUniqueID::Reverse() -{ - std::reverse(mID, &mID[16]); -} - -EUIDLength CUniqueID::Length() const -{ - return mLength; -} - -void CUniqueID::SetLength(EUIDLength Length) -{ - mLength = Length; -} - -bool CUniqueID::IsValid() const -{ - if (mLength == e32Bit) - return (*this != skInvalidID32); - - else if (mLength == e64Bit) - return (*this != skInvalidID64); - - else if (mLength == e128Bit) - return (*this != skInvalidID128); - - else return false; -} - -// ************ OPERATORS ************ -void CUniqueID::operator=(const u64& rkInput) -{ - *this = CUniqueID(rkInput); -} - -void CUniqueID::operator=(const char* pkInput) -{ - *this = CUniqueID(pkInput); -} - -bool CUniqueID::operator==(const CUniqueID& rkOther) const -{ - return ((mLength == rkOther.mLength) && - (memcmp(mID, rkOther.mID, 16) == 0)); -} - -bool CUniqueID::operator!=(const CUniqueID& rkOther) const -{ - return (!(*this == rkOther)); -} - -bool CUniqueID::operator>(const CUniqueID& rkOther) const -{ - if (mLength != rkOther.mLength) - return mLength > rkOther.mLength; - - switch (mLength) - { - case e32Bit: - return (ToLong() > rkOther.ToLong()); - - case e64Bit: - return (ToLongLong() > rkOther.ToLongLong()); - - case e128Bit: - for (u32 iByte = 0; iByte < 16; iByte++) - if (mID[iByte] != rkOther.mID[iByte]) - return (mID[iByte] > rkOther.mID[iByte]); - return false; - - default: - return false; - } -} - -bool CUniqueID::operator>=(const CUniqueID& rkOther) const -{ - return ((*this == rkOther) || (*this > rkOther)); -} - -bool CUniqueID::operator<(const CUniqueID& rkOther) const -{ - if (mLength != rkOther.mLength) - return mLength < rkOther.mLength; - - switch (mLength) - { - case e32Bit: - return (ToLong() < rkOther.ToLong()); - - case e64Bit: - return (ToLongLong() < rkOther.ToLongLong()); - - case e128Bit: - for (u32 iByte = 0; iByte < 16; iByte++) - if (mID[iByte] != rkOther.mID[iByte]) - return (mID[iByte] < rkOther.mID[iByte]); - return false; - - default: - return false; - } -} - -bool CUniqueID::operator<=(const CUniqueID& rkOther) const -{ - return ((*this == rkOther) || (*this < rkOther)); -} - -bool CUniqueID::operator==(u64 Other) const -{ - return (*this == CUniqueID(Other)); -} - -bool CUniqueID::operator!=(u64 Other) const -{ - return (!(*this == Other)); -} - -// ************ STATIC ************ -CUniqueID CUniqueID::FromString(const TString& rkString) -{ - // If the input is a hex ID in string form, then preserve it... otherwise, generate an ID by hashing the string - TString Name = rkString.GetFileName(false); - u32 NameLength = Name.Length(); - - if (Name.IsHexString()) - { - if (NameLength == 8) - { - CUniqueID ID; - ID.mLength = e32Bit; - - u32 LongID = Name.ToInt32(); - - if (kSystemEndianness == eLittleEndian) - memcpy(ID.mID, &LongID, 4); - else - memcpy(&ID.mID[12], &LongID, 4); - - return ID; - } - - else if (NameLength == 16) - { - CUniqueID ID; - ID.mLength = e64Bit; - - u64 LongID = Name.ToInt64(); - - if (kSystemEndianness == eLittleEndian) - memcpy(ID.mID, &LongID, 8); - else - memcpy(&ID.mID[8], &LongID, 8); - - return ID; - } - - else if (NameLength == 32) - { - CUniqueID ID; - ID.mLength = e128Bit; - Name.ToInt128((char*) ID.mID); - return ID; - } - } - - return CUniqueID(rkString.Hash64()); -} - -CUniqueID CUniqueID::FromData(void *pData, EUIDLength Length) -{ - CUniqueID ID; - ID.mLength = Length; - memcpy(ID.mID, pData, Length); - return ID; -} - -CUniqueID CUniqueID::RandomID() -{ - CUniqueID ID; - ID.mLength = e128Bit; - - for (u32 iByte = 0; iByte < 16; iByte++) - ID.mID[iByte] = rand() & 0xFF; - - return ID; -} - -// ************ STATIC MEMBER INITIALIZATION ************ -CUniqueID CUniqueID::skInvalidID32 = CUniqueID((u32) -1, e32Bit); -CUniqueID CUniqueID::skInvalidID64 = CUniqueID((u64) -1, e64Bit); -CUniqueID CUniqueID::skInvalidID128 = CUniqueID((u64) -1, (u64) -1); diff --git a/src/Common/CUniqueID.h b/src/Common/CUniqueID.h deleted file mode 100644 index 72f26928..00000000 --- a/src/Common/CUniqueID.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef CUNIQUEID_H -#define CUNIQUEID_H - -#include "TString.h" -#include "types.h" -#include - -enum EUIDLength -{ - e32Bit = 4, - e64Bit = 8, - e128Bit = 16, - eInvalidUIDLength = 0 -}; - -class CUniqueID -{ - EUIDLength mLength; - u8 mID[16]; - -public: - CUniqueID(); - CUniqueID(u64 ID); - CUniqueID(u64 ID, EUIDLength Length); - CUniqueID(u64 Part1, u64 Part2); - CUniqueID(const char* pkID); - CUniqueID(IInputStream& rInput, EUIDLength Length); - u32 ToLong() const; - u64 ToLongLong() const; - TString ToString() const; - void Reverse(); - EUIDLength Length() const; - void SetLength(EUIDLength Length); - bool IsValid() const; - - // Operators - void operator=(const u64& rkInput); - void operator=(const char *pkInput); - bool operator==(const CUniqueID& rkOther) const; - bool operator!=(const CUniqueID& rkOther) const; - bool operator>(const CUniqueID& rkOther) const; - bool operator>=(const CUniqueID& rkOther) const; - bool operator<(const CUniqueID& rkOther) const; - bool operator<=(const CUniqueID& rkOther) const; - bool operator==(u64 Other) const; - bool operator!=(u64 Other) const; - - // Static - static CUniqueID FromString(const TString& rkString); - static CUniqueID FromData(void *pkData, EUIDLength Length); - static CUniqueID RandomID(); - - static CUniqueID skInvalidID32; - static CUniqueID skInvalidID64; - static CUniqueID skInvalidID128; -}; - -#endif // CUNIQUEID_H diff --git a/src/Common/Common.pro b/src/Common/Common.pro index 30080f56..e8dd4769 100644 --- a/src/Common/Common.pro +++ b/src/Common/Common.pro @@ -64,7 +64,6 @@ HEADERS += \ CHashFNV1A.h \ CompressionUtil.h \ CTimer.h \ - CUniqueID.h \ EKeyInputs.h \ EMouseInputs.h \ ETransformSpace.h \ @@ -74,14 +73,15 @@ HEADERS += \ Log.h \ FileUtil.h \ AssertMacro.h \ - CScopedTimer.h + CScopedTimer.h \ + CAssetID.h # Source Files SOURCES += \ CColor.cpp \ CompressionUtil.cpp \ CTimer.cpp \ - CUniqueID.cpp \ TString.cpp \ Log.cpp \ - FileUtil.cpp + FileUtil.cpp \ + CAssetID.cpp diff --git a/src/Core/GameProject/CDependencyTree.cpp b/src/Core/GameProject/CDependencyTree.cpp index e433fb0c..599f003c 100644 --- a/src/Core/GameProject/CDependencyTree.cpp +++ b/src/Core/GameProject/CDependencyTree.cpp @@ -8,12 +8,12 @@ EDependencyNodeType CResourceDependency::Type() const return eDNT_ResourceDependency; } -void CResourceDependency::Read(IInputStream& rFile, EUIDLength IDLength) +void CResourceDependency::Read(IInputStream& rFile, EIDLength IDLength) { - mID = CUniqueID(rFile, IDLength); + mID = CAssetID(rFile, IDLength); } -void CResourceDependency::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CResourceDependency::Write(IOutputStream& rFile, EIDLength IDLength) const { if (IDLength == e32Bit) rFile.WriteLong(mID.ToLong()); @@ -27,13 +27,13 @@ EDependencyNodeType CAnimSetDependency::Type() const return eDNT_AnimSet; } -void CAnimSetDependency::Read(IInputStream& rFile, EUIDLength IDLength) +void CAnimSetDependency::Read(IInputStream& rFile, EIDLength IDLength) { CResourceDependency::Read(rFile, IDLength); mUsedChar = rFile.ReadLong(); } -void CAnimSetDependency::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CAnimSetDependency::Write(IOutputStream& rFile, EIDLength IDLength) const { CResourceDependency::Write(rFile, IDLength); rFile.WriteLong(mUsedChar); @@ -65,9 +65,9 @@ EDependencyNodeType CDependencyTree::Type() const return eDNT_Root; } -void CDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) +void CDependencyTree::Read(IInputStream& rFile, EIDLength IDLength) { - mID = CUniqueID(rFile, IDLength); + mID = CAssetID(rFile, IDLength); u32 NumDepends = rFile.ReadLong(); mReferencedResources.reserve(NumDepends); @@ -80,7 +80,7 @@ void CDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) } } -void CDependencyTree::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CDependencyTree::Write(IOutputStream& rFile, EIDLength IDLength) const { if (IDLength == e32Bit) rFile.WriteLong(mID.ToLong()); @@ -98,7 +98,7 @@ u32 CDependencyTree::NumDependencies() const return mReferencedResources.size(); } -bool CDependencyTree::HasDependency(const CUniqueID& rkID) +bool CDependencyTree::HasDependency(const CAssetID& rkID) { for (u32 iDep = 0; iDep < mReferencedResources.size(); iDep++) { @@ -109,7 +109,7 @@ bool CDependencyTree::HasDependency(const CUniqueID& rkID) return false; } -CUniqueID CDependencyTree::DependencyByIndex(u32 Index) const +CAssetID CDependencyTree::DependencyByIndex(u32 Index) const { ASSERT(Index >= 0 && Index < mReferencedResources.size()); return mReferencedResources[Index]->ID(); @@ -117,12 +117,12 @@ CUniqueID CDependencyTree::DependencyByIndex(u32 Index) const void CDependencyTree::AddDependency(CResource *pRes) { - if (!pRes || HasDependency(pRes->ResID())) return; - CResourceDependency *pDepend = new CResourceDependency(pRes->ResID()); + if (!pRes || HasDependency(pRes->ID())) return; + CResourceDependency *pDepend = new CResourceDependency(pRes->ID()); mReferencedResources.push_back(pDepend); } -void CDependencyTree::AddDependency(const CUniqueID& rkID) +void CDependencyTree::AddDependency(const CAssetID& rkID) { if (!rkID.IsValid() || HasDependency(rkID)) return; CResourceDependency *pDepend = new CResourceDependency(rkID); @@ -135,7 +135,7 @@ EDependencyNodeType CAnimSetDependencyTree::Type() const return eDNT_AnimSet; } -void CAnimSetDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) +void CAnimSetDependencyTree::Read(IInputStream& rFile, EIDLength IDLength) { CDependencyTree::Read(rFile, IDLength); u32 NumChars = rFile.ReadLong(); @@ -145,7 +145,7 @@ void CAnimSetDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) mCharacterOffsets.push_back( rFile.ReadLong() ); } -void CAnimSetDependencyTree::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CAnimSetDependencyTree::Write(IOutputStream& rFile, EIDLength IDLength) const { CDependencyTree::Write(rFile, IDLength); rFile.WriteLong(mCharacterOffsets.size()); @@ -166,7 +166,7 @@ EDependencyNodeType CScriptInstanceDependencyTree::Type() const return eDNT_ScriptInstance; } -void CScriptInstanceDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) +void CScriptInstanceDependencyTree::Read(IInputStream& rFile, EIDLength IDLength) { mObjectType = rFile.ReadLong(); u32 NumDepends = rFile.ReadLong(); @@ -174,7 +174,7 @@ void CScriptInstanceDependencyTree::Read(IInputStream& rFile, EUIDLength IDLengt for (u32 iDep = 0; iDep < NumDepends; iDep++) { - CUniqueID ID(rFile, IDLength); + CAssetID ID(rFile, IDLength); CResourceEntry *pEntry = gpResourceStore->FindEntry(ID); if (pEntry && pEntry->ResourceType() == eAnimSet && pEntry->Game() <= eEchoes) @@ -193,7 +193,7 @@ void CScriptInstanceDependencyTree::Read(IInputStream& rFile, EUIDLength IDLengt } } -void CScriptInstanceDependencyTree::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CScriptInstanceDependencyTree::Write(IOutputStream& rFile, EIDLength IDLength) const { rFile.WriteLong(mObjectType); rFile.WriteLong(mDependencies.size()); @@ -202,7 +202,7 @@ void CScriptInstanceDependencyTree::Write(IOutputStream& rFile, EUIDLength IDLen mDependencies[iDep]->Write(rFile, IDLength); } -bool CScriptInstanceDependencyTree::HasDependency(const CUniqueID& rkID) +bool CScriptInstanceDependencyTree::HasDependency(const CAssetID& rkID) { if (!rkID.IsValid()) return false; @@ -235,7 +235,7 @@ void CScriptInstanceDependencyTree::ParseStructDependencies(CScriptInstanceDepen else if (pProp->Type() == eFileProperty) { - CUniqueID ID = static_cast(pProp)->Get().ID(); + CAssetID ID = static_cast(pProp)->Get().ID(); if (ID.IsValid() && !pTree->HasDependency(ID)) { @@ -247,7 +247,7 @@ void CScriptInstanceDependencyTree::ParseStructDependencies(CScriptInstanceDepen else if (pProp->Type() == eCharacterProperty) { TCharacterProperty *pChar = static_cast(pProp); - CUniqueID ID = pChar->Get().ID(); + CAssetID ID = pChar->Get().ID(); if (ID.IsValid() && !pTree->HasDependency(ID)) pTree->mDependencies.push_back( CAnimSetDependency::BuildDependency(pChar) ); @@ -267,7 +267,7 @@ EDependencyNodeType CAreaDependencyTree::Type() const return eDNT_Area; } -void CAreaDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) +void CAreaDependencyTree::Read(IInputStream& rFile, EIDLength IDLength) { // Base dependency list contains non-script dependencies (world geometry textures + PATH/PTLA/EGMC) CDependencyTree::Read(rFile, IDLength); @@ -288,7 +288,7 @@ void CAreaDependencyTree::Read(IInputStream& rFile, EUIDLength IDLength) mLayerOffsets.push_back( rFile.ReadLong() ); } -void CAreaDependencyTree::Write(IOutputStream& rFile, EUIDLength IDLength) const +void CAreaDependencyTree::Write(IOutputStream& rFile, EIDLength IDLength) const { CDependencyTree::Write(rFile, IDLength); rFile.WriteLong(mScriptInstances.size()); diff --git a/src/Core/GameProject/CDependencyTree.h b/src/Core/GameProject/CDependencyTree.h index 23dbd264..9b677db0 100644 --- a/src/Core/GameProject/CDependencyTree.h +++ b/src/Core/GameProject/CDependencyTree.h @@ -4,7 +4,7 @@ #include "CResourceEntry.h" #include #include -#include +#include class CScriptLayer; class CScriptObject; @@ -28,26 +28,26 @@ class IDependencyNode public: virtual ~IDependencyNode() {} virtual EDependencyNodeType Type() const = 0; - virtual void Read(IInputStream& rFile, EUIDLength IDLength) = 0; - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const = 0; + virtual void Read(IInputStream& rFile, EIDLength IDLength) = 0; + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const = 0; }; // Node representing a single resource dependency. class CResourceDependency : public IDependencyNode { - CUniqueID mID; + CAssetID mID; public: CResourceDependency() {} - CResourceDependency(const CUniqueID& rkID) : mID(rkID) {} + CResourceDependency(const CAssetID& rkID) : mID(rkID) {} virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; // Accessors - inline CUniqueID ID() const { return mID; } - inline void SetID(const CUniqueID& rkID) { mID = rkID; } + inline CAssetID ID() const { return mID; } + inline void SetID(const CAssetID& rkID) { mID = rkID; } }; // Node representing a single animset dependency contained in a script object. Indicates which character is being used. @@ -60,8 +60,8 @@ public: CAnimSetDependency() : CResourceDependency(), mUsedChar(-1) {} virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; // Accessors inline u32 UsedChar() const { return mUsedChar; } @@ -75,26 +75,26 @@ public: class CDependencyTree : public IDependencyNode { protected: - CUniqueID mID; + CAssetID mID; std::vector mReferencedResources; public: - CDependencyTree(const CUniqueID& rkID) : mID(rkID) {} + CDependencyTree(const CAssetID& rkID) : mID(rkID) {} ~CDependencyTree(); virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; u32 NumDependencies() const; - bool HasDependency(const CUniqueID& rkID); - CUniqueID DependencyByIndex(u32 Index) const; - void AddDependency(const CUniqueID& rkID); + bool HasDependency(const CAssetID& rkID); + CAssetID DependencyByIndex(u32 Index) const; + void AddDependency(const CAssetID& rkID); void AddDependency(CResource *pRes); // Accessors - inline void SetID(const CUniqueID& rkID) { mID = rkID; } - inline CUniqueID ID() const { return mID; } + inline void SetID(const CAssetID& rkID) { mID = rkID; } + inline CAssetID ID() const { return mID; } }; @@ -105,10 +105,10 @@ protected: std::vector mCharacterOffsets; public: - CAnimSetDependencyTree(const CUniqueID& rkID) : CDependencyTree(rkID) {} + CAnimSetDependencyTree(const CAssetID& rkID) : CDependencyTree(rkID) {} virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; }; // Node representing a script object. Indicates the type of object. @@ -122,9 +122,9 @@ public: ~CScriptInstanceDependencyTree(); virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; - bool HasDependency(const CUniqueID& rkID); + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; + bool HasDependency(const CAssetID& rkID); // Accessors u32 NumDependencies() const { return mDependencies.size(); } @@ -142,12 +142,12 @@ protected: std::vector mLayerOffsets; public: - CAreaDependencyTree(const CUniqueID& rkID) : CDependencyTree(rkID) {} + CAreaDependencyTree(const CAssetID& rkID) : CDependencyTree(rkID) {} ~CAreaDependencyTree(); virtual EDependencyNodeType Type() const; - virtual void Read(IInputStream& rFile, EUIDLength IDLength); - virtual void Write(IOutputStream& rFile, EUIDLength IDLength) const; + virtual void Read(IInputStream& rFile, EIDLength IDLength); + virtual void Write(IOutputStream& rFile, EIDLength IDLength) const; void AddScriptLayer(CScriptLayer *pLayer); }; diff --git a/src/Core/GameProject/CGameExporter.cpp b/src/Core/GameProject/CGameExporter.cpp index 73b3e6fb..ddfd07de 100644 --- a/src/Core/GameProject/CGameExporter.cpp +++ b/src/Core/GameProject/CGameExporter.cpp @@ -50,7 +50,7 @@ bool CGameExporter::Export() return true; } -void CGameExporter::LoadResource(const CUniqueID& rkID, std::vector& rBuffer) +void CGameExporter::LoadResource(const CAssetID& rkID, std::vector& rBuffer) { SResourceInstance *pInst = FindResourceInstance(rkID); if (pInst) LoadResource(*pInst, rBuffer); @@ -168,7 +168,7 @@ void CGameExporter::LoadPaks() { #if LOAD_PAKS SCOPED_TIMER(LoadPaks); - EUIDLength IDLength = (Game() < eCorruptionProto ? e32Bit : e64Bit); + EIDLength IDLength = (Game() < eCorruptionProto ? e32Bit : e64Bit); for (auto It = mPaks.begin(); It != mPaks.end(); It++) { @@ -202,7 +202,7 @@ void CGameExporter::LoadPaks() for (u32 iName = 0; iName < NumNamedResources; iName++) { CFourCC ResType = Pak.ReadLong(); - CUniqueID ResID(Pak, IDLength); + CAssetID ResID(Pak, IDLength); u32 NameLen = Pak.ReadLong(); TString Name = Pak.ReadString(NameLen); pCollection->AddResource(Name, ResID, ResType); @@ -215,7 +215,7 @@ void CGameExporter::LoadPaks() { bool Compressed = (Pak.ReadLong() == 1); CFourCC ResType = Pak.ReadLong(); - CUniqueID ResID(Pak, IDLength); + CAssetID ResID(Pak, IDLength); u32 ResSize = Pak.ReadLong(); u32 ResOffset = Pak.ReadLong(); @@ -263,7 +263,7 @@ void CGameExporter::LoadPaks() { TString Name = Pak.ReadString(); CFourCC ResType = Pak.ReadLong(); - CUniqueID ResID(Pak, IDLength); + CAssetID ResID(Pak, IDLength); pCollection->AddResource(Name, ResID, ResType); SetResourcePath(ResID.ToLongLong(), PakName + L"\\", Name.ToUTF16()); } @@ -279,7 +279,7 @@ void CGameExporter::LoadPaks() { bool Compressed = (Pak.ReadLong() == 1); CFourCC Type = Pak.ReadLong(); - CUniqueID ResID(Pak, IDLength); + CAssetID ResID(Pak, IDLength); u32 Size = Pak.ReadLong(); u32 Offset = DataStart + Pak.ReadLong(); @@ -461,7 +461,7 @@ void CGameExporter::ExportWorlds() TWideString AreaDir = WorldDir + TWideString::FromInt32(iArea, 2, 10) + L"_" + FileUtil::SanitizeName(GameAreaName, true) + L"\\"; FileUtil::CreateDirectory(mCookedDir + AreaDir); - CUniqueID AreaID = pWorld->AreaResourceID(iArea); + CAssetID AreaID = pWorld->AreaResourceID(iArea); SResourceInstance *pInst = FindResourceInstance(AreaID); ASSERT(pInst != nullptr); diff --git a/src/Core/GameProject/CGameExporter.h b/src/Core/GameProject/CGameExporter.h index ffbd7a51..2cfc475c 100644 --- a/src/Core/GameProject/CGameExporter.h +++ b/src/Core/GameProject/CGameExporter.h @@ -3,7 +3,7 @@ #include "CGameProject.h" #include "CResourceStore.h" -#include +#include #include #include #include @@ -30,7 +30,7 @@ class CGameExporter struct SResourceInstance { TWideString PakFile; - CUniqueID ResourceID; + CAssetID ResourceID; CFourCC ResourceType; u32 PakOffset; u32 PakSize; @@ -49,7 +49,7 @@ class CGameExporter public: CGameExporter(const TString& rkInputDir, const TString& rkOutputDir); bool Export(); - void LoadResource(const CUniqueID& rkID, std::vector& rBuffer); + void LoadResource(const CAssetID& rkID, std::vector& rBuffer); protected: void CopyDiscData(); @@ -61,21 +61,21 @@ protected: void ExportResource(SResourceInstance& rRes); // Convenience Functions - inline SResourceInstance* FindResourceInstance(const CUniqueID& rkID) + inline SResourceInstance* FindResourceInstance(const CAssetID& rkID) { u64 IntegralID = rkID.ToLongLong(); auto Found = mResourceMap.find(IntegralID); return (Found == mResourceMap.end() ? nullptr : &Found->second); } - inline SResourcePath* FindResourcePath(const CUniqueID& rkID) + inline SResourcePath* FindResourcePath(const CAssetID& rkID) { u64 IntegralID = rkID.ToLongLong(); auto Found = mResourcePaths.find(IntegralID); return (Found == mResourcePaths.end() ? nullptr : &Found->second); } - inline void SetResourcePath(const CUniqueID& rkID, const TWideString& rkDir, const TWideString& rkName) + inline void SetResourcePath(const CAssetID& rkID, const TWideString& rkDir, const TWideString& rkName) { SetResourcePath(rkID.ToLongLong(), rkDir, rkName); } diff --git a/src/Core/GameProject/CGameProject.cpp b/src/Core/GameProject/CGameProject.cpp index a5306aae..d18fb0dd 100644 --- a/src/Core/GameProject/CGameProject.cpp +++ b/src/Core/GameProject/CGameProject.cpp @@ -127,7 +127,7 @@ void CGameProject::SetActive() } } -void CGameProject::GetWorldList(std::list& rOut) const +void CGameProject::GetWorldList(std::list& rOut) const { for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++) { diff --git a/src/Core/GameProject/CGameProject.h b/src/Core/GameProject/CGameProject.h index 862ff854..cb744553 100644 --- a/src/Core/GameProject/CGameProject.h +++ b/src/Core/GameProject/CGameProject.h @@ -5,7 +5,7 @@ #include "CResourceStore.h" #include "Core/Resource/EGame.h" #include -#include +#include #include #include @@ -47,7 +47,7 @@ public: bool Load(const TWideString& rkPath); void Save(); void SetActive(); - void GetWorldList(std::list& rOut) const; + void GetWorldList(std::list& rOut) const; // Directory Handling inline TWideString ProjectRoot() const { return mProjectRoot; } diff --git a/src/Core/GameProject/CPackage.cpp b/src/Core/GameProject/CPackage.cpp index d55388e3..5b8bf654 100644 --- a/src/Core/GameProject/CPackage.cpp +++ b/src/Core/GameProject/CPackage.cpp @@ -43,7 +43,7 @@ void CPackage::Load() else { - CUniqueID ID = CUniqueID::FromString(pIDElem->GetText()); + CAssetID ID = CAssetID::FromString(pIDElem->GetText()); TString Name = pNameElem->GetText(); CFourCC Type = CFourCC(pTypeElem->GetText()); pCollection->AddResource(Name, ID, Type); diff --git a/src/Core/GameProject/CPackage.h b/src/Core/GameProject/CPackage.h index adde7ca9..8705ba46 100644 --- a/src/Core/GameProject/CPackage.h +++ b/src/Core/GameProject/CPackage.h @@ -1,8 +1,8 @@ #ifndef CPACKAGE #define CPACKAGE +#include #include -#include #include class CGameProject; @@ -10,7 +10,7 @@ class CGameProject; struct SNamedResource { TString Name; - CUniqueID ID; + CAssetID ID; CFourCC Type; }; @@ -27,7 +27,7 @@ public: inline u32 NumResources() const { return mNamedResources.size(); } inline const SNamedResource& ResourceByIndex(u32 Idx) const { return mNamedResources[Idx]; } - inline void AddResource(const TString& rkName, const CUniqueID& rkID, const CFourCC& rkType) + inline void AddResource(const TString& rkName, const CAssetID& rkID, const CFourCC& rkType) { mNamedResources.push_back( SNamedResource { rkName, rkID, rkType } ); } diff --git a/src/Core/GameProject/CResourceEntry.cpp b/src/Core/GameProject/CResourceEntry.cpp index f319f725..71acc990 100644 --- a/src/Core/GameProject/CResourceEntry.cpp +++ b/src/Core/GameProject/CResourceEntry.cpp @@ -25,7 +25,7 @@ #include "Core/Resource/Factory/CTextureDecoder.h" #include "Core/Resource/Factory/CWorldLoader.h" -CResourceEntry::CResourceEntry(CResourceStore *pStore, const CUniqueID& rkID, +CResourceEntry::CResourceEntry(CResourceStore *pStore, const CAssetID& rkID, const TWideString& rkDir, const TWideString& rkFilename, EResType Type, bool Transient /*= false*/) : mpResource(nullptr) diff --git a/src/Core/GameProject/CResourceEntry.h b/src/Core/GameProject/CResourceEntry.h index 5dc2cceb..7815f4c3 100644 --- a/src/Core/GameProject/CResourceEntry.h +++ b/src/Core/GameProject/CResourceEntry.h @@ -3,7 +3,7 @@ #include "CVirtualDirectory.h" #include "Core/Resource/EResType.h" -#include +#include #include #include @@ -26,7 +26,7 @@ class CResourceEntry CResource *mpResource; CResourceStore *mpStore; CDependencyTree *mpDependencies; - CUniqueID mID; + CAssetID mID; EResType mType; EGame mGame; CVirtualDirectory *mpDirectory; @@ -37,7 +37,7 @@ class CResourceEntry mutable TWideString mCachedUppercaseName; // This is used to speed up case-insensitive sorting and filtering. public: - CResourceEntry(CResourceStore *pStore, const CUniqueID& rkID, + CResourceEntry(CResourceStore *pStore, const CAssetID& rkID, const TWideString& rkDir, const TWideString& rkFilename, EResType Type, bool Transient = false); ~CResourceEntry(); @@ -68,7 +68,7 @@ public: inline bool IsLoaded() const { return mpResource != nullptr; } inline CResource* Resource() const { return mpResource; } inline CDependencyTree* Dependencies() const { return mpDependencies; } - inline CUniqueID ID() const { return mID; } + inline CAssetID ID() const { return mID; } inline EGame Game() const { return mGame; } inline CVirtualDirectory* Directory() const { return mpDirectory; } inline TWideString Name() const { return mName; } diff --git a/src/Core/GameProject/CResourceIterator.h b/src/Core/GameProject/CResourceIterator.h index 4ddb72f8..fcbbbd6b 100644 --- a/src/Core/GameProject/CResourceIterator.h +++ b/src/Core/GameProject/CResourceIterator.h @@ -7,7 +7,7 @@ class CResourceIterator { CResourceStore *mpStore; - std::map::iterator mIter; + std::map::iterator mIter; CResourceEntry *mpCurEntry; public: diff --git a/src/Core/GameProject/CResourceStore.cpp b/src/Core/GameProject/CResourceStore.cpp index b3dcdc7f..478ece26 100644 --- a/src/Core/GameProject/CResourceStore.cpp +++ b/src/Core/GameProject/CResourceStore.cpp @@ -56,7 +56,7 @@ void CResourceStore::LoadResourceDatabase(const TString& rkPath) if (pID && pType && pDir && pName) { - CUniqueID ID = CUniqueID::FromString(pID->GetText()); + CAssetID ID = CAssetID::FromString(pID->GetText()); EResType Type = CResource::ResTypeForExtension(pType->GetText()); TWideString FileDir = pDir->GetText(); TWideString FileName = pName->GetText(); @@ -186,7 +186,7 @@ CVirtualDirectory* CResourceStore::GetVirtualDirectory(const TWideString& rkPath else return nullptr; } -CResourceEntry* CResourceStore::FindEntry(const CUniqueID& rkID) const +CResourceEntry* CResourceStore::FindEntry(const CAssetID& rkID) const { if (!rkID.IsValid()) return nullptr; auto Found = mResourceEntries.find(rkID); @@ -194,12 +194,12 @@ CResourceEntry* CResourceStore::FindEntry(const CUniqueID& rkID) const else return Found->second; } -bool CResourceStore::IsResourceRegistered(const CUniqueID& rkID) const +bool CResourceStore::IsResourceRegistered(const CAssetID& rkID) const { return FindEntry(rkID) == nullptr; } -CResourceEntry* CResourceStore::RegisterResource(const CUniqueID& rkID, EResType Type, const TWideString& rkDir, const TWideString& rkFileName) +CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType Type, const TWideString& rkDir, const TWideString& rkFileName) { CResourceEntry *pEntry = FindEntry(rkID); @@ -226,12 +226,12 @@ CResourceEntry* CResourceStore::RegisterResource(const CUniqueID& rkID, EResType CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const TWideString& rkDir /*= L""*/, const TWideString& rkFileName /*= L""*/) { - CResourceEntry *pEntry = new CResourceEntry(this, CUniqueID::RandomID(), rkDir, rkFileName, Type, true); + CResourceEntry *pEntry = new CResourceEntry(this, CAssetID::RandomID(), rkDir, rkFileName, Type, true); mResourceEntries[pEntry->ID()] = pEntry; return pEntry; } -CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const CUniqueID& rkID, const TWideString& rkDir /*=L ""*/, const TWideString& rkFileName /*= L""*/) +CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const CAssetID& rkID, const TWideString& rkDir /*=L ""*/, const TWideString& rkFileName /*= L""*/) { CResourceEntry *pEntry = FindEntry(rkID); @@ -244,7 +244,7 @@ CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const C return pEntry; } -CResource* CResourceStore::LoadResource(const CUniqueID& rkID, const CFourCC& rkType) +CResource* CResourceStore::LoadResource(const CAssetID& rkID, const CFourCC& rkType) { if (!rkID.IsValid()) return nullptr; @@ -305,7 +305,7 @@ CResource* CResourceStore::LoadResource(const TString& rkPath) // Construct ID from string, check if resource is loaded already TWideString Dir = FileUtil::MakeAbsolute(TWideString(rkPath.GetFileDirectory())); TString Name = rkPath.GetFileName(false); - CUniqueID ID = (Name.IsHexString() ? Name.ToInt64() : rkPath.Hash64()); + CAssetID ID = (Name.IsHexString() ? Name.ToInt64() : rkPath.Hash64()); auto Find = mLoadedResources.find(ID); if (Find != mLoadedResources.end()) @@ -350,7 +350,7 @@ void CResourceStore::TrackLoadedResource(CResourceEntry *pEntry) mLoadedResources[pEntry->ID()] = pEntry; } -CFourCC CResourceStore::ResourceTypeByID(const CUniqueID& rkID, const TStringList& rkPossibleTypes) const +CFourCC CResourceStore::ResourceTypeByID(const CAssetID& rkID, const TStringList& rkPossibleTypes) const { if (!rkID.IsValid()) return eInvalidResType; if (rkPossibleTypes.size() == 1) return CFourCC(rkPossibleTypes.front()); @@ -420,7 +420,7 @@ void CResourceStore::DestroyUnreferencedResources() bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry) { - CUniqueID ID = pEntry->ID(); + CAssetID ID = pEntry->ID(); if (pEntry->IsLoaded()) { diff --git a/src/Core/GameProject/CResourceStore.h b/src/Core/GameProject/CResourceStore.h index 87c3be26..64e43ace 100644 --- a/src/Core/GameProject/CResourceStore.h +++ b/src/Core/GameProject/CResourceStore.h @@ -3,8 +3,8 @@ #include "CVirtualDirectory.h" #include "Core/Resource/EResType.h" +#include #include -#include #include #include #include @@ -21,8 +21,8 @@ class CResourceStore CGameProject *mpProj; CVirtualDirectory *mpProjectRoot; std::vector mTransientRoots; - std::map mResourceEntries; - std::map mLoadedResources; + std::map mResourceEntries; + std::map mLoadedResources; // Directory to look for transient resources in TWideString mTransientLoadDir; @@ -48,16 +48,16 @@ public: void CloseActiveProject(); CVirtualDirectory* GetVirtualDirectory(const TWideString& rkPath, bool Transient, bool AllowCreate); - bool IsResourceRegistered(const CUniqueID& rkID) const; - CResourceEntry* RegisterResource(const CUniqueID& rkID, EResType Type, const TWideString& rkDir, const TWideString& rkFileName); - CResourceEntry* FindEntry(const CUniqueID& rkID) const; + bool IsResourceRegistered(const CAssetID& rkID) const; + CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TWideString& rkDir, const TWideString& rkFileName); + CResourceEntry* FindEntry(const CAssetID& rkID) const; CResourceEntry* RegisterTransientResource(EResType Type, const TWideString& rkDir = L"", const TWideString& rkFileName = L""); - CResourceEntry* RegisterTransientResource(EResType Type, const CUniqueID& rkID, const TWideString& rkDir = L"", const TWideString& rkFileName = L""); + CResourceEntry* RegisterTransientResource(EResType Type, const CAssetID& rkID, const TWideString& rkDir = L"", const TWideString& rkFileName = L""); - CResource* LoadResource(const CUniqueID& rkID, const CFourCC& rkType); + CResource* LoadResource(const CAssetID& rkID, const CFourCC& rkType); CResource* LoadResource(const TString& rkPath); void TrackLoadedResource(CResourceEntry *pEntry); - CFourCC ResourceTypeByID(const CUniqueID& rkID, const TStringList& rkPossibleTypes) const; + CFourCC ResourceTypeByID(const CAssetID& rkID, const TStringList& rkPossibleTypes) const; void DestroyUnreferencedResources(); bool DeleteResourceEntry(CResourceEntry *pEntry); void SetTransientLoadDir(const TString& rkDir); diff --git a/src/Core/Resource/Area/CGameArea.cpp b/src/Core/Resource/Area/CGameArea.cpp index 66a54bb3..fcd48b5e 100644 --- a/src/Core/Resource/Area/CGameArea.cpp +++ b/src/Core/Resource/Area/CGameArea.cpp @@ -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++) { diff --git a/src/Core/Resource/CAnimationParameters.cpp b/src/Core/Resource/CAnimationParameters.cpp index bdc9ed70..bcdf5a01 100644 --- a/src/Core/Resource/CAnimationParameters.cpp +++ b/src/Core/Resource/CAnimationParameters.cpp @@ -106,7 +106,7 @@ void CAnimationParameters::Write(IOutputStream& rSCLY) else { - rSCLY.WriteLongLong(CUniqueID::skInvalidID64.ToLongLong()); + rSCLY.WriteLongLong(CAssetID::skInvalidID64.ToLongLong()); rSCLY.WriteLong(0xFFFFFFFF); } } diff --git a/src/Core/Resource/CAnimationParameters.h b/src/Core/Resource/CAnimationParameters.h index daa88aaa..ec581412 100644 --- a/src/Core/Resource/CAnimationParameters.h +++ b/src/Core/Resource/CAnimationParameters.h @@ -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; } diff --git a/src/Core/Resource/CDependencyGroup.h b/src/Core/Resource/CDependencyGroup.h index 5a646dbf..1ee57030 100644 --- a/src/Core/Resource/CDependencyGroup.h +++ b/src/Core/Resource/CDependencyGroup.h @@ -6,21 +6,21 @@ class CDependencyGroup : public CResource { DECLARE_RESOURCE_TYPE(eDependencyGroup) - std::set mDependencies; + std::set 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); diff --git a/src/Core/Resource/CFont.cpp b/src/Core/Resource/CFont.cpp index 7372fe92..2c2a89df 100644 --- a/src/Core/Resource/CFont.cpp +++ b/src/Core/Resource/CFont.cpp @@ -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; } diff --git a/src/Core/Resource/CResource.h b/src/Core/Resource/CResource.h index 78e7a254..1d658e80 100644 --- a/src/Core/Resource/CResource.h +++ b/src/Core/Resource/CResource.h @@ -5,8 +5,8 @@ #include "Core/GameProject/CDependencyTree.h" #include "Core/GameProject/CResourceEntry.h" #include "Core/GameProject/CResourceStore.h" +#include #include -#include #include #include @@ -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); } diff --git a/src/Core/Resource/CResourceInfo.h b/src/Core/Resource/CResourceInfo.h index 15aef92f..019b333e 100644 --- a/src/Core/Resource/CResourceInfo.h +++ b/src/Core/Resource/CResourceInfo.h @@ -3,7 +3,7 @@ #include "CResource.h" #include "Core/GameProject/CResourceStore.h" -#include +#include #include #include @@ -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; } } diff --git a/src/Core/Resource/CScan.h b/src/Core/Resource/CScan.h index 391b9ab3..55b7918b 100644 --- a/src/Core/Resource/CScan.h +++ b/src/Core/Resource/CScan.h @@ -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; diff --git a/src/Core/Resource/CWorld.cpp b/src/Core/Resource/CWorld.cpp index 66a32aa5..3edd6ad8 100644 --- a/src/Core/Resource/CWorld.cpp +++ b/src/Core/Resource/CWorld.cpp @@ -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++) { diff --git a/src/Core/Resource/Cooker/CMaterialCooker.cpp b/src/Core/Resource/Cooker/CMaterialCooker.cpp index d1d5b38e..4efb133a 100644 --- a/src/Core/Resource/Cooker/CMaterialCooker.cpp +++ b/src/Core/Resource/Cooker/CMaterialCooker.cpp @@ -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++) { diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index e9e8fe61..2e8b9bd5 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -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"); } diff --git a/src/Core/Resource/Factory/CDependencyGroupLoader.cpp b/src/Core/Resource/Factory/CDependencyGroupLoader.cpp index c94afa4e..80e4a0e5 100644 --- a/src/Core/Resource/Factory/CDependencyGroupLoader.cpp +++ b/src/Core/Resource/Factory/CDependencyGroupLoader.cpp @@ -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); } diff --git a/src/Core/Resource/Factory/CScriptLoader.cpp b/src/Core/Resource/Factory/CScriptLoader.cpp index a1b59422..5df4b332 100644 --- a/src/Core/Resource/Factory/CScriptLoader.cpp +++ b/src/Core/Resource/Factory/CScriptLoader.cpp @@ -110,7 +110,7 @@ void CScriptLoader::ReadProperty(IProperty *pProp, u32 Size, IInputStream& rSCLY { TFileProperty *pFileCast = static_cast(pProp); - CUniqueID ResID = (mVersion < eCorruptionProto ? rSCLY.ReadLong() : rSCLY.ReadLongLong()); + CAssetID ResID = (mVersion < eCorruptionProto ? rSCLY.ReadLong() : rSCLY.ReadLongLong()); const TStringList& rkExtensions = static_cast(pTemp)->Extensions(); CResourceInfo Info(ResID, CFourCC(!rkExtensions.empty() ? rkExtensions.front() : "UNKN")); diff --git a/src/Core/Resource/Model/CModel.cpp b/src/Core/Resource/Model/CModel.cpp index a8d29533..09fb00ef 100644 --- a/src/Core/Resource/Model/CModel.cpp +++ b/src/Core/Resource/Model/CModel.cpp @@ -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++) { diff --git a/src/Editor/CNodeCopyMimeData.h b/src/Editor/CNodeCopyMimeData.h index 26883020..c4fe0490 100644 --- a/src/Editor/CNodeCopyMimeData.h +++ b/src/Editor/CNodeCopyMimeData.h @@ -30,7 +30,7 @@ public: private: CWorldEditor *mpEditor; - CUniqueID mAreaID; + CAssetID mAreaID; QVector mCopiedNodes; EGame mGame; @@ -45,7 +45,7 @@ public: CNodeCopyMimeData(CWorldEditor *pEditor) : mpEditor(pEditor) - , mAreaID(pEditor->ActiveArea()->ResID()) + , mAreaID(pEditor->ActiveArea()->ID()) , mGame(pEditor->CurrentGame()) { CNodeSelection *pSelection = pEditor->Selection(); @@ -100,7 +100,7 @@ public: return -1; } - CUniqueID AreaID() const { return mAreaID; } + CAssetID AreaID() const { return mAreaID; } EGame Game() const { return mGame; } const QVector& CopiedNodes() const { return mCopiedNodes; } }; diff --git a/src/Editor/CProjectOverviewDialog.cpp b/src/Editor/CProjectOverviewDialog.cpp index 21338cec..b6e99b6f 100644 --- a/src/Editor/CProjectOverviewDialog.cpp +++ b/src/Editor/CProjectOverviewDialog.cpp @@ -89,14 +89,14 @@ void CProjectOverviewDialog::SetupWorldsList() { ASSERT(mpProject != nullptr && mpProject->IsActive()); - std::list WorldIDs; + std::list WorldIDs; mpProject->GetWorldList(WorldIDs); mWorldEntries.clear(); mpUI->WorldsList->clear(); for (auto It = WorldIDs.begin(); It != WorldIDs.end(); It++) { - CUniqueID ID = *It; + CAssetID ID = *It; CResourceEntry *pEntry = gpResourceStore->FindEntry(ID); if (!pEntry) diff --git a/src/Editor/CStartWindow.cpp b/src/Editor/CStartWindow.cpp index a58fa62b..1782ee20 100644 --- a/src/Editor/CStartWindow.cpp +++ b/src/Editor/CStartWindow.cpp @@ -192,7 +192,7 @@ void CStartWindow::on_LaunchWorldEditorButton_clicked() { Log::ClearErrorLog(); - CUniqueID AreaID = mpWorld->AreaResourceID(mSelectedAreaIndex); + CAssetID AreaID = mpWorld->AreaResourceID(mSelectedAreaIndex); TString AreaPath = mpWorld->Entry()->CookedAssetPath().GetFileDirectory() + AreaID.ToString() + ".MREA"; TResPtr pArea = gpResourceStore->LoadResource(AreaPath); diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index 3442d0ff..0955d788 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -104,7 +104,7 @@ void CPasteNodesCommand::redo() pLink->SetReceiver(pNewTarget->InstanceID()); } - else if (mpMimeData->AreaID() != pArea->ResID() || pArea->InstanceByID(pLink->ReceiverID()) == nullptr) + else if (mpMimeData->AreaID() != pArea->ID() || pArea->InstanceByID(pLink->ReceiverID()) == nullptr) { CScriptObject *pSender = pLink->Sender(); CScriptObject *pReceiver = pLink->Receiver();