mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-16 08:27:01 +00:00
Fixed crash when creating new projects
This commit is contained in:
@@ -626,7 +626,9 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
||||
Name = rRes.ResourceID.ToString();
|
||||
#endif
|
||||
|
||||
CResourceEntry *pEntry = mpStore->CreateNewResource(rRes.ResourceID, CResTypeInfo::TypeForCookedExtension(mGame, rRes.ResourceType)->Type(), Directory, Name);
|
||||
CResourceEntry *pEntry = mpStore->CreateNewResource(rRes.ResourceID,
|
||||
CResTypeInfo::TypeForCookedExtension(mGame, rRes.ResourceType)->Type(),
|
||||
Directory, Name, true);
|
||||
|
||||
// Set flags
|
||||
pEntry->SetFlag(EResEntryFlag::IsBaseGameResource);
|
||||
|
||||
@@ -24,7 +24,7 @@ CResourceEntry::CResourceEntry(CResourceStore *pStore)
|
||||
// Static constructors
|
||||
CResourceEntry* CResourceEntry::CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResourceType Type)
|
||||
EResourceType Type, bool ExistingResource /*= false*/)
|
||||
{
|
||||
// Initialize all entry info with the input data.
|
||||
CResourceEntry *pEntry = new CResourceEntry(pStore);
|
||||
@@ -41,12 +41,16 @@ CResourceEntry* CResourceEntry::CreateNewResource(CResourceStore *pStore, const
|
||||
|
||||
pEntry->mMetadataDirty = true;
|
||||
|
||||
// Check if the data exists or not. If so, then we are creating an entry for an existing resource (game exporter).
|
||||
// If not, we want to initiate the new resource data and save it as soon as possible.
|
||||
if (!pEntry->HasCookedVersion())
|
||||
// If this is a new resource (i.e. not a base game resource that we are currently exporting),
|
||||
// then instantiate the new resource data so it can be saved as soon as possible.
|
||||
if (!ExistingResource)
|
||||
{
|
||||
pEntry->mpResource = CResourceFactory::SpawnResource(pEntry);
|
||||
pEntry->mpResource->InitializeNewResource();
|
||||
pEntry->mpResource = CResourceFactory::CreateResource(pEntry);
|
||||
|
||||
if (pEntry->mpResource)
|
||||
{
|
||||
pEntry->mpResource->InitializeNewResource();
|
||||
}
|
||||
}
|
||||
|
||||
return pEntry;
|
||||
@@ -394,7 +398,7 @@ CResource* CResourceEntry::Load()
|
||||
// support serialization yet) then load the cooked version as a backup.
|
||||
if (HasRawVersion())
|
||||
{
|
||||
mpResource = CResourceFactory::SpawnResource(this);
|
||||
mpResource = CResourceFactory::CreateResource(this);
|
||||
|
||||
if (mpResource)
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ class CResourceEntry
|
||||
public:
|
||||
static CResourceEntry* CreateNewResource(CResourceStore *pStore, const CAssetID& rkID,
|
||||
const TString& rkDir, const TString& rkName,
|
||||
EResourceType Type);
|
||||
EResourceType Type, bool ExistingResource = false);
|
||||
static CResourceEntry* BuildFromArchive(CResourceStore *pStore, IArchive& rArc);
|
||||
static CResourceEntry* BuildFromDirectory(CResourceStore *pStore, CResTypeInfo *pTypeInfo,
|
||||
const TString& rkDirPath, const TString& rkName);
|
||||
|
||||
@@ -445,7 +445,7 @@ bool CResourceStore::IsResourceRegistered(const CAssetID& rkID) const
|
||||
return FindEntry(rkID) != nullptr;
|
||||
}
|
||||
|
||||
CResourceEntry* CResourceStore::CreateNewResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName)
|
||||
CResourceEntry* CResourceStore::CreateNewResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName, bool ExistingResource /*= false*/)
|
||||
{
|
||||
CResourceEntry *pEntry = FindEntry(rkID);
|
||||
|
||||
@@ -457,7 +457,7 @@ CResourceEntry* CResourceStore::CreateNewResource(const CAssetID& rkID, EResourc
|
||||
// Validate directory
|
||||
if (IsValidResourcePath(rkDir, rkName))
|
||||
{
|
||||
pEntry = CResourceEntry::CreateNewResource(this, rkID, rkDir, rkName, Type);
|
||||
pEntry = CResourceEntry::CreateNewResource(this, rkID, rkDir, rkName, Type, ExistingResource);
|
||||
mResourceEntries[rkID] = pEntry;
|
||||
mDatabaseCacheDirty = true;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
TString DeletedResourcePath() const;
|
||||
|
||||
bool IsResourceRegistered(const CAssetID& rkID) const;
|
||||
CResourceEntry* CreateNewResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName);
|
||||
CResourceEntry* CreateNewResource(const CAssetID& rkID, EResourceType Type, const TString& rkDir, const TString& rkName, bool ExistingResource = false);
|
||||
CResourceEntry* FindEntry(const CAssetID& rkID) const;
|
||||
CResourceEntry* FindEntry(const TString& rkPath) const;
|
||||
bool AreAllEntriesValid() const;
|
||||
|
||||
Reference in New Issue
Block a user