Bladeren bron

boolean is<thing>valid chjecks for assets. tests wether it's non-empty and reporting zero flaws

AzaezelX 3 jaren geleden
bovenliggende
commit
776741770d

+ 4 - 2
Engine/source/T3D/assets/ImageAsset.h

@@ -270,7 +270,8 @@ public: \
    GFXTexHandle get##name##Resource() \
    {\
       return m##name;\
-   }
+   }\
+   bool name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_IMAGEASSET_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\
@@ -494,7 +495,8 @@ public: \
       if(index >= sm##name##Count || index < 0)\
          return nullptr;\
       return m##name[index];\
-   }
+   }\
+   bool name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_IMAGEASSET_ARRAY_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\

+ 2 - 1
Engine/source/T3D/assets/MaterialAsset.h

@@ -259,7 +259,8 @@ public: \
    SimObjectPtr<Material> get##name##Resource() \
    {\
       return m##name;\
-   }
+   }\
+   bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_MATERIALASSET_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\

+ 4 - 2
Engine/source/T3D/assets/ShapeAsset.h

@@ -321,7 +321,8 @@ public: \
    Resource<TSShape> get##name##Resource() \
    {\
       return m##name;\
-   }
+   }\
+   bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_SHAPEASSET_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\
@@ -522,7 +523,8 @@ public: \
       if(index >= sm##name##Count || index < 0)\
          return ResourceManager::get().load( "" );\
       return m##name[index];\
-   }
+   }\
+   bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_SHAPEASSET_ARRAY_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\

+ 4 - 2
Engine/source/T3D/assets/SoundAsset.h

@@ -270,7 +270,8 @@ public: \
       if (get##name() != StringTable->EmptyString() && m##name##Asset.notNull())\
          return m##name##Asset->getSfxProfile();\
       return NULL;\
-   }
+   }\
+   bool is##name##Valid() { (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_SOUNDASSET_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\
@@ -485,7 +486,8 @@ public: \
       if (get##name(id) != StringTable->EmptyString() && m##name##Asset[id].notNull())\
          return m##name##Asset[id]->getSfxProfile();\
       return NULL;\
-   }
+   }\
+   bool is##name##Valid(const U32& id) { (get##name(id) != StringTable->EmptyString() && m##name##Asset[id]->getStatus() == AssetBase::Ok) ? true : false; }
 
 #define DECLARE_SOUNDASSET_ARRAY_SETGET(className, name)\
    static bool _set##name##Data(void* obj, const char* index, const char* data)\

+ 2 - 2
Engine/source/T3D/fx/lightning.cpp

@@ -296,7 +296,7 @@ bool LightningData::preload(bool server, String &errorStr)
    {
       for (S32 i = 0; i < MaxThunders; i++)
       {
-         if (getThunderSound(i))
+         if (isThunderSoundValid(i))
          {
             _setThunderSound(getThunderSound(i), i);
             if (!getThunderSoundProfile(i))
@@ -304,7 +304,7 @@ bool LightningData::preload(bool server, String &errorStr)
          }
       }
 
-      if(getStrikeSound() && !getStrikeSoundProfile())
+      if(isStrikeSoundValid() && !getStrikeSoundProfile())
          Con::errorf(ConsoleLogEntry::General, "LightningData::preload: can't get sfxProfile from asset");
 
       mNumStrikeTextures = 0;