From 68fee78744c2d4bbc6585a4c78b236af537650ad Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 17 Aug 2021 14:41:09 -0500 Subject: [PATCH 1/3] prefab safeties --- Engine/source/T3D/prefab.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine/source/T3D/prefab.cpp b/Engine/source/T3D/prefab.cpp index 9c30963c0..38934062f 100644 --- a/Engine/source/T3D/prefab.cpp +++ b/Engine/source/T3D/prefab.cpp @@ -71,6 +71,8 @@ Prefab::Prefab() mNetFlags.clear(Ghostable); mTypeMask |= StaticObjectType; + + mFilename = StringTable->EmptyString(); } Prefab::~Prefab() @@ -558,6 +560,7 @@ bool Prefab::buildExportPolyList(ColladaUtils::ExportData* exportData, const Box void Prefab::getUtilizedAssets(Vector* usedAssetsList) { + if (!mChildGroup) return; Vector foundObjects; mChildGroup->findObjectByType(foundObjects); From 0bf97ad2c8c4c1e006561f35989a3a92ed93e60c Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 17 Aug 2021 15:27:23 -0500 Subject: [PATCH 2/3] decal safeties via if (mMaterialAsset.notNull() && mMaterialAsset->getStatus() == MaterialAsset::Ok) --- Engine/source/T3D/decal/decalData.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Engine/source/T3D/decal/decalData.cpp b/Engine/source/T3D/decal/decalData.cpp index 6951d76e3..7c033b7f6 100644 --- a/Engine/source/T3D/decal/decalData.cpp +++ b/Engine/source/T3D/decal/decalData.cpp @@ -202,7 +202,7 @@ void DecalData::initPersistFields() "grid; use #textureCoords to manually specify UV coordinates for " "irregular sized frames." ); - addField( "textureCoords", TypeRectF, Offset( texRect, DecalData ), MAX_TEXCOORD_COUNT, + addField( "textureCoords", TypeRectUV, Offset( texRect, DecalData ), MAX_TEXCOORD_COUNT, "@brief An array of RectFs (topleft.x topleft.y extent.x extent.y) " "representing the UV coordinates for each frame in the imagemap.\n\n" "@note This field should only be set if the imagemap frames are " @@ -313,7 +313,9 @@ void DecalData::_initMaterial() { SAFE_DELETE( matInst ); - if (mMaterialAsset.notNull()) + _setMaterial(getMaterial()); + + if (mMaterialAsset.notNull() && mMaterialAsset->getStatus() == MaterialAsset::Ok) { matInst = getMaterialResource()->createMatInstance(); } From 69abcb862c4e510c3621a2e4f518e93142dd83c8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 17 Aug 2021 15:32:05 -0500 Subject: [PATCH 3/3] assetbase crashes: test (most) cases for mpAssetDefinition existing before returning values. return empty if it doesn't. --- Engine/source/T3D/assets/LevelAsset.cpp | 4 +--- Engine/source/assets/assetBase.h | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Engine/source/T3D/assets/LevelAsset.cpp b/Engine/source/T3D/assets/LevelAsset.cpp index 0b5415ea8..edbc1243b 100644 --- a/Engine/source/T3D/assets/LevelAsset.cpp +++ b/Engine/source/T3D/assets/LevelAsset.cpp @@ -172,9 +172,7 @@ void LevelAsset::loadAsset() if (previewImageAssetId != StringTable->EmptyString()) { mPreviewImageAssetId = previewImageAssetId; - - AssetPtr previewImgAsset = mPreviewImageAssetId; - mPreviewImageAsset = previewImgAsset; + mPreviewImageAsset = mPreviewImageAssetId; } } diff --git a/Engine/source/assets/assetBase.h b/Engine/source/assets/assetBase.h index 352efa1f1..7d1918857 100644 --- a/Engine/source/assets/assetBase.h +++ b/Engine/source/assets/assetBase.h @@ -98,23 +98,23 @@ public: /// Asset configuration. inline void setAssetName(const char* pAssetName) { if (mpOwningAssetManager == NULL) mpAssetDefinition->mAssetName = StringTable->insert(pAssetName); } - inline StringTableEntry getAssetName(void) const { return mpAssetDefinition->mAssetName; } + inline StringTableEntry getAssetName(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetName : StringTable->EmptyString(); } void setAssetDescription(const char* pAssetDescription); - inline StringTableEntry getAssetDescription(void) const { return mpAssetDefinition->mAssetDescription; } + inline StringTableEntry getAssetDescription(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetDescription : StringTable->EmptyString(); } void setAssetCategory(const char* pAssetCategory); - inline StringTableEntry getAssetCategory(void) const { return mpAssetDefinition->mAssetCategory; } + inline StringTableEntry getAssetCategory(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetCategory : StringTable->EmptyString(); } void setAssetAutoUnload(const bool autoUnload); inline bool getAssetAutoUnload(void) const { return mpAssetDefinition->mAssetAutoUnload; } void setAssetInternal(const bool assetInternal); inline bool getAssetInternal(void) const { return mpAssetDefinition->mAssetInternal; } inline bool getAssetPrivate(void) const { return mpAssetDefinition->mAssetPrivate; } - inline StringTableEntry getAssetType(void) const { return mpAssetDefinition->mAssetType; } + inline StringTableEntry getAssetType(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetType: StringTable->EmptyString(); } inline S32 getAcquiredReferenceCount(void) const { return mAcquireReferenceCount; } inline bool getOwned(void) const { return mpOwningAssetManager != NULL; } // Asset Id is only available once registered with the asset manager. - inline StringTableEntry getAssetId(void) const { return mpAssetDefinition->mAssetId; } + inline StringTableEntry getAssetId(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetId : StringTable->EmptyString(); } /// Expanding/Collapsing asset paths is only available once registered with the asset manager. StringTableEntry expandAssetFilePath(const char* pAssetFilePath) const;