From f72f82d519de2a7d0a1b95e56b6d391bdade2f9f Mon Sep 17 00:00:00 2001 From: Aruki Date: Sun, 7 May 2017 20:29:33 -0600 Subject: [PATCH] Dropped support for transient resources; I am not using this functionality at all whatsoever and likely won't for a while, so why do I have it? --- src/Common/CAssetID.cpp | 5 - src/Common/CAssetID.h | 2 - src/Core/CAreaAttributes.cpp | 4 +- src/Core/CAudioManager.cpp | 4 +- src/Core/GameProject/AssetNameGeneration.cpp | 2 +- src/Core/GameProject/CGameExporter.cpp | 43 ++- src/Core/GameProject/CResourceEntry.cpp | 53 +--- src/Core/GameProject/CResourceEntry.h | 7 +- src/Core/GameProject/CResourceStore.cpp | 266 +++++------------- src/Core/GameProject/CResourceStore.h | 11 +- .../GameProject/DependencyListBuilders.cpp | 2 +- src/Core/Resource/Animation/CAnimSet.h | 2 +- .../Resource/Animation/CAnimationParameters.h | 2 +- src/Core/Resource/Animation/IMetaAnimation.h | 2 +- src/Core/Resource/CResource.h | 5 + src/Core/Resource/Cooker/CWorldCooker.cpp | 2 +- src/Core/Resource/Factory/CAnimSetLoader.cpp | 16 +- .../Resource/Factory/CAnimationLoader.cpp | 4 +- src/Core/Resource/Factory/CAreaLoader.cpp | 2 +- src/Core/Resource/Factory/CFontLoader.cpp | 4 +- src/Core/Resource/Factory/CMaterialLoader.cpp | 4 +- src/Core/Resource/Factory/CScanLoader.cpp | 6 +- src/Core/Resource/Factory/CWorldLoader.cpp | 26 +- src/Core/Resource/Script/CScriptTemplate.cpp | 2 +- src/Core/Scene/CScriptAttachNode.cpp | 2 +- .../ScriptExtra/CDamageableTriggerExtra.cpp | 2 +- src/Core/ScriptExtra/CDoorExtra.cpp | 2 +- .../ScriptExtra/CPointOfInterestExtra.cpp | 2 +- src/Editor/WorldEditor/CWorldEditor.cpp | 2 +- 29 files changed, 156 insertions(+), 330 deletions(-) diff --git a/src/Common/CAssetID.cpp b/src/Common/CAssetID.cpp index 3af213a9..a82f21be 100644 --- a/src/Common/CAssetID.cpp +++ b/src/Common/CAssetID.cpp @@ -33,11 +33,6 @@ CAssetID::CAssetID(u64 ID, EIDLength Length) mID &= 0xFFFFFFFF; } -CAssetID::CAssetID(const char* pkID) -{ - *this = CAssetID::FromString(pkID); -} - void CAssetID::Write(IOutputStream& rOutput) const { if (mLength == e32Bit) diff --git a/src/Common/CAssetID.h b/src/Common/CAssetID.h index 652683b9..107efbf6 100644 --- a/src/Common/CAssetID.h +++ b/src/Common/CAssetID.h @@ -22,7 +22,6 @@ public: CAssetID(); CAssetID(u64 ID); CAssetID(u64 ID, EIDLength Length); - CAssetID(const char* pkID); CAssetID(IInputStream& rInput, EIDLength Length); CAssetID(IInputStream& rInput, EGame Game); void Write(IOutputStream& rOutput) const; @@ -31,7 +30,6 @@ public: // 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 mLength >= rkOther.mLength && mID > rkOther.mID; } diff --git a/src/Core/CAreaAttributes.cpp b/src/Core/CAreaAttributes.cpp index 8df21edf..21069c3e 100644 --- a/src/Core/CAreaAttributes.cpp +++ b/src/Core/CAreaAttributes.cpp @@ -47,13 +47,13 @@ CModel* CAreaAttributes::SkyModel() const switch (mGame) { case ePrime: - return (CModel*) gpResourceStore->LoadResource( static_cast(pBaseStruct->PropertyByIndex(7))->Get(), "CMDL" ); + return gpResourceStore->LoadResource( static_cast(pBaseStruct->PropertyByIndex(7))->Get() ); case eEchoesDemo: case eEchoes: case eCorruptionProto: case eCorruption: case eReturns: - return (CModel*) gpResourceStore->LoadResource( static_cast(pBaseStruct->PropertyByID(0xD208C9FA))->Get(), "CMDL" ); + return gpResourceStore->LoadResource( static_cast(pBaseStruct->PropertyByID(0xD208C9FA))->Get() ); default: return nullptr; } diff --git a/src/Core/CAudioManager.cpp b/src/Core/CAudioManager.cpp index 2239dde3..00dae23b 100644 --- a/src/Core/CAudioManager.cpp +++ b/src/Core/CAudioManager.cpp @@ -45,14 +45,14 @@ void CAudioManager::LoadAssets() CAssetID AudioLookupID = mpProject->FindNamedResource(AudioLookupName); if (AudioLookupID.IsValid()) - mpAudioLookupTable = mpProject->ResourceStore()->LoadResource(AudioLookupID, "ATBL"); + mpAudioLookupTable = mpProject->ResourceStore()->LoadResource(AudioLookupID); if (mpProject->Game() >= eEchoesDemo) { CAssetID SfxNameListID = mpProject->FindNamedResource("audio_name_lookup_STLC"); if (SfxNameListID.IsValid()) - mpSfxNameList = mpProject->ResourceStore()->LoadResource(SfxNameListID, "STLC"); + mpSfxNameList = mpProject->ResourceStore()->LoadResource(SfxNameListID); } } diff --git a/src/Core/GameProject/AssetNameGeneration.cpp b/src/Core/GameProject/AssetNameGeneration.cpp index 6fe65d58..d5b69984 100644 --- a/src/Core/GameProject/AssetNameGeneration.cpp +++ b/src/Core/GameProject/AssetNameGeneration.cpp @@ -32,7 +32,7 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr if (pEntry->Game() >= eCorruptionProto) SanitizedDir = SanitizedDir.ToLower(); - CVirtualDirectory *pNewDir = pEntry->ResourceStore()->GetVirtualDirectory(SanitizedDir, false, true); + CVirtualDirectory *pNewDir = pEntry->ResourceStore()->GetVirtualDirectory(SanitizedDir, true); if (pEntry->Directory() == pNewDir && pEntry->Name() == SanitizedName) return; TString Name = SanitizedName; diff --git a/src/Core/GameProject/CGameExporter.cpp b/src/Core/GameProject/CGameExporter.cpp index 0ac296e2..6bcbd50b 100644 --- a/src/Core/GameProject/CGameExporter.cpp +++ b/src/Core/GameProject/CGameExporter.cpp @@ -468,35 +468,32 @@ void CGameExporter::ExportResourceEditorData() // should really be doing this by dependency order instead of by ID order. for (CResourceIterator It(mpStore); It; ++It) { - if (!It->IsTransient()) + // Worlds need some info we can only get from the pak at export time; namely, which areas can + // have duplicates, as well as the world's internal name. + if (It->ResourceType() == eWorld) { - // Worlds need some info we can only get from the pak at export time; namely, which areas can - // have duplicates, as well as the world's internal name. - if (It->ResourceType() == eWorld) + CWorld *pWorld = (CWorld*) It->Load(); + + // Set area duplicate flags + for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) { - CWorld *pWorld = (CWorld*) It->Load(); + CAssetID AreaID = pWorld->AreaResourceID(iArea); + auto Find = mAreaDuplicateMap.find(AreaID); - // Set area duplicate flags - for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++) - { - CAssetID AreaID = pWorld->AreaResourceID(iArea); - auto Find = mAreaDuplicateMap.find(AreaID); - - if (Find != mAreaDuplicateMap.end()) - pWorld->SetAreaAllowsPakDuplicates(iArea, Find->second); - } - - // Set world name - TString WorldName = MakeWorldName(pWorld->ID()); - pWorld->SetName(WorldName); + if (Find != mAreaDuplicateMap.end()) + pWorld->SetAreaAllowsPakDuplicates(iArea, Find->second); } - // Save raw resource + generate dependencies - if (It->TypeInfo()->CanBeSerialized()) - It->Save(true); - else - It->UpdateDependencies(); + // Set world name + TString WorldName = MakeWorldName(pWorld->ID()); + pWorld->SetName(WorldName); } + + // Save raw resource + generate dependencies + if (It->TypeInfo()->CanBeSerialized()) + It->Save(true); + else + It->UpdateDependencies(); } } { diff --git a/src/Core/GameProject/CResourceEntry.cpp b/src/Core/GameProject/CResourceEntry.cpp index d1bc4939..8d94904a 100644 --- a/src/Core/GameProject/CResourceEntry.cpp +++ b/src/Core/GameProject/CResourceEntry.cpp @@ -12,7 +12,7 @@ CResourceEntry::CResourceEntry(CResourceStore *pStore, const CAssetID& rkID, const TString& rkDir, const TString& rkFilename, - EResType Type, bool Transient /*= false*/) + EResType Type) : mpResource(nullptr) , mpStore(pStore) , mpDependencies(nullptr) @@ -25,9 +25,7 @@ CResourceEntry::CResourceEntry(CResourceStore *pStore, const CAssetID& rkID, mpTypeInfo = CResTypeInfo::FindTypeInfo(Type); ASSERT(mpTypeInfo); - if (Transient) mFlags |= eREF_Transient; - - mpDirectory = mpStore->GetVirtualDirectory(rkDir, Transient, true); + mpDirectory = mpStore->GetVirtualDirectory(rkDir, true); if (mpDirectory) mpDirectory->AddChild("", this); } @@ -39,8 +37,6 @@ CResourceEntry::~CResourceEntry() void CResourceEntry::SerializeCacheData(IArchive& rArc) { - ASSERT(!IsTransient()); - u32 Flags = mFlags & eREF_SavedFlags; rArc << SERIAL_AUTO(Flags); if (rArc.IsReader()) mFlags = Flags & eREF_SavedFlags; @@ -99,7 +95,7 @@ TString CResourceEntry::RawAssetPath(bool Relative) const TString Ext = RawExtension(); TString Path = mpDirectory ? mpDirectory->FullPath() : ""; TString Name = mName + "." + Ext; - return ((IsTransient() || Relative) ? Path + Name : mpStore->RawDir(false) + Path + Name); + return Relative ? Path + Name : mpStore->RawDir(false) + Path + Name; } TString CResourceEntry::RawExtension() const @@ -112,7 +108,7 @@ TString CResourceEntry::CookedAssetPath(bool Relative) const TString Ext = CookedExtension().ToString(); TString Path = mpDirectory ? mpDirectory->FullPath() : ""; TString Name = mName + "." + Ext; - return ((IsTransient() || Relative) ? Path + Name : mpStore->CookedDir(false) + Path + Name); + return Relative ? Path + Name : mpStore->CookedDir(false) + Path + Name; } CFourCC CResourceEntry::CookedExtension() const @@ -267,11 +263,12 @@ bool CResourceEntry::Cook() CResource* CResourceEntry::Load() { + // If the asset is already loaded then just return it immediately + if (mpResource) return mpResource; + // Always try to load raw version as the raw version contains extra editor-only data. // If there is no raw version (which will be the case for resource types that don't // support serialization yet) then load the cooked version as a backup. - if (mpResource) return mpResource; - if (HasRawVersion()) { mpResource = CResourceFactory::SpawnResource(this); @@ -353,14 +350,11 @@ bool CResourceEntry::Unload() bool CResourceEntry::CanMoveTo(const TString& rkDir, const TString& rkName) { - // Transient resources can't be moved - if (IsTransient()) return false; - // Validate that the path/name are valid if (!mpStore->IsValidResourcePath(rkDir, rkName)) return false; // We need to validate the path isn't taken already - either the directory doesn't exist, or doesn't have a resource by this name - CVirtualDirectory *pDir = mpStore->GetVirtualDirectory(rkDir, false, false); + CVirtualDirectory *pDir = mpStore->GetVirtualDirectory(rkDir, false); if (pDir && pDir->FindChildResource(rkName, ResourceType())) return false; // All checks are true @@ -378,7 +372,7 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName) TString OldRawPath = RawAssetPath(); // Set new directory and name - CVirtualDirectory *pNewDir = mpStore->GetVirtualDirectory(rkDir, IsTransient(), true); + CVirtualDirectory *pNewDir = mpStore->GetVirtualDirectory(rkDir, true); if (pNewDir == mpDirectory && rkName == mName) return false; // Check if we can legally move to this spot @@ -459,35 +453,6 @@ bool CResourceEntry::Move(const TString& rkDir, const TString& rkName) } } -void CResourceEntry::AddToProject(const TString& rkDir, const TString& rkName) -{ - if (mFlags.HasFlag(eREF_Transient)) - { - mFlags.ClearFlag(eREF_Transient); - Move(rkDir, rkName); - } - - else - { - Log::Error("AddToProject called on non-transient resource entry: " + CookedAssetPath(true)); - } -} - -void CResourceEntry::RemoveFromProject() -{ - if (!mFlags.HasFlag(eREF_Transient)) - { - TString Dir = CookedAssetPath().GetFileDirectory(); - mFlags.SetFlag(eREF_Transient); - Move(Dir, mName); - } - - else - { - Log::Error("RemoveFromProject called on transient resource entry: " + CookedAssetPath(true)); - } -} - CGameProject* CResourceEntry::Project() const { return mpStore ? mpStore->Project() : nullptr; diff --git a/src/Core/GameProject/CResourceEntry.h b/src/Core/GameProject/CResourceEntry.h index 6f87a436..d91a7eed 100644 --- a/src/Core/GameProject/CResourceEntry.h +++ b/src/Core/GameProject/CResourceEntry.h @@ -17,7 +17,7 @@ class CDependencyTree; enum EResEntryFlag { eREF_NeedsRecook = 0x00000001, // Resource has been updated but not recooked - eREF_Transient = 0x00000002, // Resource is transient (not part of a game project resource DB) + // UNUSED = 0x00000002, eREF_Hidden = 0x00000004, // Resource is hidden, doesn't show up in resource browser eREF_HasBeenModified = 0x00000008, // Resource has been modified and resaved by the user eREF_IsUserResource = 0x00000010, // Resource was created by the user (i.e. isn't a Retro Studios asset) @@ -43,7 +43,7 @@ class CResourceEntry public: CResourceEntry(CResourceStore *pStore, const CAssetID& rkID, const TString& rkDir, const TString& rkFilename, - EResType Type, bool Transient = false); + EResType Type); ~CResourceEntry(); void SerializeCacheData(IArchive& rArc); @@ -65,8 +65,6 @@ public: bool Unload(); bool CanMoveTo(const TString& rkDir, const TString& rkName); bool Move(const TString& rkDir, const TString& rkName); - void AddToProject(const TString& rkDir, const TString& rkName); - void RemoveFromProject(); CGameProject* Project() const; EGame Game() const; @@ -87,7 +85,6 @@ public: inline TString Name() const { return mName; } inline const TString& UppercaseName() const { return mCachedUppercaseName; } inline EResType ResourceType() const { return mpTypeInfo->Type(); } - inline bool IsTransient() const { return mFlags.HasFlag(eREF_Transient); } inline bool IsHidden() const { return mFlags.HasFlag(eREF_Hidden); } protected: diff --git a/src/Core/GameProject/CResourceStore.cpp b/src/Core/GameProject/CResourceStore.cpp index 846cabfc..590e9d0e 100644 --- a/src/Core/GameProject/CResourceStore.cpp +++ b/src/Core/GameProject/CResourceStore.cpp @@ -56,9 +56,6 @@ CResourceStore::~CResourceStore() for (auto It = mResourceEntries.begin(); It != mResourceEntries.end(); It++) delete It->second; - - for (auto It = mTransientRoots.begin(); It != mTransientRoots.end(); It++) - delete *It; } void CResourceStore::SerializeResourceDatabase(IArchive& rArc) @@ -83,10 +80,7 @@ void CResourceStore::SerializeResourceDatabase(IArchive& rArc) Resources.reserve(mResourceEntries.size()); for (CResourceIterator It(this); It; ++It) - { - if (!It->IsTransient()) - Resources.push_back( SDatabaseResource { It->ID(), It->TypeInfo(), It->Directory()->FullPath(), It->Name() } ); - } + Resources.push_back( SDatabaseResource { It->ID(), It->TypeInfo(), It->Directory()->FullPath(), It->Name() } ); } // Serialize @@ -175,7 +169,7 @@ bool CResourceStore::LoadCacheFile() CResourceEntry *pEntry = FindEntry(ID); - if (pEntry && !pEntry->IsTransient()) + if (pEntry) { CBasicBinaryReader Reader(&CacheFile, Version); @@ -215,26 +209,23 @@ bool CResourceStore::SaveCacheFile() // Structure: Entry Asset ID -> Entry Cache Size -> Serialized Entry Cache Data for (CResourceIterator It(this); It; ++It) { - if (!It->IsTransient()) + ResCount++; + It->ID().Write(CacheFile); + u32 SizeOffset = CacheFile.Tell(); + CacheFile.WriteLong(0); + + CBasicBinaryWriter Writer(&CacheFile, Version.FileVersion(), Version.Game()); + + if (Writer.ParamBegin("EntryCache")) { - ResCount++; - It->ID().Write(CacheFile); - u32 SizeOffset = CacheFile.Tell(); - CacheFile.WriteLong(0); - - CBasicBinaryWriter Writer(&CacheFile, Version.FileVersion(), Version.Game()); - - if (Writer.ParamBegin("EntryCache")) - { - It->SerializeCacheData(Writer); - Writer.ParamEnd(); - } - - u32 EntryCacheEnd = CacheFile.Tell(); - CacheFile.Seek(SizeOffset, SEEK_SET); - CacheFile.WriteLong(EntryCacheEnd - SizeOffset - 4); - CacheFile.Seek(EntryCacheEnd, SEEK_SET); + It->SerializeCacheData(Writer); + Writer.ParamEnd(); } + + u32 EntryCacheEnd = CacheFile.Tell(); + CacheFile.Seek(SizeOffset, SEEK_SET); + CacheFile.WriteLong(EntryCacheEnd - SizeOffset - 4); + CacheFile.Seek(EntryCacheEnd, SEEK_SET); } CacheFile.Seek(ResCountOffset, SEEK_SET); @@ -294,16 +285,8 @@ void CResourceStore::CloseProject() while (It != mResourceEntries.end()) { - CResourceEntry *pEntry = It->second; - - if (!pEntry->IsTransient()) - { - delete pEntry; - It = mResourceEntries.erase(It); - } - - else - It++; + delete It->second; + It = mResourceEntries.erase(It); } delete mpDatabaseRoot; @@ -312,34 +295,14 @@ void CResourceStore::CloseProject() mGame = eUnknownGame; } -CVirtualDirectory* CResourceStore::GetVirtualDirectory(const TString& rkPath, bool Transient, bool AllowCreate) +CVirtualDirectory* CResourceStore::GetVirtualDirectory(const TString& rkPath, bool AllowCreate) { - if (rkPath.IsEmpty()) return mpDatabaseRoot; - - else if (Transient) - { - for (u32 iTrans = 0; iTrans < mTransientRoots.size(); iTrans++) - { - if (mTransientRoots[iTrans]->Name() == rkPath) - return mTransientRoots[iTrans]; - } - - if (AllowCreate) - { - CVirtualDirectory *pDir = new CVirtualDirectory(rkPath, this); - mTransientRoots.push_back(pDir); - return pDir; - } - - else return nullptr; - } - + if (rkPath.IsEmpty()) + return mpDatabaseRoot; else if (mpDatabaseRoot) - { return mpDatabaseRoot->FindChildDirectory(rkPath, AllowCreate); - } - - else return nullptr; + else + return nullptr; } void CResourceStore::ConditionalDeleteDirectory(CVirtualDirectory *pDir) @@ -382,16 +345,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType CResourceEntry *pEntry = FindEntry(rkID); if (pEntry) - { - if (pEntry->IsTransient()) - { - ASSERT(pEntry->ResourceType() == Type); - pEntry->AddToProject(rkDir, rkName); - } - - else - Log::Error("Attempted to register resource that's already tracked in the database: " + rkID.ToString() + " / " + rkDir + " / " + rkName); - } + Log::Error("Attempted to register resource that's already tracked in the database: " + rkID.ToString() + " / " + rkDir + " / " + rkName); else { @@ -409,133 +363,74 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType return pEntry; } -CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const TString& rkDir /*= ""*/, const TString& rkFileName /*= ""*/) -{ - CResourceEntry *pEntry = new CResourceEntry(this, CAssetID::RandomID(), rkDir, rkFileName, Type, true); - mResourceEntries[pEntry->ID()] = pEntry; - return pEntry; -} - -CResourceEntry* CResourceStore::RegisterTransientResource(EResType Type, const CAssetID& rkID, const TString& rkDir /*=L ""*/, const TString& rkFileName /*= ""*/) -{ - CResourceEntry *pEntry = FindEntry(rkID); - - if (!pEntry) - { - pEntry = new CResourceEntry(this, rkID, rkDir, rkFileName, Type, true); - mResourceEntries[rkID] = pEntry; - } - - return pEntry; -} - -CResource* CResourceStore::LoadResource(const CAssetID& rkID, const CFourCC& rkType) +CResource* CResourceStore::LoadResource(const CAssetID& rkID) { if (!rkID.IsValid()) return nullptr; - // Check if resource is already loaded - auto Find = mLoadedResources.find(rkID); - if (Find != mLoadedResources.end()) - return Find->second->Resource(); - - // Check for resource in store CResourceEntry *pEntry = FindEntry(rkID); - if (pEntry) return pEntry->Load(); - // Check in transient load directory - this only works for cooked - EResType Type = CResTypeInfo::TypeForCookedExtension(mGame, rkType)->Type(); - - if (Type != eInvalidResType) - { - // Note the entry may not be able to find the resource on its own (due to not knowing what game - // it is) so we will attempt to open the file stream ourselves and pass it to the entry instead. - TString Name = rkID.ToString(); - CResourceEntry *pEntry = RegisterTransientResource(Type, mTransientLoadDir, Name); - - TString Path = mTransientLoadDir + Name + "." + rkType.ToString(); - CFileInStream File(Path, IOUtil::eBigEndian); - CResource *pRes = pEntry->LoadCooked(File); - - if (!pRes) DeleteResourceEntry(pEntry); - return pRes; - } + if (pEntry) + return pEntry->Load(); else { - Log::Error("Can't load requested resource with ID \"" + rkID.ToString() + "\"; can't locate resource. Note: Loading raw assets from an arbitrary directory is unsupported.");; + // Resource doesn't seem to exist + Log::Error("Can't find requested resource with ID \"" + rkID.ToString() + "\".");; return nullptr; } } +CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type) +{ + CResource *pRes = LoadResource(rkID); + + if (pRes) + { + if (pRes->Type() == Type) + { + return pRes; + } + else + { + CResTypeInfo *pExpectedType = CResTypeInfo::FindTypeInfo(Type); + CResTypeInfo *pGotType = pRes->TypeInfo(); + ASSERT(pExpectedType && pGotType); + + Log::Error("Resource with ID \"" + rkID.ToString() + "\" requested with the wrong type; expected " + pExpectedType->TypeName() + " asset, got " + pGotType->TypeName() + " asset"); + return nullptr; + } + } + + else + return nullptr; +} + CResource* CResourceStore::LoadResource(const TString& rkPath) { // If this is a relative path then load via the resource DB - if (!FileUtil::IsAbsolute(rkPath)) + CResourceEntry *pEntry = FindEntry(rkPath); + + if (pEntry) { - CResourceEntry *pEntry = FindEntry(rkPath); + // Verify extension matches the entry + load resource + TString Ext = rkPath.GetFileExtension(); - if (pEntry) + if (!Ext.IsEmpty()) { - // Verify extension matches the entry + load resource - TString Ext = rkPath.GetFileExtension(); - - if (!Ext.IsEmpty()) + if (Ext.Length() == 4) { - if (Ext.Length() == 4) - { - ASSERT(Ext.CaseInsensitiveCompare(pEntry->CookedExtension().ToString())); - } - else - { - ASSERT(Ext.CaseInsensitiveCompare(pEntry->RawExtension())); - } + ASSERT(Ext.CaseInsensitiveCompare(pEntry->CookedExtension().ToString())); + } + else + { + ASSERT(Ext.CaseInsensitiveCompare(pEntry->RawExtension())); } - - return pEntry->Load(); } - else return nullptr; + return pEntry->Load(); } - // Otherwise create transient entry; construct ID from string, check if resource is loaded already - TString Dir = FileUtil::MakeAbsolute(rkPath.GetFileDirectory()); - TString Name = rkPath.GetFileName(false); - CAssetID ID = (Name.IsHexString() ? Name.ToInt64() : rkPath.Hash64()); - auto Find = mLoadedResources.find(ID); - - if (Find != mLoadedResources.end()) - return Find->second->Resource(); - - // Determine type - TString Extension = rkPath.GetFileExtension().ToUpper(); - EResType Type = CResTypeInfo::TypeForCookedExtension(mGame, Extension)->Type(); - - if (Type == eInvalidResType) - { - Log::Error("Unable to load resource " + rkPath + "; unrecognized extension: " + Extension); - return nullptr; - } - - // Open file - CFileInStream File(rkPath, IOUtil::eBigEndian); - - if (!File.IsValid()) - { - Log::Error("Unable to load resource; couldn't open file: " + rkPath); - return nullptr; - } - - // Load resource - TString OldTransientDir = mTransientLoadDir; - mTransientLoadDir = Dir; - - CResourceEntry *pEntry = RegisterTransientResource(Type, ID, Dir, Name); - CResource *pRes = pEntry->LoadCooked(File); - if (!pRes) DeleteResourceEntry(pEntry); - - mTransientLoadDir = OldTransientDir; - - return pRes; + else return nullptr; } void CResourceStore::TrackLoadedResource(CResourceEntry *pEntry) @@ -563,27 +458,11 @@ void CResourceStore::DestroyUnreferencedResources() { It = mLoadedResources.erase(It); NumDeleted++; - - // Transient resources should have their entries cleared out when the resource is unloaded - if (pEntry->IsTransient()) - DeleteResourceEntry(pEntry); } else It++; } } while (NumDeleted > 0); - - // Destroy empty virtual directories - for (auto DirIt = mTransientRoots.begin(); DirIt != mTransientRoots.end(); DirIt++) - { - CVirtualDirectory *pRoot = *DirIt; - - if (pRoot->IsEmpty()) - { - delete pRoot; - DirIt = mTransientRoots.erase(DirIt); - } - } } bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry) @@ -611,13 +490,6 @@ bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry) return true; } -void CResourceStore::SetTransientLoadDir(const TString& rkDir) -{ - mTransientLoadDir = rkDir; - mTransientLoadDir.EnsureEndsWith('/'); - Log::Write("Set resource directory: " + rkDir); -} - void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly) { // Read file contents -first- then move assets -after-; this diff --git a/src/Core/GameProject/CResourceStore.h b/src/Core/GameProject/CResourceStore.h index 6ec6a83a..1a0695a4 100644 --- a/src/Core/GameProject/CResourceStore.h +++ b/src/Core/GameProject/CResourceStore.h @@ -22,7 +22,6 @@ class CResourceStore CGameProject *mpProj; EGame mGame; CVirtualDirectory *mpDatabaseRoot; - std::vector mTransientRoots; std::map mResourceEntries; std::map mLoadedResources; bool mDatabaseDirty; @@ -33,7 +32,6 @@ class CResourceStore TString mDatabaseName; TString mRawDir; TString mCookedDir; - TString mTransientLoadDir; enum EDatabaseVersion { @@ -56,22 +54,21 @@ public: void ConditionalSaveStore(); void SetProject(CGameProject *pProj); void CloseProject(); - CVirtualDirectory* GetVirtualDirectory(const TString& rkPath, bool Transient, bool AllowCreate); + CVirtualDirectory* GetVirtualDirectory(const TString& rkPath, bool AllowCreate); void ConditionalDeleteDirectory(CVirtualDirectory *pDir); bool IsResourceRegistered(const CAssetID& rkID) const; CResourceEntry* RegisterResource(const CAssetID& rkID, EResType Type, const TString& rkDir, const TString& rkName); CResourceEntry* FindEntry(const CAssetID& rkID) const; CResourceEntry* FindEntry(const TString& rkPath) const; - CResourceEntry* RegisterTransientResource(EResType Type, const TString& rkDir = "", const TString& rkFileName = ""); - CResourceEntry* RegisterTransientResource(EResType Type, const CAssetID& rkID, const TString& rkDir = "", const TString& rkFileName = ""); - CResource* LoadResource(const CAssetID& rkID, const CFourCC& rkType); + template ResType* LoadResource(const CAssetID& rkID) { return static_cast(LoadResource(rkID, ResType::StaticType())); } + CResource* LoadResource(const CAssetID& rkID); + CResource* LoadResource(const CAssetID& rkID, EResType Type); CResource* LoadResource(const TString& rkPath); void TrackLoadedResource(CResourceEntry *pEntry); void DestroyUnreferencedResources(); bool DeleteResourceEntry(CResourceEntry *pEntry); - void SetTransientLoadDir(const TString& rkDir); void ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly); diff --git a/src/Core/GameProject/DependencyListBuilders.cpp b/src/Core/GameProject/DependencyListBuilders.cpp index 666d5ed6..33da023e 100644 --- a/src/Core/GameProject/DependencyListBuilders.cpp +++ b/src/Core/GameProject/DependencyListBuilders.cpp @@ -98,7 +98,7 @@ void CCharacterUsageMap::DebugPrintContents() { CAssetID ID = Iter->first; std::vector& rUsedList = Iter->second; - CAnimSet *pSet = (CAnimSet*) mpStore->LoadResource(ID, "ANCS"); + CAnimSet *pSet = mpStore->LoadResource(ID); for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++) { diff --git a/src/Core/Resource/Animation/CAnimSet.h b/src/Core/Resource/Animation/CAnimSet.h index 3dc66586..d474e190 100644 --- a/src/Core/Resource/Animation/CAnimSet.h +++ b/src/Core/Resource/Animation/CAnimSet.h @@ -161,7 +161,7 @@ public: rkAnim.pMetaAnim->GetUniquePrimitives(PrimitiveSet); } - CSourceAnimData *pAnimData = (CSourceAnimData*) gpResourceStore->LoadResource(rkChar.AnimDataID, "SAND"); + CSourceAnimData *pAnimData = gpResourceStore->LoadResource(rkChar.AnimDataID); if (pAnimData) pAnimData->AddTransitionDependencies(pTree); diff --git a/src/Core/Resource/Animation/CAnimationParameters.h b/src/Core/Resource/Animation/CAnimationParameters.h index 1fb0b344..102c95fc 100644 --- a/src/Core/Resource/Animation/CAnimationParameters.h +++ b/src/Core/Resource/Animation/CAnimationParameters.h @@ -28,7 +28,7 @@ public: // Accessors inline EGame Version() const { return mGame; } inline CAssetID ID() const { return mCharacterID; } - inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID, (mGame < eCorruptionProto ? "ANCS" : "CHAR")); } + inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID); } inline u32 CharacterIndex() const { return mCharIndex; } inline u32 AnimIndex() const { return mAnimIndex; } inline void SetCharIndex(u32 Index) { mCharIndex = Index; } diff --git a/src/Core/Resource/Animation/IMetaAnimation.h b/src/Core/Resource/Animation/IMetaAnimation.h index 0ffb4b52..e72bb29f 100644 --- a/src/Core/Resource/Animation/IMetaAnimation.h +++ b/src/Core/Resource/Animation/IMetaAnimation.h @@ -34,7 +34,7 @@ public: CAnimPrimitive(IInputStream& rInput, EGame Game) { - mpAnim = gpResourceStore->LoadResource( CAssetID(rInput, Game), "ANIM" ); + mpAnim = gpResourceStore->LoadResource( CAssetID(rInput, Game) ); mID = rInput.ReadLong(); mName = rInput.ReadString(); } diff --git a/src/Core/Resource/CResource.h b/src/Core/Resource/CResource.h index b0a25dc9..606da38d 100644 --- a/src/Core/Resource/CResource.h +++ b/src/Core/Resource/CResource.h @@ -26,6 +26,11 @@ public: \ return ResTypeEnum; \ } \ \ + static CResTypeInfo* StaticTypeInfo() \ + { \ + return CResTypeInfo::FindTypeInfo(StaticType()); \ + } \ + \ private: \ class CResource diff --git a/src/Core/Resource/Cooker/CWorldCooker.cpp b/src/Core/Resource/Cooker/CWorldCooker.cpp index d9f70c37..8abdfe47 100644 --- a/src/Core/Resource/Cooker/CWorldCooker.cpp +++ b/src/Core/Resource/Cooker/CWorldCooker.cpp @@ -166,7 +166,7 @@ bool CWorldCooker::CookMLVL(CWorld *pWorld, IOutputStream& rMLVL) for (auto It = AudioGroups.begin(); It != AudioGroups.end(); It++) { - CAudioGroup *pGroup = (CAudioGroup*) gpResourceStore->LoadResource(*It, "AGSC"); + CAudioGroup *pGroup = gpResourceStore->LoadResource(*It); ASSERT(pGroup); SortedAudioGroups.push_back(pGroup); } diff --git a/src/Core/Resource/Factory/CAnimSetLoader.cpp b/src/Core/Resource/Factory/CAnimSetLoader.cpp index 1e148742..617f1a5a 100644 --- a/src/Core/Resource/Factory/CAnimSetLoader.cpp +++ b/src/Core/Resource/Factory/CAnimSetLoader.cpp @@ -15,8 +15,8 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR) // Character Header rChar.ID = rCHAR.ReadByte(); rChar.Name = rCHAR.ReadString(); - rChar.pModel = gpResourceStore->LoadResource(rCHAR.ReadLongLong(), "CMDL"); - rChar.pSkin = gpResourceStore->LoadResource(rCHAR.ReadLongLong(), "CSKR"); + rChar.pModel = gpResourceStore->LoadResource(rCHAR.ReadLongLong()); + rChar.pSkin = gpResourceStore->LoadResource(rCHAR.ReadLongLong()); u32 NumOverlays = rCHAR.ReadLong(); @@ -29,7 +29,7 @@ CAnimSet* CAnimSetLoader::LoadCorruptionCHAR(IInputStream& rCHAR) rChar.OverlayModels.push_back(Overlay); } - rChar.pSkeleton = gpResourceStore->LoadResource(rCHAR.ReadLongLong(), "CINF"); + rChar.pSkeleton = gpResourceStore->LoadResource(rCHAR.ReadLongLong()); rChar.AnimDataID = CAssetID(rCHAR, e64Bit); // PAS Database @@ -108,7 +108,7 @@ CAnimSet* CAnimSetLoader::LoadReturnsCHAR(IInputStream& rCHAR) rChar.Name = rCHAR.ReadString(); rCHAR.Seek(0x14, SEEK_CUR); rCHAR.ReadString(); - rChar.pModel = gpResourceStore->LoadResource(rCHAR.ReadLongLong(), "CMDL"); + rChar.pModel = gpResourceStore->LoadResource(rCHAR.ReadLongLong()); return pSet; } @@ -285,7 +285,7 @@ void CAnimSetLoader::ProcessPrimitives() if (mGame == eCorruptionProto || mGame == eCorruption) { - CSourceAnimData *pAnimData = (CSourceAnimData*) gpResourceStore->LoadResource( pSet->mCharacters[0].AnimDataID, "SAND" ); + CSourceAnimData *pAnimData = gpResourceStore->LoadResource( pSet->mCharacters[0].AnimDataID ); if (pAnimData) pAnimData->GetUniquePrimitives(UniquePrimitives); @@ -415,9 +415,9 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS, CResourceEntry *pEntry) Loader.mGame = (CharVersion == 0xA) ? eEchoes : ePrime; } pChar->Name = rANCS.ReadString(); - pChar->pModel = gpResourceStore->LoadResource(rANCS.ReadLong(), "CMDL"); - pChar->pSkin = gpResourceStore->LoadResource(rANCS.ReadLong(), "CSKR"); - pChar->pSkeleton = gpResourceStore->LoadResource(rANCS.ReadLong(), "CINF"); + pChar->pModel = gpResourceStore->LoadResource(rANCS.ReadLong()); + pChar->pSkin = gpResourceStore->LoadResource(rANCS.ReadLong()); + pChar->pSkeleton = gpResourceStore->LoadResource(rANCS.ReadLong()); if (pChar->pModel) pChar->pModel->SetSkin(pChar->pSkin); // Unfortunately that's all that's actually supported at the moment. Hope to expand later. diff --git a/src/Core/Resource/Factory/CAnimationLoader.cpp b/src/Core/Resource/Factory/CAnimationLoader.cpp index d249b3fd..70041059 100644 --- a/src/Core/Resource/Factory/CAnimationLoader.cpp +++ b/src/Core/Resource/Factory/CAnimationLoader.cpp @@ -199,7 +199,7 @@ void CAnimationLoader::ReadUncompressedANIM() if (mGame == ePrime) { - mpAnim->mpEventData = gpResourceStore->LoadResource(mpInput->ReadLong(), "EVNT"); + mpAnim->mpEventData = gpResourceStore->LoadResource(mpInput->ReadLong()); } } @@ -213,7 +213,7 @@ void CAnimationLoader::ReadCompressedANIM() if (mGame == ePrime) { - mpAnim->mpEventData = gpResourceStore->LoadResource(mpInput->ReadLong(), "EVNT"); + mpAnim->mpEventData = gpResourceStore->LoadResource(mpInput->ReadLong()); mpInput->Seek(0x4, SEEK_CUR); // Skip unknown } else mpInput->Seek(0x2, SEEK_CUR); // Skip unknowns diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index ce261812..1cc9c653 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -603,7 +603,7 @@ void CAreaLoader::ReadEGMC() { mpSectionMgr->ToSection(mEGMCBlockNum); CAssetID EGMC(*mpMREA, mVersion); - mpArea->mpPoiToWorldMap = gpResourceStore->LoadResource(EGMC, "EGMC"); + mpArea->mpPoiToWorldMap = gpResourceStore->LoadResource(EGMC, eStaticGeometryMap); } void CAreaLoader::MergeGeneratedLayer(CScriptLayer *pLayer) diff --git a/src/Core/Resource/Factory/CFontLoader.cpp b/src/Core/Resource/Factory/CFontLoader.cpp index 19043aab..0309442c 100644 --- a/src/Core/Resource/Factory/CFontLoader.cpp +++ b/src/Core/Resource/Factory/CFontLoader.cpp @@ -18,8 +18,8 @@ CFont* CFontLoader::LoadFont(IInputStream& rFONT) mpFont->mDefaultSize = rFONT.ReadLong(); mpFont->mFontName = rFONT.ReadString(); - if (mVersion <= eEchoes) mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLong(), "TXTR"); - else mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLongLong(), "TXTR"); + if (mVersion <= eEchoes) mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLong(), eTexture); + else mpFont->mpFontTexture = gpResourceStore->LoadResource(rFONT.ReadLongLong(), eTexture); mpFont->mTextureFormat = rFONT.ReadLong(); u32 NumGlyphs = rFONT.ReadLong(); diff --git a/src/Core/Resource/Factory/CMaterialLoader.cpp b/src/Core/Resource/Factory/CMaterialLoader.cpp index 08aa9de9..012d7464 100644 --- a/src/Core/Resource/Factory/CMaterialLoader.cpp +++ b/src/Core/Resource/Factory/CMaterialLoader.cpp @@ -50,7 +50,7 @@ void CMaterialLoader::ReadPrimeMatSet() for (u32 iTex = 0; iTex < NumTextures; iTex++) { u32 TextureID = mpFile->ReadLong(); - mTextures[iTex] = gpResourceStore->LoadResource(TextureID, "TXTR"); + mTextures[iTex] = gpResourceStore->LoadResource(TextureID); } // Materials @@ -367,7 +367,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial() continue; } - pPass->mpTexture = gpResourceStore->LoadResource(TextureID, "TXTR"); + pPass->mpTexture = gpResourceStore->LoadResource(TextureID); pPass->mTexCoordSource = 4 + (u8) mpFile->ReadLong(); u32 AnimSize = mpFile->ReadLong(); diff --git a/src/Core/Resource/Factory/CScanLoader.cpp b/src/Core/Resource/Factory/CScanLoader.cpp index f932407b..6326479c 100644 --- a/src/Core/Resource/Factory/CScanLoader.cpp +++ b/src/Core/Resource/Factory/CScanLoader.cpp @@ -10,7 +10,7 @@ CScan* CScanLoader::LoadScanMP1(IInputStream& rSCAN) { // Basic support at the moment - don't read animation/scan image data mpScan->mFrameID = CAssetID(rSCAN, e32Bit); - mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), "STRG"); + mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), eStringTable); mpScan->mIsSlow = (rSCAN.ReadLong() != 0); mpScan->mCategory = (CScan::ELogbookCategory) rSCAN.ReadLong(); mpScan->mIsImportant = (rSCAN.ReadByte() == 1); @@ -112,7 +112,7 @@ void CScanLoader::LoadParamsMP2(IInputStream& rSCAN, u16 NumProperties) switch (PropertyID) { case 0x2F5B6423: - mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), "STRG"); + mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLong(), eStringTable); break; case 0xC308A322: @@ -210,7 +210,7 @@ void CScanLoader::LoadParamsMP3(IInputStream& rSCAN, u16 NumProperties) switch (PropertyID) { case 0x2F5B6423: - mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLongLong(), "STRG"); + mpScan->mpStringTable = gpResourceStore->LoadResource(rSCAN.ReadLongLong(), eStringTable); break; case 0xC308A322: diff --git a/src/Core/Resource/Factory/CWorldLoader.cpp b/src/Core/Resource/Factory/CWorldLoader.cpp index e78f1eb0..5fb62875 100644 --- a/src/Core/Resource/Factory/CWorldLoader.cpp +++ b/src/Core/Resource/Factory/CWorldLoader.cpp @@ -16,19 +16,19 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL) // Header if (mVersion < eCorruptionProto) { - mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), "STRG"); - if (mVersion == eEchoes) mpWorld->mpDarkWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), "STRG"); + mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), eStringTable); + if (mVersion == eEchoes) mpWorld->mpDarkWorldName = gpResourceStore->LoadResource(rMLVL.ReadLong(), eStringTable); if (mVersion >= eEchoes) mpWorld->mTempleKeyWorldIndex = rMLVL.ReadLong(); - if (mVersion >= ePrime) mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLong(), "SAVW"); - mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLong(), "CMDL"); + if (mVersion >= ePrime) mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLong(), eSaveWorld); + mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLong(), eModel); } else { - mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "STRG"); + mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eStringTable); rMLVL.Seek(0x4, SEEK_CUR); // Skipping unknown value - mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "SAVW"); - mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "CMDL"); + mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eStringTable); + mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eModel); } // Memory relays - only in MP1 @@ -57,7 +57,7 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL) { // Area header CWorld::SArea *pArea = &mpWorld->mAreas[iArea]; - pArea->pAreaName = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion), "STRG" ); + pArea->pAreaName = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion) ); pArea->Transform = CTransform4f(rMLVL); pArea->AetherBox = CAABox(rMLVL); pArea->AreaResID = CAssetID(rMLVL, mVersion); @@ -132,7 +132,7 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL) } // MapWorld - mpWorld->mpMapWorld = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion), "MAPW" ); + mpWorld->mpMapWorld = gpResourceStore->LoadResource( CAssetID(rMLVL, mVersion), eMapWorld ); rMLVL.Seek(0x5, SEEK_CUR); // Unknown values which are always 0 // Audio Groups - we don't need this info as we regenerate it on cook @@ -173,7 +173,7 @@ void CWorldLoader::LoadPrimeMLVL(IInputStream& rMLVL) void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL) { - mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "STRG"); + mpWorld->mpWorldName = gpResourceStore->LoadResource(rMLVL.ReadLongLong()); bool Check = (rMLVL.ReadByte() != 0); if (Check) @@ -182,8 +182,8 @@ void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL) rMLVL.Seek(0x10, SEEK_CUR); } - mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "SAVW"); - mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "CMDL"); + mpWorld->mpSaveWorld = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), eSaveWorld); + mpWorld->mpDefaultSkybox = gpResourceStore->LoadResource(rMLVL.ReadLongLong()); // Areas u32 NumAreas = rMLVL.ReadLong(); @@ -194,7 +194,7 @@ void CWorldLoader::LoadReturnsMLVL(IInputStream& rMLVL) // Area header CWorld::SArea *pArea = &mpWorld->mAreas[iArea]; - pArea->pAreaName = gpResourceStore->LoadResource(rMLVL.ReadLongLong(), "STRG"); + pArea->pAreaName = gpResourceStore->LoadResource(rMLVL.ReadLongLong()); pArea->Transform = CTransform4f(rMLVL); pArea->AetherBox = CAABox(rMLVL); pArea->AreaResID = rMLVL.ReadLongLong(); diff --git a/src/Core/Resource/Script/CScriptTemplate.cpp b/src/Core/Resource/Script/CScriptTemplate.cpp index ea887af7..99d8160f 100644 --- a/src/Core/Resource/Script/CScriptTemplate.cpp +++ b/src/Core/Resource/Script/CScriptTemplate.cpp @@ -224,7 +224,7 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties if (pProp->Type() == eAssetProperty) { TAssetProperty *pAsset = static_cast(pProp); - pRes = gpResourceStore->LoadResource( pAsset->Get(), "DCLN" ); + pRes = gpResourceStore->LoadResource( pAsset->Get(), eDynamicCollision ); } } diff --git a/src/Core/Scene/CScriptAttachNode.cpp b/src/Core/Scene/CScriptAttachNode.cpp index 9d5ba826..d9b2542c 100644 --- a/src/Core/Scene/CScriptAttachNode.cpp +++ b/src/Core/Scene/CScriptAttachNode.cpp @@ -22,7 +22,7 @@ void CScriptAttachNode::AttachPropertyModified() if (mpAttachAssetProp) { if (mpAttachAssetProp->Type() == eAssetProperty) - mpAttachAsset = gpResourceStore->LoadResource( TPropCast(mpAttachAssetProp)->Get(), "CMDL" ); + mpAttachAsset = gpResourceStore->LoadResource( TPropCast(mpAttachAssetProp)->Get() ); else if (mpAttachAssetProp->Type() == eCharacterProperty) mpAttachAsset = TPropCast(mpAttachAssetProp)->Get().AnimSet(); diff --git a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp index 4086353a..93c1922f 100644 --- a/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp +++ b/src/Core/ScriptExtra/CDamageableTriggerExtra.cpp @@ -200,7 +200,7 @@ void CDamageableTriggerExtra::PropertyModified(IProperty *pProperty) { if (pProperty == mpTextureProps[iTex]) { - mpTextures[iTex] = gpResourceStore->LoadResource( mpTextureProps[iTex]->Get(), "TXTR" ); + mpTextures[iTex] = gpResourceStore->LoadResource( mpTextureProps[iTex]->Get() ); if (mpTextures[iTex] && mpTextures[iTex]->Type() != eTexture) mpTextures[iTex] = nullptr; diff --git a/src/Core/ScriptExtra/CDoorExtra.cpp b/src/Core/ScriptExtra/CDoorExtra.cpp index 865fa033..351b10d9 100644 --- a/src/Core/ScriptExtra/CDoorExtra.cpp +++ b/src/Core/ScriptExtra/CDoorExtra.cpp @@ -29,7 +29,7 @@ void CDoorExtra::PropertyModified(IProperty *pProperty) { if (pProperty == mpShieldModelProp) { - mpShieldModel = gpResourceStore->LoadResource( mpShieldModelProp->Get(), "CMDL" ); + mpShieldModel = gpResourceStore->LoadResource( mpShieldModelProp->Get() ); if (mpShieldModel) mLocalAABox = mpShieldModel->AABox(); diff --git a/src/Core/ScriptExtra/CPointOfInterestExtra.cpp b/src/Core/ScriptExtra/CPointOfInterestExtra.cpp index 07e39072..eb3df472 100644 --- a/src/Core/ScriptExtra/CPointOfInterestExtra.cpp +++ b/src/Core/ScriptExtra/CPointOfInterestExtra.cpp @@ -19,7 +19,7 @@ CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CScene *p void CPointOfInterestExtra::PropertyModified(IProperty* pProperty) { if (mpScanProperty == pProperty) - mpScanData = gpResourceStore->LoadResource( mpScanProperty->Get(), "SCAN" ); + mpScanData = gpResourceStore->LoadResource( mpScanProperty->Get() ); } void CPointOfInterestExtra::ModifyTintColor(CColor& Color) diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 789733b7..e47035aa 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -705,7 +705,7 @@ void CWorldEditor::UpdateOpenRecentActions() // Remove projects that don't exist anymore foreach (const QString& rkProj, RecentProjectsList) { - if (!FileUtil::Exists( TO_TSTRING(rkProj) )) + if (!FileUtil::Exists( TO_TSTRING(rkProj) ) || rkProj.contains('\\') ) RecentProjectsList.removeAll(rkProj); }