Browse Source

Removed exception throwing from XMLElement code.
Fixed divide by zero bug in AnimationState.

Lasse Öörni 15 years ago
parent
commit
916b30bcb3

+ 2 - 2
Engine/Audio/PositionalChannel.cpp

@@ -158,8 +158,8 @@ void PositionalChannel::loadXML(const XMLElement& source, ResourceCache* cache)
     mAutoRemove = channelElem.getBool("autoremove");
     
     // Read currently playing sound (if any)
-    XMLElement soundElem = source.getChildElement("sound", false);
-    if (soundElem.notNull())
+    XMLElement soundElem = source.getChildElement("sound");
+    if (soundElem)
     {
         Sound* sound = cache->getResource<Sound>(soundElem.getString("name"));
         unsigned offset = soundElem.getInt("offset");

+ 2 - 2
Engine/Audio/Sound.cpp

@@ -352,9 +352,9 @@ void Sound::loadParameters(ResourceCache* cache)
     
     XMLFile* xml = cache->getResource<XMLFile>(xmlName);
     XMLElement rootElem = xml->getRootElement();
-    XMLElement paramElem = rootElem.getChildElement("", false);
+    XMLElement paramElem = rootElem.getChildElement("");
     
-    while (paramElem.notNull())
+    while (paramElem)
     {
         std::string name = paramElem.getName();
         

+ 2 - 2
Engine/Audio/StereoChannel.cpp

@@ -133,8 +133,8 @@ void StereoChannel::loadXML(const XMLElement& source, ResourceCache* cache)
     mAutoRemove = channelElem.getBool("autoremove");
     
     // Read currently playing sound (if any)
-    XMLElement soundElem = source.getChildElement("sound", false);
-    if (soundElem.notNull())
+    XMLElement soundElem = source.getChildElement("sound");
+    if (soundElem)
     {
         Sound* sound = cache->getResource<Sound>(soundElem.getString("name"));
         unsigned offset = soundElem.getInt("offset");

+ 3 - 3
Engine/Engine/ParticleEmitter.cpp

@@ -169,9 +169,9 @@ void ParticleEmitter::loadXML(const XMLElement& source, ResourceCache* cache)
     mActive = emitterElem.getBool("active");
     setNumParticles(getNumBillboards());
     
-    XMLElement particleElem = source.getChildElement("particle", false);
+    XMLElement particleElem = source.getChildElement("particle");
     unsigned index = 0;
-    while ((particleElem.notNull()) && (index < mParticles.size()))
+    while ((particleElem) && (index < mParticles.size()))
     {
         Particle& particle = mParticles[index];
         particle.mVelocity = particleElem.getVector3("velocity");
@@ -439,7 +439,7 @@ void ParticleEmitter::loadParameters(XMLFile* file, ResourceCache* cache)
     {
         std::vector<ColorFade> fades;
         XMLElement colorFadeElem = rootElem.getChildElement("colorfade");
-        while (colorFadeElem.notNull())
+        while (colorFadeElem)
         {
             ColorFade fade;
             fade.mColor = colorFadeElem.getColor("color");

+ 36 - 36
Engine/Engine/RegisterResource.cpp

@@ -168,42 +168,42 @@ static void registerXMLElement(asIScriptEngine* engine)
     engine->RegisterObjectType("XMLElement", sizeof(XMLElement), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_C);
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructXMLElement), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_CONSTRUCT, "void f(const XMLElement& in)", asFUNCTION(ConstructXMLElementCopy), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("XMLElement", "bool isNull() const", asMETHODPR(XMLElement, isNull, () const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool notNull() const", asMETHODPR(XMLElement, notNull, () const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement createChildElement(const string& in)", asMETHODPR(XMLElement, createChildElement, (const std::string&), XMLElement), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getAttribute(const string& in, bool) const", asMETHODPR(XMLElement, getAttribute, (const std::string&, bool) const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool getBool(const string& in, bool) const", asMETHODPR(XMLElement, getBool, (const std::string&, bool) const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "BoundingBox getBoundingBox(bool) const", asMETHODPR(XMLElement, getBoundingBox, (bool) const, BoundingBox), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement getChildElement(const string& in, bool) const", asMETHODPR(XMLElement, getChildElement, (const std::string&, bool) const, XMLElement), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "Color getColor(const string& in, bool) const", asMETHODPR(XMLElement, getColor, (const std::string&, bool) const, Color), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "float getFloat(const string& in, bool) const", asMETHODPR(XMLElement, getFloat, (const std::string&, bool) const, float), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "int getInt(const string& in, bool) const", asMETHODPR(XMLElement, getInt, (const std::string&, bool) const, int), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getName() const", asMETHODPR(XMLElement, getName, () const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement getNextElement(const string& in) const", asMETHODPR(XMLElement, getNextElement, (const std::string&) const, XMLElement), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "Quaternion getQuaternion(const string& in, bool) const", asMETHODPR(XMLElement, getQuaternion, (const std::string&, bool) const, Quaternion), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getString(const string& in, bool) const", asMETHODPR(XMLElement, getString, (const std::string&, bool) const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getStringLower(const string& in, bool) const", asMETHODPR(XMLElement, getStringLower, (const std::string&, bool) const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getStringUpper(const string& in, bool) const", asMETHODPR(XMLElement, getStringUpper, (const std::string&, bool) const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "string getText() const", asMETHODPR(XMLElement, getText, () const, std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "Variant getVariant(bool) const", asMETHODPR(XMLElement, getVariant, (bool) const, Variant), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "VariantMap getVariantMap(bool) const", asMETHODPR(XMLElement, getVariantMap, (bool) const, VariantMap), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "Vector2 getVector2(const string& in, bool) const", asMETHODPR(XMLElement, getVector2, (const std::string&, bool) const, Vector2), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "Vector3 getVector3(const string& in, bool) const", asMETHODPR(XMLElement, getVector3, (const std::string&, bool) const, Vector3), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool hasAttribute(const string& in) const", asMETHODPR(XMLElement, hasAttribute, (const std::string&) const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool hasChildElement(const string& in) const", asMETHODPR(XMLElement, hasChildElement, (const std::string&) const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void removeChildElement(const string& in, bool)", asMETHODPR(XMLElement,removeChildElement, (const std::string&, bool), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setAttribute(const string& in, const string& in)", asMETHODPR(XMLElement,setAttribute, (const std::string&, const std::string&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setBool(const string& in, bool)", asMETHODPR(XMLElement,setBool, (const std::string&, bool), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setBoundingBox(const BoundingBox& in)", asMETHODPR(XMLElement,setBoundingBox, (const BoundingBox&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setColor(const string& in, const Color& in)", asMETHODPR(XMLElement,setColor, (const std::string&, const Color&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setFloat(const string& in, float)", asMETHODPR(XMLElement,setFloat, (const std::string&, float), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setInt(const string& in, int)", asMETHODPR(XMLElement,setInt, (const std::string&, int), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setQuaternion(const string& in, const Quaternion& in)", asMETHODPR(XMLElement,setQuaternion, (const std::string&, const Quaternion&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setString(const string& in, const string& in)", asMETHODPR(XMLElement,setString, (const std::string&, const std::string&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setVariant(const Variant& in)", asMETHODPR(XMLElement,setVariant, (const Variant&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setVariantMap(const VariantMap& in)", asMETHODPR(XMLElement,setVariantMap, (const VariantMap&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setVector2(const string& in, const Vector2& in)", asMETHODPR(XMLElement,setVector2, (const std::string&, const Vector2&), void ), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "void setVector3(const string& in, const Vector3& in)", asMETHODPR(XMLElement,setVector3, (const std::string&, const Vector3&), void ), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool isNull() const", asMETHOD(XMLElement, isNull), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool notNull() const", asMETHOD(XMLElement, notNull), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement createChildElement(const string& in)", asMETHOD(XMLElement, createChildElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getAttribute(const string& in) const", asMETHOD(XMLElement, getAttribute), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool getBool(const string& in) const", asMETHOD(XMLElement, getBool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "BoundingBox getBoundingBox() const", asMETHOD(XMLElement, getBoundingBox), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement getChildElement(const string& in) const", asMETHOD(XMLElement, getChildElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "Color getColor(const string& in) const", asMETHOD(XMLElement, getColor), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "float getFloat(const string& in) const", asMETHOD(XMLElement, getFloat), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "int getInt(const string& in) const", asMETHOD(XMLElement, getInt), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getName() const", asMETHOD(XMLElement, getName), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement getNextElement(const string& in) const", asMETHOD(XMLElement, getNextElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "Quaternion getQuaternion(const string& in) const", asMETHOD(XMLElement, getQuaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getString(const string& in) const", asMETHOD(XMLElement, getString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getStringLower(const string& in) const", asMETHOD(XMLElement, getStringLower), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getStringUpper(const string& in) const", asMETHOD(XMLElement, getStringUpper), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "string getText() const", asMETHOD(XMLElement, getText), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "Variant getVariant() const", asMETHOD(XMLElement, getVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "VariantMap getVariantMap() const", asMETHOD(XMLElement, getVariantMap), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "Vector2 getVector2(const string& in) const", asMETHOD(XMLElement, getVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "Vector3 getVector3(const string& in) const", asMETHOD(XMLElement, getVector3), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool hasAttribute(const string& in) const", asMETHOD(XMLElement, hasAttribute), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool hasChildElement(const string& in) const", asMETHOD(XMLElement, hasChildElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool removeChildElement(const string& in, bool)", asMETHOD(XMLElement,removeChildElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setAttribute(const string& in, const string& in)", asMETHOD(XMLElement,setAttribute), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setBool(const string& in, bool)", asMETHOD(XMLElement,setBool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setBoundingBox(const BoundingBox& in)", asMETHOD(XMLElement,setBoundingBox), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setColor(const string& in, const Color& in)", asMETHOD(XMLElement, setColor), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setFloat(const string& in, float)", asMETHOD(XMLElement, setFloat), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setInt(const string& in, int)", asMETHOD(XMLElement, setInt), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setQuaternion(const string& in, const Quaternion& in)", asMETHOD(XMLElement, setQuaternion), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setString(const string& in, const string& in)", asMETHOD(XMLElement, setString), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setVariant(const Variant& in)", asMETHOD(XMLElement, setVariant), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setVariantMap(const VariantMap& in)", asMETHOD(XMLElement, setVariantMap), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setVector2(const string& in, const Vector2& in)", asMETHOD(XMLElement, setVector2), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool setVector3(const string& in, const Vector3& in)", asMETHOD(XMLElement, setVector3), asCALL_THISCALL);
 }
 
 static XMLFile* ConstructXMLFile(const std::string& name)

+ 12 - 12
Engine/Engine/RegisterScene.cpp

@@ -279,13 +279,13 @@ static Entity* SceneCreateEntityWithNameAndLocalFlag(const std::string& name, bo
     }
 }
 
-static void SceneSave(File* file, bool throwOnError, Scene* ptr)
+static void SceneSave(File* file, Scene* ptr)
 {
     if (!file)
         SAFE_EXCEPTION("Null scene destination file");
     try
     {
-        ptr->save(*file, throwOnError);
+        ptr->save(*file);
     }
     catch (Exception& e)
     {
@@ -293,13 +293,13 @@ static void SceneSave(File* file, bool throwOnError, Scene* ptr)
     }
 }
 
-static void SceneLoad(File* file, bool throwOnError, Scene* ptr)
+static void SceneLoad(File* file, Scene* ptr)
 {
     if (!file)
         SAFE_EXCEPTION("Null scene source file");
     try
     {
-        ptr->load(*file, throwOnError);
+        ptr->load(*file);
     }
     catch (Exception& e)
     {
@@ -307,13 +307,13 @@ static void SceneLoad(File* file, bool throwOnError, Scene* ptr)
     }
 }
 
-static void SceneSaveXML(File* file, bool throwOnError, Scene* ptr)
+static void SceneSaveXML(File* file, Scene* ptr)
 {
     if (!file)
         SAFE_EXCEPTION("Null scene destination XML file");
     try
     {
-        ptr->saveXML(*file, throwOnError);
+        ptr->saveXML(*file);
     }
     catch (Exception& e)
     {
@@ -321,13 +321,13 @@ static void SceneSaveXML(File* file, bool throwOnError, Scene* ptr)
     }
 }
 
-static void SceneLoadXML(File* file, bool throwOnError, Scene* ptr)
+static void SceneLoadXML(File* file, Scene* ptr)
 {
     if (!file)
         SAFE_EXCEPTION("Null scene source XML file");
     try
     {
-        ptr->loadXML(*file, throwOnError);
+        ptr->loadXML(*file);
     }
     catch (Exception& e)
     {
@@ -395,10 +395,10 @@ static void registerScene(asIScriptEngine* engine)
 {
     engine->RegisterObjectBehaviour("Scene", asBEHAVE_ADDREF, "void f()", asMETHOD(Scene, addRef), asCALL_THISCALL);
     engine->RegisterObjectBehaviour("Scene", asBEHAVE_RELEASE, "void f()", asMETHOD(Scene, releaseRef), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Scene", "void save(File@+, bool)", asFUNCTION(SceneSave), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Scene", "void load(File@+, bool)", asFUNCTION(SceneLoad), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Scene", "void saveXML(File@+, bool)", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("Scene", "void loadXML(File@+, bool)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "void save(File@+)", asFUNCTION(SceneSave), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "void load(File@+)", asFUNCTION(SceneLoad), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "void saveXML(File@+)", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Scene", "void loadXML(File@+)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "void loadAsync(File@+)", asFUNCTION(SceneLoadAsync), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "void loadAsyncXML(File@+)", asFUNCTION(SceneLoadAsyncXML), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Scene", "Entity@+ createEntity()", asFUNCTION(SceneCreateEntity), asCALL_CDECL_OBJLAST);

+ 2 - 2
Engine/Physics/CollisionShape.cpp

@@ -357,8 +357,8 @@ void CollisionShape::load(Deserializer& source, ResourceCache* cache)
     xml.load(source, cache);
     
     XMLElement rootElem = xml.getRootElement();
-    XMLElement shapeElem = rootElem.getChildElement("", false);
-    while (shapeElem.notNull())
+    XMLElement shapeElem = rootElem.getChildElement("");
+    while (shapeElem)
     {
         std::string type = shapeElem.getName();
         Vector3 position = Vector3::sZero;

+ 10 - 7
Engine/Renderer/AnimatedModel.cpp

@@ -171,8 +171,8 @@ void AnimatedModel::loadXML(const XMLElement& source, ResourceCache* cache)
     XMLElement modelElem = source.getChildElement("model");
     setModel(cache->getResource<Model>(modelElem.getString("name")));
     
-    XMLElement materialElem = source.getChildElement("material", false);
-    while (materialElem.notNull())
+    XMLElement materialElem = source.getChildElement("material");
+    while (materialElem)
     {
         unsigned index = materialElem.getInt("index");
         setMaterial(index, cache->getResource<Material>(materialElem.getString("name")));
@@ -183,8 +183,8 @@ void AnimatedModel::loadXML(const XMLElement& source, ResourceCache* cache)
     XMLElement lodElem = source.getChildElement("lod");
     mAnimationLodBias = lodElem.getFloat("animlodbias");
     removeAllAnimationStates();
-    XMLElement animationElem = source.getChildElement("animation", false);
-    while (animationElem.notNull())
+    XMLElement animationElem = source.getChildElement("animation");
+    while (animationElem)
     {
         AnimationState* newState = addAnimationState(cache->getResource<Animation>(animationElem.getString("name")));
         newState->loadXML(animationElem);
@@ -192,8 +192,8 @@ void AnimatedModel::loadXML(const XMLElement& source, ResourceCache* cache)
     }
     
     // Read morph properties
-    XMLElement morphElem = source.getChildElement("morph", false);
-    while (morphElem.notNull())
+    XMLElement morphElem = source.getChildElement("morph");
+    while (morphElem)
     {
         unsigned index = morphElem.getInt("index");
         setMorphWeight(index, morphElem.getFloat("weight"));
@@ -534,8 +534,11 @@ void AnimatedModel::updateNode(const FrameInfo& frame)
         static const Vector3 dotScale(1 / 3.0f, 1 / 3.0f, 1 / 3.0f);
         float scale = getWorldBoundingBox().getSize().dotProduct(dotScale);
         mAnimationLodDistance = frame.mCamera->getLodDistance(distance, scale, mLodBias) * ANIMATION_LOD_INVISIBLE_FACTOR;
+        LOGINFO("Invisible update");
     }
-    
+    else
+        LOGINFO("Visible update");
+        
     updateAnimation(frame);
 }
 

+ 6 - 2
Engine/Renderer/AnimationState.cpp

@@ -325,7 +325,9 @@ void AnimationState::apply()
                 float timeInterval = nextKeyFrame->mTime - keyFrame->mTime;
                 if (timeInterval < 0.0f)
                     timeInterval += mAnimation->getLength();
-                float t = clamp((mTime - keyFrame->mTime) / timeInterval, 0.0f, 1.0f);
+                float t = 1.0f;
+                if (timeInterval > 0.0f)
+                    t = (mTime - keyFrame->mTime) / timeInterval;
                 
                 // Interpolation, full weight
                 if (channelMask & CHANNEL_POSITION)
@@ -393,7 +395,9 @@ void AnimationState::apply()
                 float timeInterval = nextKeyFrame->mTime - keyFrame->mTime;
                 if (timeInterval < 0.0f)
                     timeInterval += mAnimation->getLength();
-                float t = clamp((mTime - keyFrame->mTime) / timeInterval, 0.0f, 1.0f);
+                float t = 1.0f;
+                if (timeInterval > 0.0f)
+                    t = (mTime - keyFrame->mTime) / timeInterval;
                 
                 // Interpolation, blend between old transform & animation
                 if (channelMask & CHANNEL_POSITION)

+ 2 - 2
Engine/Renderer/BillboardSet.cpp

@@ -178,9 +178,9 @@ void BillboardSet::loadXML(const XMLElement& source, ResourceCache* cache)
     XMLElement lodElem = source.getChildElement("lod");
     mAnimationLodBias = lodElem.getFloat("animlodbias");
     
-    XMLElement billboardElem = source.getChildElement("billboard", false);
+    XMLElement billboardElem = source.getChildElement("billboard");
     unsigned index = 0;
-    while ((billboardElem.notNull()) && (index < mBillboards.size()))
+    while ((billboardElem) && (index < mBillboards.size()))
     {
         Billboard& billboard = mBillboards[index];
         billboard.mEnabled = billboardElem.hasAttribute("pos");

+ 2 - 2
Engine/Renderer/CustomObject.cpp

@@ -171,9 +171,9 @@ void CustomObject::loadXML(const XMLElement& source, ResourceCache* cache)
     setNumGeometries(geometriesElem.getInt("count"));
     
     unsigned vertexSize = VertexBuffer::getVertexSize(mVertexElementMask);
-    XMLElement geometryElem = source.getChildElement("geometry", false);
+    XMLElement geometryElem = source.getChildElement("geometry");
     unsigned index = 0;
-    while ((geometryElem.notNull()) && (index < mGeometries.size()))
+    while ((geometryElem) && (index < mGeometries.size()))
     {
         CustomGeometry& geometry = mCustomGeometries[index];
         geometry.mBoundingBox = geometryElem.getBoundingBox();

+ 3 - 3
Engine/Renderer/InstancedModel.cpp

@@ -146,8 +146,8 @@ void InstancedModel::loadXML(const XMLElement& source, ResourceCache* cache)
     XMLElement modelElem = source.getChildElement("model");
     setModel(cache->getResource<Model>(modelElem.getString("name")));
     
-    XMLElement materialElem = source.getChildElement("material", false);
-    while (materialElem.notNull())
+    XMLElement materialElem = source.getChildElement("material");
+    while (materialElem)
     {
         unsigned index = materialElem.getInt("index");
         setMaterial(index, cache->getResource<Material>(materialElem.getString("name")));
@@ -158,7 +158,7 @@ void InstancedModel::loadXML(const XMLElement& source, ResourceCache* cache)
     mInstancesRelative = instancesElem.getBool("relative");
     setNumInstances(instancesElem.getInt("count"));
     
-    XMLElement instanceElem = source.getChildElement("instance", false);
+    XMLElement instanceElem = source.getChildElement("instance");
     unsigned index = 0;
     while ((instanceElem) && (index < mInstances.size()))
     {

+ 10 - 10
Engine/Renderer/Material.cpp

@@ -342,8 +342,8 @@ void Material::load(Deserializer& source, ResourceCache* cache)
     
     XMLElement rootElem = xml.getRootElement();
     // Check for base material and inherit all settings, techniques and passes
-    XMLElement baseElem = rootElem.getChildElement("base", false);
-    if (baseElem.notNull())
+    XMLElement baseElem = rootElem.getChildElement("base");
+    if (baseElem)
     {
         Material* baseMaterial = cache->getResource<Material>(baseElem.getString("name"));
         mTechniques = baseMaterial->mTechniques;
@@ -358,9 +358,9 @@ void Material::load(Deserializer& source, ResourceCache* cache)
     else
         mTechniques.clear();
     
-    XMLElement techniqueElem = rootElem.getChildElement("technique", false);
+    XMLElement techniqueElem = rootElem.getChildElement("technique");
     unsigned index = 0;
-    while (techniqueElem.notNull())
+    while (techniqueElem)
     {
         if (mTechniques.size() < index + 1)
             setNumTechniques(index + 1);
@@ -374,8 +374,8 @@ void Material::load(Deserializer& source, ResourceCache* cache)
         if (techniqueElem.hasAttribute("sm3"))
             newTechnique.setRequireSM3(techniqueElem.getBool("sm3"));
         
-        XMLElement textureElem = techniqueElem.getChildElement("texture", false);
-        while (textureElem.notNull())
+        XMLElement textureElem = techniqueElem.getChildElement("texture");
+        while (textureElem)
         {
             TextureUnit unit = TU_DIFFUSE;
             if (textureElem.hasAttribute("unit"))
@@ -403,8 +403,8 @@ void Material::load(Deserializer& source, ResourceCache* cache)
             textureElem = textureElem.getNextElement("texture");
         }
         
-        XMLElement parameterElem = techniqueElem.getChildElement("parameter", false);
-        while (parameterElem.notNull())
+        XMLElement parameterElem = techniqueElem.getChildElement("parameter");
+        while (parameterElem)
         {
             std::string name = parameterElem.getString("name");
             Vector4 value = parameterElem.getVector("value");
@@ -423,8 +423,8 @@ void Material::load(Deserializer& source, ResourceCache* cache)
             parameterElem = parameterElem.getNextElement("parameter");
         }
         
-        XMLElement passElem = techniqueElem.getChildElement("pass", false);
-        while (passElem.notNull())
+        XMLElement passElem = techniqueElem.getChildElement("pass");
+        while (passElem)
         {
             PassType type = MAX_PASSES;
             if (passElem.hasAttribute("name"))

+ 61 - 47
Engine/Renderer/Pipeline.cpp

@@ -500,24 +500,28 @@ void Pipeline::drawDebugGeometry(DebugRenderer* debug)
         lights[i]->drawDebugGeometry(debug);
 }
 
-VertexShader* Pipeline::getVertexShader(const std::string& name) const
+VertexShader* Pipeline::getVertexShader(const std::string& name, bool checkExists) const
 {
     // Check for extra underscore with no variations and remove
     std::string fullName = replace(mShaderPath + name + mVSFormat, "_.", ".");
-    if (mCache->exists(fullName))
-        return mCache->getResource<VertexShader>(fullName);
-    else
-        return 0;
+    if (checkExists)
+    {
+        if (!mCache->exists(fullName))
+            return 0;
+    }
+    return mCache->getResource<VertexShader>(fullName);
 }
 
-PixelShader* Pipeline::getPixelShader(const std::string& name) const
+PixelShader* Pipeline::getPixelShader(const std::string& name, bool checkExists) const
 {
     // Check for extra underscore with no variations and remove
     std::string fullName = replace(mShaderPath + name + mPSFormat, "_.", ".");
-    if (mCache->exists(fullName))
-        return mCache->getResource<PixelShader>(fullName);
-    else
-        return 0;
+    if (checkExists)
+    {
+        if (!mCache->exists(fullName))
+            return 0;
+    }
+    return mCache->getResource<PixelShader>(fullName);
 }
 
 unsigned Pipeline::getNumGeometries(bool allViews) const
@@ -956,52 +960,62 @@ void Pipeline::loadMaterialPassShaders(MaterialTechnique* technique, PassType pa
     std::vector<SharedPtr<VertexShader> >& vertexShaders = i->second.getVertexShaders();
     std::vector<SharedPtr<PixelShader> >& pixelShaders = i->second.getPixelShaders();
     
-    switch (i->first)
+    // Forget all the old shaders
+    vertexShaders.clear();
+    pixelShaders.clear();
+    
+    try
     {
-    default:
-        vertexShaders.resize(MAX_GEOMETRYTYPES);
-        pixelShaders.resize(1);
-        for (unsigned j = 0; j < MAX_GEOMETRYTYPES; ++j)
-            vertexShaders[j] = getVertexShader(vertexShaderName + geometryVSVariations[j]);
-        pixelShaders[0] = getPixelShader(pixelShaderName);
-        break;
-        
-    case PASS_LIGHT:
-    case PASS_NEGATIVE:
-        vertexShaders.resize(MAX_GEOMETRYTYPES * MAX_LIGHT_VS_VARIATIONS);
-        pixelShaders.resize(MAX_LIGHT_PS_VARIATIONS);
-        
-        for (unsigned j = 0; j < MAX_GEOMETRYTYPES * MAX_LIGHT_VS_VARIATIONS; ++j)
+        switch (i->first)
         {
-            unsigned g = j / MAX_LIGHT_VS_VARIATIONS;
-            unsigned l = j % MAX_LIGHT_VS_VARIATIONS;
-            if ((!(l & LVS_SHADOW)) || (allowShadows))
-                vertexShaders[j] = getVertexShader(vertexShaderName + lightVSVariations[l] + geometryVSVariations[g]);
-            else
-                vertexShaders[j].reset();
-        }
-        for (unsigned j = 0; j < MAX_LIGHT_PS_VARIATIONS; ++j)
-        {
-            unsigned variation = j % 5;
-            if ((variation == LPS_SHADOW) || (variation == LPS_SHADOWSPEC))
+        default:
+            vertexShaders.resize(MAX_GEOMETRYTYPES);
+            pixelShaders.resize(1);
+            for (unsigned j = 0; j < MAX_GEOMETRYTYPES; ++j)
+                vertexShaders[j] = getVertexShader(vertexShaderName + geometryVSVariations[j], j != 0);
+            pixelShaders[0] = getPixelShader(pixelShaderName);
+            break;
+            
+        case PASS_LIGHT:
+        case PASS_NEGATIVE:
+            vertexShaders.resize(MAX_GEOMETRYTYPES * MAX_LIGHT_VS_VARIATIONS);
+            pixelShaders.resize(MAX_LIGHT_PS_VARIATIONS);
+            
+            for (unsigned j = 0; j < MAX_GEOMETRYTYPES * MAX_LIGHT_VS_VARIATIONS; ++j)
             {
-                if (allowShadows)
-                    pixelShaders[j] = getPixelShader(pixelShaderName + deferredLightPSVariations[j] + 
-                        shadowPSVariations[hwShadows]);
+                unsigned g = j / MAX_LIGHT_VS_VARIATIONS;
+                unsigned l = j % MAX_LIGHT_VS_VARIATIONS;
+                if ((!(l & LVS_SHADOW)) || (allowShadows))
+                    vertexShaders[j] = getVertexShader(vertexShaderName + lightVSVariations[l] + geometryVSVariations[g], g != 0);
                 else
-                    pixelShaders[j].reset();
+                    vertexShaders[j].reset();
             }
-            else
+            for (unsigned j = 0; j < MAX_LIGHT_PS_VARIATIONS; ++j)
             {
-                // For the negative pass, load only the negative version of the shader
-                bool needed = (pass == PASS_LIGHT) ? (variation != LPS_NEGATIVE) : (variation == LPS_NEGATIVE);
-                if (needed)
-                    pixelShaders[j] = getPixelShader(pixelShaderName + deferredLightPSVariations[j]);
+                unsigned variation = j % 5;
+                if ((variation == LPS_SHADOW) || (variation == LPS_SHADOWSPEC))
+                {
+                    if (allowShadows)
+                        pixelShaders[j] = getPixelShader(pixelShaderName + deferredLightPSVariations[j] + 
+                            shadowPSVariations[hwShadows]);
+                    else
+                        pixelShaders[j].reset();
+                }
                 else
-                    pixelShaders[j].reset();
+                {
+                    // For the negative pass, load only the negative version of the shader
+                    bool needed = (pass == PASS_LIGHT) ? (variation != LPS_NEGATIVE) : (variation == LPS_NEGATIVE);
+                    if (needed)
+                        pixelShaders[j] = getPixelShader(pixelShaderName + deferredLightPSVariations[j]);
+                    else
+                        pixelShaders[j].reset();
+                }
             }
+            break;
         }
-        break;
+    }
+    catch (...)
+    {
     }
     
     technique->markShadersLoaded(mShadersChangedFrameNumber);

+ 2 - 2
Engine/Renderer/Pipeline.h

@@ -184,9 +184,9 @@ public:
     //! Return the default spotlight attenuation texture
     Texture* getDefaultLightSpot() const { return mDefaultLightSpot; }
     //! Return a vertex shader by name
-    VertexShader* getVertexShader(const std::string& name) const;
+    VertexShader* getVertexShader(const std::string& name, bool checkExists = false) const;
     //! Return a pixel shader by name
-    PixelShader* getPixelShader(const std::string& name) const;
+    PixelShader* getPixelShader(const std::string& name, bool checkExists = false) const;
     //! Return the renderer subsystem
     Renderer* getRenderer() const { return mRenderer; }
     

+ 9 - 9
Engine/Renderer/PixelShader.cpp

@@ -158,10 +158,10 @@ void PixelShader::loadParameters(ResourceCache* cache)
     
     // Update (global) parameter register mappings
     XMLElement shadersElem = xml->getRootElement();
-    XMLElement paramsElem = shadersElem.getChildElement("psparameters", false);
-    XMLElement paramElem = paramsElem.getChildElement("parameter", false);
+    XMLElement paramsElem = shadersElem.getChildElement("psparameters");
+    XMLElement paramElem = paramsElem.getChildElement("parameter");
     
-    while (paramElem.notNull())
+    while (paramElem)
     {
         std::string name = paramElem.getString("name");
         if (sParameters.find(name) == sParameters.end())
@@ -173,8 +173,8 @@ void PixelShader::loadParameters(ResourceCache* cache)
     }
     
     // Get parameters and texture units used by this shader
-    XMLElement shaderElem = shadersElem.getChildElement("shader", false);
-    while (shaderElem.notNull())
+    XMLElement shaderElem = shadersElem.getChildElement("shader");
+    while (shaderElem)
     {
         std::string name = shaderElem.getString("name");
         std::string type = shaderElem.getStringLower("type");
@@ -186,16 +186,16 @@ void PixelShader::loadParameters(ResourceCache* cache)
             for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
                 mUseTextureUnit[i] = false;
             
-            XMLElement shaderParamElem = shaderElem.getChildElement("parameter", false);
-            while (shaderParamElem.notNull())
+            XMLElement shaderParamElem = shaderElem.getChildElement("parameter");
+            while (shaderParamElem)
             {
                 std::string name = shaderParamElem.getString("name");
                 mUseParameter[sParameters[name]] = true;
                 shaderParamElem = shaderParamElem.getNextElement("parameter");
             }
             
-            XMLElement textureElem = shaderElem.getChildElement("textureunit", false);
-            while (textureElem.notNull())
+            XMLElement textureElem = shaderElem.getChildElement("textureunit");
+            while (textureElem)
             {
                 std::string name = textureElem.getString("name");
                 if (sTextureUnits.find(name) == sTextureUnits.end())

+ 2 - 2
Engine/Renderer/StaticModel.cpp

@@ -103,8 +103,8 @@ void StaticModel::loadXML(const XMLElement& source, ResourceCache* cache)
     XMLElement modelElem = source.getChildElement("model");
     setModel(cache->getResource<Model>(modelElem.getString("name")));
     
-    XMLElement materialElem = source.getChildElement("material", false);
-    while (materialElem.notNull())
+    XMLElement materialElem = source.getChildElement("material");
+    while (materialElem)
     {
         unsigned index = materialElem.getInt("index");
         setMaterial(index, cache->getResource<Material>(materialElem.getString("name")));

+ 2 - 2
Engine/Renderer/Texture.cpp

@@ -157,9 +157,9 @@ void Texture::loadParameters(ResourceCache* cache)
 void Texture::loadParameters(XMLFile& xml)
 {
     XMLElement rootElem = xml.getRootElement();
-    XMLElement paramElem = rootElem.getChildElement("", false);
+    XMLElement paramElem = rootElem.getChildElement("");
     
-    while (paramElem.notNull())
+    while (paramElem)
     {
         std::string name = paramElem.getName();
         

+ 2 - 2
Engine/Renderer/TextureCube.cpp

@@ -129,9 +129,9 @@ void TextureCube::load(Deserializer& source, ResourceCache* cache)
     loadParameters(xml);
     
     XMLElement textureElem = xml.getRootElement();
-    XMLElement faceElem = textureElem.getChildElement("face", false);
+    XMLElement faceElem = textureElem.getChildElement("face");
     unsigned faces = 0;
-    while ((faceElem.notNull()) && (faces < MAX_CUBEMAP_FACES))
+    while ((faceElem) && (faces < MAX_CUBEMAP_FACES))
     {
         std::string name = faceElem.getString("name");
         std::string faceTexPath;

+ 7 - 7
Engine/Renderer/VertexShader.cpp

@@ -157,10 +157,10 @@ void VertexShader::loadParameters(ResourceCache* cache)
     
     // Update (global) parameter register mappings
     XMLElement shadersElem = xml->getRootElement();
-    XMLElement paramsElem = shadersElem.getChildElement("vsparameters", false);
-    XMLElement paramElem = paramsElem.getChildElement("parameter", false);
+    XMLElement paramsElem = shadersElem.getChildElement("vsparameters");
+    XMLElement paramElem = paramsElem.getChildElement("parameter");
     
-    while (paramElem.notNull())
+    while (paramElem)
     {
         std::string name = paramElem.getString("name");
         if (sParameters.find(name) == sParameters.end())
@@ -172,8 +172,8 @@ void VertexShader::loadParameters(ResourceCache* cache)
     }
     
     // Get parameters and texture units used by this shader
-    XMLElement shaderElem = shadersElem.getChildElement("shader", false);
-    while (shaderElem.notNull())
+    XMLElement shaderElem = shadersElem.getChildElement("shader");
+    while (shaderElem)
     {
         std::string name = shaderElem.getString("name");
         std::string type = shaderElem.getStringLower("type");
@@ -183,8 +183,8 @@ void VertexShader::loadParameters(ResourceCache* cache)
             for (unsigned i = 0; i < MAX_VS_PARAMETERS; ++i)
                 mUseParameter[i] = false;
             
-            XMLElement shaderParamElem = shaderElem.getChildElement("parameter", false);
-            while (shaderParamElem.notNull())
+            XMLElement shaderParamElem = shaderElem.getChildElement("parameter");
+            while (shaderParamElem)
             {
                 std::string name = shaderParamElem.getString("name");
                 mUseParameter[sParameters[name]] = true;

+ 120 - 135
Engine/Resource/XMLElement.cpp

@@ -23,6 +23,7 @@
 
 #include "Precompiled.h"
 #include "Exception.h"
+#include "Log.h"
 #include "StringUtils.h"
 #include "XMLElement.h"
 
@@ -50,17 +51,19 @@ XMLElement::~XMLElement()
 XMLElement XMLElement::createChildElement(const std::string& name)
 {
     if (!mElement)
-        SAFE_EXCEPTION_RET("Null XML element, can not create child element " + name, XMLElement());
-    
+    {
+        LOGERROR("Null XML element, can not create child element " + name);
+        return XMLElement();
+    }
     TiXmlElement newElement(name.c_str());
     mElement->InsertEndChild(newElement);
     return XMLElement(static_cast<TiXmlElement*>(mElement->LastChild()));
 }
 
-void XMLElement::removeChildElement(const std::string& name, bool last)
+bool XMLElement::removeChildElement(const std::string& name, bool last)
 {
     if (!mElement)
-        return;
+        return false;
     
     TiXmlNode* element;
     if (name.empty())
@@ -77,30 +80,41 @@ void XMLElement::removeChildElement(const std::string& name, bool last)
         else
             element = mElement->FirstChild(name.c_str());
     }
-
-    mElement->RemoveChild(element);
+    
+    if (element)
+    {
+        mElement->RemoveChild(element);
+        return true;
+    }
+    
+    return false;
 }
 
-void XMLElement::setAttribute(const std::string& name, const std::string& value)
+bool XMLElement::setAttribute(const std::string& name, const std::string& value)
 {
     if (!mElement)
-        SAFE_EXCEPTION("Null XML element, can not set attribute " + name);
-
+    {
+        LOGERROR("Null XML element, can not set attribute " + name);
+        return false;
+    }
+    
     mElement->SetAttribute(name.c_str(), value.c_str());
+    return true;
 }
 
-void XMLElement::setBool(const std::string& name, bool value)
+bool XMLElement::setBool(const std::string& name, bool value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setBoundingBox(const BoundingBox& value)
+bool XMLElement::setBoundingBox(const BoundingBox& value)
 {
-    setVector3("min", value.mMin);
-    setVector3("max", value.mMax);
+    if (!setVector3("min", value.mMin))
+        return false;
+    return setVector3("max", value.mMax);
 }
 
-void XMLElement::setBuffer(const std::string& name, const void* data, unsigned size)
+bool XMLElement::setBuffer(const std::string& name, const void* data, unsigned size)
 {
     std::string dataStr;
     const unsigned char* bytes = (const unsigned char*)data;
@@ -108,68 +122,71 @@ void XMLElement::setBuffer(const std::string& name, const void* data, unsigned s
     for (unsigned i = 0; i < size; ++i)
         dataStr += toString(bytes[i]) + " ";
     
-    setAttribute(name, dataStr);
+    return setAttribute(name, dataStr);
 }
 
-void XMLElement::setBuffer(const std::string& name, const std::vector<unsigned char>& value)
+bool XMLElement::setBuffer(const std::string& name, const std::vector<unsigned char>& value)
 {
     if (!value.size())
-        setAttribute(name, std::string());
+        return setAttribute(name, std::string());
     else
-        setBuffer(name, &value[0], value.size());
+        return setBuffer(name, &value[0], value.size());
 }
 
-void XMLElement::setColor(const std::string& name, const Color& value)
+bool XMLElement::setColor(const std::string& name, const Color& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setFloat(const std::string& name, float value)
+bool XMLElement::setFloat(const std::string& name, float value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setInt(const std::string& name, int value)
+bool XMLElement::setInt(const std::string& name, int value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setIntRect(const std::string& name, const IntRect& value)
+bool XMLElement::setIntRect(const std::string& name, const IntRect& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setIntVector2(const std::string& name, const IntVector2& value)
+bool XMLElement::setIntVector2(const std::string& name, const IntVector2& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setRect(const std::string& name, const Rect& value)
+bool XMLElement::setRect(const std::string& name, const Rect& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setQuaternion(const std::string& name, const Quaternion& value)
+bool XMLElement::setQuaternion(const std::string& name, const Quaternion& value)
 {
-    XMLElement::setAttribute(name, toString(value));
+    return XMLElement::setAttribute(name, toString(value));
 }
 
-void XMLElement::setString(const std::string& name, const std::string& value)
+bool XMLElement::setString(const std::string& name, const std::string& value)
 {
-    setAttribute(name, value);
+    return setAttribute(name, value);
 }
 
-void XMLElement::setVariant(const Variant& value)
+bool XMLElement::setVariant(const Variant& value)
 {
-    setAttribute("type", value.getTypeName());
-    setAttribute("value", value.toString());
+    if (!setAttribute("type", value.getTypeName()))
+        return false;
+    return setAttribute("value", value.toString());
 }
 
-void XMLElement::setVariantMap(const VariantMap& value)
+bool XMLElement::setVariantMap(const VariantMap& value)
 {
     for (VariantMap::const_iterator i = value.begin(); i != value.end(); ++i)
     {
         XMLElement variantElem = createChildElement("variant");
+        if (!variantElem)
+            return false;
         std::string name = shortHashToString(i->first);
         if (name.empty())
             variantElem.setInt("hash", i->first.mData);
@@ -177,28 +194,30 @@ void XMLElement::setVariantMap(const VariantMap& value)
             variantElem.setString("name", name);
         variantElem.setVariant(i->second);
     }
+    
+    return true;
 }
 
-void XMLElement::setVector2(const std::string& name, const Vector2& value)
+bool XMLElement::setVector2(const std::string& name, const Vector2& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setVector3(const std::string& name, const Vector3& value)
+bool XMLElement::setVector3(const std::string& name, const Vector3& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
-void XMLElement::setVector4(const std::string& name, const Vector4& value)
+bool XMLElement::setVector4(const std::string& name, const Vector4& value)
 {
-    setAttribute(name, toString(value));
+    return setAttribute(name, toString(value));
 }
 
 std::string XMLElement::getName() const
 {
     if (!mElement)
         return std::string();
-
+    
     return std::string(mElement->Value());
 }
 
@@ -225,35 +244,16 @@ bool XMLElement::hasChildElement(const std::string& name) const
         return false;
 }
 
-XMLElement XMLElement::getChildElement(const std::string& name, bool throwIfMissing) const
+XMLElement XMLElement::getChildElement(const std::string& name) const
 {
-    if (throwIfMissing)
-    {
-        if (!mElement)
-            SAFE_EXCEPTION_RET("Null XML element, can not get child element " + name, XMLElement());
-        
-        TiXmlElement* child;
-        if (name.empty())
-            child = mElement->FirstChildElement();
-        else
-            child = mElement->FirstChildElement(name.c_str());
-        
-        if (!child)
-            SAFE_EXCEPTION_RET("XML element " + std::string(mElement->Value()) + " has no child element " + name, XMLElement());
-        
-        return XMLElement(child);
-    }
+    if (!mElement)
+        return XMLElement();
     else
     {
-        if (!mElement)
-            return XMLElement();
+        if (name.empty())
+            return XMLElement(mElement->FirstChildElement());
         else
-        {
-            if (name.empty())
-                return XMLElement(mElement->FirstChildElement());
-            else
-                return XMLElement(mElement->FirstChildElement(name.c_str()));
-        }
+            return XMLElement(mElement->FirstChildElement(name.c_str()));
     }
 }
 
@@ -280,55 +280,40 @@ bool XMLElement::hasAttribute(const std::string& name) const
 }
 
 
-std::string XMLElement::getAttribute(const std::string& name, bool throwIfMissing) const
+std::string XMLElement::getAttribute(const std::string& name) const
 {
-    if (throwIfMissing)
+    if (!mElement)
+        return std::string();
+    else
     {
-        if (!mElement)
-            SAFE_EXCEPTION_RET("Null XML element, can not get attribute " + name, std::string());
-        
         const char* data = mElement->Attribute(name.c_str());
         
         if (!data)
-            SAFE_EXCEPTION_RET("XML element " + std::string(mElement->Value()) + " has no attribute " + name, std::string())
-        else
-            return std::string(data);
-    }
-    else
-    {
-        if (!mElement)
             return std::string();
         else
-        {
-            const char* data = mElement->Attribute(name.c_str());
-            
-            if (!data)
-                return std::string();
-            else
-                return std::string(data);
-        }
+            return std::string(data);
     }
 }
 
-bool XMLElement::getBool(const std::string& name, bool throwIfMissing) const
+bool XMLElement::getBool(const std::string& name) const
 {
-    return toBool(getAttribute(name, throwIfMissing));
+    return toBool(getAttribute(name));
 }
 
-BoundingBox XMLElement::getBoundingBox(bool throwIfMissing) const
+BoundingBox XMLElement::getBoundingBox() const
 {
     BoundingBox ret;
     
-    ret.mMin = getVector3("min", throwIfMissing);
-    ret.mMax = getVector3("max", throwIfMissing);
+    ret.mMin = getVector3("min");
+    ret.mMax = getVector3("max");
     ret.mDefined = true;
     return ret;
 }
 
-std::vector<unsigned char> XMLElement::getBuffer(const std::string& name, bool throwIfMissing) const
+std::vector<unsigned char> XMLElement::getBuffer(const std::string& name) const
 {
     std::vector<unsigned char> ret;
-    std::vector<std::string> bytes = split(getAttribute(name, throwIfMissing), ' ');
+    std::vector<std::string> bytes = split(getAttribute(name), ' ');
     
     ret.resize(bytes.size());
     for (unsigned i = 0; i < bytes.size(); ++i)
@@ -336,10 +321,10 @@ std::vector<unsigned char> XMLElement::getBuffer(const std::string& name, bool t
     return ret;
 }
 
-void XMLElement::getBuffer(const std::string& name, void* dest, unsigned size, bool throwIfMissing) const
+void XMLElement::getBuffer(const std::string& name, void* dest, unsigned size) const
 {
     std::vector<unsigned char> ret;
-    std::vector<std::string> bytes = split(getAttribute(name, throwIfMissing), ' ');
+    std::vector<std::string> bytes = split(getAttribute(name), ' ');
     unsigned char* destBytes = (unsigned char*)dest;
     if (size < bytes.size())
         SAFE_EXCEPTION("Destination buffer not big enough");
@@ -348,101 +333,101 @@ void XMLElement::getBuffer(const std::string& name, void* dest, unsigned size, b
         destBytes[i] = toInt(bytes[i]);
 }
 
-Color XMLElement::getColor(const std::string& name, bool throwIfMissing) const
+Color XMLElement::getColor(const std::string& name) const
 {
-    return toColor(getAttribute(name, throwIfMissing));
+    return toColor(getAttribute(name));
 }
 
-float XMLElement::getFloat(const std::string& name, bool throwIfMissing) const
+float XMLElement::getFloat(const std::string& name) const
 {
-    return toFloat(getAttribute(name, throwIfMissing));
+    return toFloat(getAttribute(name));
 }
 
-int XMLElement::getInt(const std::string& name, bool throwIfMissing) const
+int XMLElement::getInt(const std::string& name) const
 {
-    return toInt(getAttribute(name, throwIfMissing));
+    return toInt(getAttribute(name));
 }
 
-IntRect XMLElement::getIntRect(const std::string& name, bool throwIfMissing) const
+IntRect XMLElement::getIntRect(const std::string& name) const
 {
-    return toIntRect(getAttribute(name, throwIfMissing));
+    return toIntRect(getAttribute(name));
 }
 
-IntVector2 XMLElement::getIntVector2(const std::string& name, bool throwIfMissing) const
+IntVector2 XMLElement::getIntVector2(const std::string& name) const
 {
-    return toIntVector2(getAttribute(name, throwIfMissing));
+    return toIntVector2(getAttribute(name));
 }
 
-Quaternion XMLElement::getQuaternion(const std::string& name, bool throwIfMissing) const
+Quaternion XMLElement::getQuaternion(const std::string& name) const
 {
-    return toQuaternion(getAttribute(name, throwIfMissing));
+    return toQuaternion(getAttribute(name));
 }
 
-Rect XMLElement::getRect(const std::string& name, bool throwIfMissing) const
+Rect XMLElement::getRect(const std::string& name) const
 {
-    return toRect(getAttribute(name, throwIfMissing));
+    return toRect(getAttribute(name));
 }
 
-std::string XMLElement::getString(const std::string& name, bool throwIfMissing) const
+std::string XMLElement::getString(const std::string& name) const
 {
-    return getAttribute(name, throwIfMissing);
+    return getAttribute(name);
 }
 
-std::string XMLElement::getStringLower(const std::string& name, bool throwIfMissing) const
+std::string XMLElement::getStringLower(const std::string& name) const
 {
-    return toLower(getAttribute(name, throwIfMissing));
+    return toLower(getAttribute(name));
 }
 
-std::string XMLElement::getStringUpper(const std::string& name, bool throwIfMissing) const
+std::string XMLElement::getStringUpper(const std::string& name) const
 {
-    return toUpper(getAttribute(name, throwIfMissing));
+    return toUpper(getAttribute(name));
 }
 
-Variant XMLElement::getVariant(bool throwIfMissing) const
+Variant XMLElement::getVariant() const
 {
     Variant ret;
-    std::string type = getAttribute("type", throwIfMissing);
-    std::string value = getAttribute("value", throwIfMissing);
+    std::string type = getAttribute("type");
+    std::string value = getAttribute("value");
     
     ret.fromString(type, value);
     return ret;
 }
 
-VariantMap XMLElement::getVariantMap(bool throwIfMissing) const
+VariantMap XMLElement::getVariantMap() const
 {
     VariantMap ret;
     
-    XMLElement variantElem = getChildElement("variant", false);
-    while (variantElem.notNull())
+    XMLElement variantElem = getChildElement("variant");
+    while (variantElem)
     {
         ShortStringHash key;
         if (variantElem.hasAttribute("hash"))
             key.mData = variantElem.getInt("hash");
         else
             key = ShortStringHash(variantElem.getString("name"));
-        ret[key] =variantElem.getVariant(throwIfMissing);
+        ret[key] = variantElem.getVariant();
         variantElem = variantElem.getNextElement("variant");
     }
     
     return ret;
 }
 
-Vector2 XMLElement::getVector2(const std::string& name, bool throwIfMissing) const
+Vector2 XMLElement::getVector2(const std::string& name) const
 {
-    return toVector2(getAttribute(name, throwIfMissing));
+    return toVector2(getAttribute(name));
 }
 
-Vector3 XMLElement::getVector3(const std::string& name, bool throwIfMissing) const
+Vector3 XMLElement::getVector3(const std::string& name) const
 {
-    return toVector3(getAttribute(name, throwIfMissing));
+    return toVector3(getAttribute(name));
 }
 
-Vector4 XMLElement::getVector4(const std::string& name, bool throwIfMissing) const
+Vector4 XMLElement::getVector4(const std::string& name) const
 {
-    return toVector4(getAttribute(name, throwIfMissing));
+    return toVector4(getAttribute(name));
 }
 
-Vector4 XMLElement::getVector(const std::string& name, bool throwIfMissing) const
+Vector4 XMLElement::getVector(const std::string& name) const
 {
-    return toVector4(getAttribute(name, throwIfMissing), true);
+    return toVector4(getAttribute(name), true);
 }

+ 63 - 63
Engine/Resource/XMLElement.h

@@ -51,43 +51,43 @@ public:
     //! Create a child element
     XMLElement createChildElement(const std::string& name);
     //! Remove a child element, either first or last of them if several exist
-    void removeChildElement(const std::string& name, bool last = true);
+    bool removeChildElement(const std::string& name, bool last = true);
     //! Set an attribute
-    void setAttribute(const std::string& name, const std::string& value);
+    bool setAttribute(const std::string& name, const std::string& value);
     //! Set a bool attribute
-    void setBool(const std::string& name, bool value);
+    bool setBool(const std::string& name, bool value);
     //! Set a BoundingBox attribute
-    void setBoundingBox(const BoundingBox& value);
+    bool setBoundingBox(const BoundingBox& value);
     //! Set a buffer attribute
-    void setBuffer(const std::string& name, const void* data, unsigned size);
+    bool setBuffer(const std::string& name, const void* data, unsigned size);
     //! Set a buffer attribute
-    void setBuffer(const std::string& name, const std::vector<unsigned char>& value);
+    bool setBuffer(const std::string& name, const std::vector<unsigned char>& value);
     //! Set a Color attribute
-    void setColor(const std::string& name, const Color& value);
+    bool setColor(const std::string& name, const Color& value);
     //! Set a float attribute
-    void setFloat(const std::string& name, float value);
+    bool setFloat(const std::string& name, float value);
     //! Set an integer attribute
-    void setInt(const std::string& name, int value);
+    bool setInt(const std::string& name, int value);
     //! Set an IntRect attribute
-    void setIntRect(const std::string& name, const IntRect& value);
+    bool setIntRect(const std::string& name, const IntRect& value);
     //! Set an IntVector2 attribute
-    void setIntVector2(const std::string& name, const IntVector2& value);
+    bool setIntVector2(const std::string& name, const IntVector2& value);
     //! Set a Rect attribute
-    void setRect(const std::string& name, const Rect& value);
+    bool setRect(const std::string& name, const Rect& value);
     //! Set a Quaternion attribute
-    void setQuaternion(const std::string& name, const Quaternion& value);
+    bool setQuaternion(const std::string& name, const Quaternion& value);
     //! Set a string attribute
-    void setString(const std::string& name, const std::string& value);
+    bool setString(const std::string& name, const std::string& value);
     //! Set a Variant attribute
-    void setVariant(const Variant& value);
+    bool setVariant(const Variant& value);
     //! Set a VariantMap attribute
-    void setVariantMap(const VariantMap& value);
+    bool setVariantMap(const VariantMap& value);
     //! Set a Vector2 attribute
-    void setVector2(const std::string& name, const Vector2& value);
+    bool setVector2(const std::string& name, const Vector2& value);
     //! Set a Vector3 attribute
-    void setVector3(const std::string& name, const Vector3& value);
+    bool setVector3(const std::string& name, const Vector3& value);
     //! Set a Vector4 attribute
-    void setVector4(const std::string& name, const Vector4& value);
+    bool setVector4(const std::string& name, const Vector4& value);
     
     //! Return whether does not refer to an element
     bool isNull() const { return mElement == 0; }
@@ -101,54 +101,54 @@ public:
     std::string getText() const;
     //! Return whether has a child element
     bool hasChildElement(const std::string& name) const;
-    //! Return child element. Optionally throw an exception if missing
-    XMLElement getChildElement(const std::string& name = std::string(), bool throwIfMissing = true) const;
+    //! Return child element, or null if missing
+    XMLElement getChildElement(const std::string& name = std::string()) const;
     //! Return next sibling element
     XMLElement getNextElement(const std::string& name = std::string()) const;
     //! Return whether has an attribute
     bool hasAttribute(const std::string& name) const;
-    //! Return attribute. Optionally throw an exception if missing
-    std::string getAttribute(const std::string& name, bool throwIfMissing = true) const;
-    //! Return bool attribute. Optionally throw an exception if missing
-    bool getBool(const std::string& name, bool throwIfMissing = true) const;
-    //! Return buffer attribute. Optionally throw an exception if missing
-    std::vector<unsigned char> getBuffer(const std::string& name, bool throwIfMissing = true) const;
-    //! Copy buffer attribute into a supplied buffer. Throw exception if not big enough. Optionally throw an exception if missing
-    void getBuffer(const std::string& name, void* dest, unsigned size, bool throwIfMissing = true) const;
-    //! Return bounding box attribute. Optionally throw an exception if missing
-    BoundingBox getBoundingBox(bool throwIfMissing = true) const;
-    //! Return a Color attribute. Optionally throw an exception if missing
-    Color getColor(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a float attribute. Optionally throw an exception if missing
-    float getFloat(const std::string& name, bool throwIfMissing = true) const;
-    //! Return an integer attribute. Optionally throw an exception if missing
-    int getInt(const std::string& name, bool throwIfMissing = true) const;
-    //! Return an IntRect attribute. Optionally throw an exception if missing
-    IntRect getIntRect(const std::string& name, bool throwIfMissing = true) const;
-    //! Return an IntVector2 attribute. Optionally throw an exception if missing
-    IntVector2 getIntVector2(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a Rect attribute. Optionally throw an exception if missing
-    Rect getRect(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a Quaternion attribute. Optionally throw an exception if missing
-    Quaternion getQuaternion(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a string attribute. Optionally throw an exception if missing
-    std::string getString(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a string attribute in lowercase. Optionally throw an exception if missing
-    std::string getStringLower(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a string attribute in uppercase. Optionally throw an exception if missing
-    std::string getStringUpper(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a Variant attribute. Optionally throw an exception if missing
-    Variant getVariant(bool throwIfMissing = true) const;
-    //! Return a VariantMap attribute. Optionally throw an exception if missing
-    VariantMap getVariantMap(bool throwIfMissing = true) const;
-    //! Return a Vector2 attribute. Optionally throw an exception if missing
-    Vector2 getVector2(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a Vector3 attribute. Optionally throw an exception if missing
-    Vector3 getVector3(const std::string& name, bool throwIfMissing = true) const;
-    //! Return a Vector4 attribute. Optionally throw an exception if missing
-    Vector4 getVector4(const std::string& name, bool throwIfMissing = true) const;
-    //! Return any Vector attribute as Vector4. Missing coordinates will be zero. Optionally throw an exception if missing
-    Vector4 getVector(const std::string& name, bool throwIfMissing = true) const;
+    //! Return attribute, or empty if missing
+    std::string getAttribute(const std::string& name) const;
+    //! Return bool attribute, or false if missing
+    bool getBool(const std::string& name) const;
+    //! Return buffer attribute, or empty if missing
+    std::vector<unsigned char> getBuffer(const std::string& name) const;
+    //! Copy buffer attribute into a supplied buffer. Throw exception if not big enough
+    void getBuffer(const std::string& name, void* dest, unsigned size) const;
+    //! Return bounding box attribute, or empty if missing
+    BoundingBox getBoundingBox() const;
+    //! Return a Color attribute, or default if missing
+    Color getColor(const std::string& name) const;
+    //! Return a float attribute, or zero if missing
+    float getFloat(const std::string& name) const;
+    //! Return an integer attribute, or zero if missing
+    int getInt(const std::string& name) const;
+    //! Return an IntRect attribute, or default if missing
+    IntRect getIntRect(const std::string& name) const;
+    //! Return an IntVector2 attribute, or default if missing
+    IntVector2 getIntVector2(const std::string& name) const;
+    //! Return a Rect attribute, or default if missing
+    Rect getRect(const std::string& name) const;
+    //! Return a Quaternion attribute, or default if missing
+    Quaternion getQuaternion(const std::string& name) const;
+    //! Return a string attribute, or empty if missing
+    std::string getString(const std::string& name) const;
+    //! Return a string attribute in lowercase, or empty if missing
+    std::string getStringLower(const std::string& name) const;
+    //! Return a string attribute in uppercase, or empty if missing
+    std::string getStringUpper(const std::string& name) const;
+    //! Return a Variant attribute, or empty if missing
+    Variant getVariant() const;
+    //! Return a VariantMap attribute, or empty if missing
+    VariantMap getVariantMap() const;
+    //! Return a Vector2 attribute, or default if missing
+    Vector2 getVector2(const std::string& name) const;
+    //! Return a Vector3 attribute, or default if missing
+    Vector3 getVector3(const std::string& name) const;
+    //! Return a Vector4 attribute, or default if missing
+    Vector4 getVector4(const std::string& name) const;
+    //! Return any Vector attribute as Vector4. Missing coordinates will be zero
+    Vector4 getVector(const std::string& name) const;
     
     //! Return TinyXML element
     TiXmlElement* getElement() const { return mElement; }

+ 3 - 12
Engine/Resource/XMLFile.cpp

@@ -81,20 +81,11 @@ XMLElement XMLFile::createRootElement(const std::string& name)
     return getRootElement();
 }
 
-XMLElement XMLFile::getRootElement(const std::string& name, bool throwIfMissing) const
+XMLElement XMLFile::getRootElement(const std::string& name) const
 {
     XMLElement rootElem = XMLElement(mDocument->RootElement());
     
-    if ((rootElem.isNull()) && (throwIfMissing))
-        SAFE_EXCEPTION_RET("No root XML element", XMLElement());
-    
-    if ((!name.empty()) && (rootElem.notNull()) && (rootElem.getName() != name))
-    {
-        if (throwIfMissing)
-            SAFE_EXCEPTION_RET("XML document has no root element " + name, XMLElement())
-        else
-            rootElem = XMLElement();
-    }
-    
+    if ((rootElem.isNull()) || ((!name.empty()) && (rootElem.getName() != name)))
+        return XMLElement();
     return rootElem;
 }

+ 2 - 2
Engine/Resource/XMLFile.h

@@ -48,8 +48,8 @@ public:
     //! Clear the document and create a root element
     XMLElement createRootElement(const std::string& name);
     
-    //! Return the root element
-    XMLElement getRootElement(const std::string& name = std::string(), bool throwIfMissing = true) const;
+    //! Return the root element, with optionally specified name. Return null element if not found
+    XMLElement getRootElement(const std::string& name = std::string()) const;
     //! Return the TinyXML document
     TiXmlDocument* getDocument() const { return mDocument; }
     

+ 1 - 1
Engine/Scene/Component.cpp

@@ -228,7 +228,7 @@ void ComponentRef::readXML(const XMLElement& source)
     if (source)
     {
         mEntityID = source.getInt("id");
-        mHash = ShortStringHash(source.getString("type")) + ShortStringHash(source.getString("name", false));
+        mHash = ShortStringHash(source.getString("type")) + ShortStringHash(source.getString("name"));
     }
     else
     {

+ 5 - 5
Engine/Scene/Entity.cpp

@@ -161,8 +161,8 @@ void Entity::loadXML(const XMLElement& source, ResourceCache* cache)
     
     // Read properties
     mProperties.clear();
-    XMLElement propertyElem = source.getChildElement("property", false);
-    while (propertyElem.notNull())
+    XMLElement propertyElem = source.getChildElement("property");
+    while (propertyElem)
     {
         ShortStringHash key;
         if (propertyElem.hasAttribute("hash"))
@@ -177,11 +177,11 @@ void Entity::loadXML(const XMLElement& source, ResourceCache* cache)
     }
     
     // Create and read components
-    XMLElement componentElem = source.getChildElement("component", false);
-    while (componentElem.notNull())
+    XMLElement componentElem = source.getChildElement("component");
+    while (componentElem)
     {
         std::string type = componentElem.getString("type");
-        std::string name = componentElem.getString("name", false);
+        std::string name = componentElem.getString("name");
         Component* newComponent = createComponent(ShortStringHash(type), name);
         newComponent->loadXML(componentElem, cache);
         componentElem = componentElem.getNextElement("component");

+ 22 - 32
Engine/Scene/Scene.cpp

@@ -115,7 +115,7 @@ void Scene::interpolate(float timeStep)
     }
 }
 
-void Scene::save(Serializer& dest, bool throwOnError)
+void Scene::save(Serializer& dest)
 {
     // Write scene name
     dest.writeString(mName);
@@ -139,8 +139,6 @@ void Scene::save(Serializer& dest, bool throwOnError)
         }
         catch (...)
         {
-            if (throwOnError)
-                throw;
             // Something went wrong. Save a zero length buffer
             LOGERROR("Failed to save entity " + toString(entity->getID()));
             dest.writeVLE(0);
@@ -148,7 +146,7 @@ void Scene::save(Serializer& dest, bool throwOnError)
     }
 }
 
-void Scene::load(Deserializer& source, bool throwOnError)
+void Scene::load(Deserializer& source)
 {
     LOGINFO("Loading scene from " + source.getName());
     
@@ -167,12 +165,12 @@ void Scene::load(Deserializer& source, bool throwOnError)
     // Read entities
     unsigned numEntities = source.readUInt();
     for (unsigned i = 0; i < numEntities; ++i)
-        loadEntity(source, throwOnError);
+        loadEntity(source);
     
-    finishLoading(source, throwOnError);
+    finishLoading(source);
 }
 
-void Scene::saveXML(Serializer& dest, bool throwOnError)
+void Scene::saveXML(Serializer& dest)
 {
     XMLFile xml;
     XMLElement sceneElem = xml.createRootElement("scene");
@@ -196,8 +194,6 @@ void Scene::saveXML(Serializer& dest, bool throwOnError)
         }
         catch (...)
         {
-            if (throwOnError)
-                throw;
             // Something went wrong. Remove the element
             sceneElem.removeChildElement("entity");
             LOGERROR("Failed to save entity " + toString(entity->getID()));
@@ -207,7 +203,7 @@ void Scene::saveXML(Serializer& dest, bool throwOnError)
     xml.save(dest);
 }
 
-void Scene::loadXML(Deserializer& source, bool throwOnError)
+void Scene::loadXML(Deserializer& source)
 {
     LOGINFO("Loading XML scene from " + source.getName());
     
@@ -222,17 +218,17 @@ void Scene::loadXML(Deserializer& source, bool throwOnError)
     removeAllEntities();
     
     // Read scene name
-    mName = sceneElem.getString("name", false);
+    mName = sceneElem.getString("name");
     
     // Read extension properties
     loadPropertiesXML(sceneElem);
     
     // Read entities
-    XMLElement entityElem = sceneElem.getChildElement("entity", false);
-    while (entityElem.notNull())
-        loadEntityXML(entityElem, throwOnError);
+    XMLElement entityElem = sceneElem.getChildElement("entity");
+    while (entityElem)
+        loadEntityXML(entityElem);
     
-    finishLoading(source, throwOnError);
+    finishLoading(source);
 }
 
 void Scene::saveProperties(Serializer& dest)
@@ -448,7 +444,7 @@ void Scene::loadAsyncXML(File* file)
     removeAllEntities();
     
     // Read scene name
-    mName = sceneElem.getString("name", false);
+    mName = sceneElem.getString("name");
     
     // Read extension properties
     loadPropertiesXML(sceneElem);
@@ -456,8 +452,8 @@ void Scene::loadAsyncXML(File* file)
     // Count entities
     mAsyncTotalEntities = 0;
     mAsyncLoadedEntities = 0;
-    mAsyncXMLElement = sceneElem.getChildElement("entity", false);
-    while (mAsyncXMLElement.notNull())
+    mAsyncXMLElement = sceneElem.getChildElement("entity");
+    while (mAsyncXMLElement)
     {
         ++mAsyncTotalEntities;
         mAsyncXMLElement = mAsyncXMLElement.getNextElement("entity");
@@ -466,7 +462,7 @@ void Scene::loadAsyncXML(File* file)
     // Begin async loading
     mAsyncFile = file;
     mAsyncXMLFile = xml;
-    mAsyncXMLElement = sceneElem.getChildElement("entity", false);
+    mAsyncXMLElement = sceneElem.getChildElement("entity");
     mAsyncLoading = true;
 }
 
@@ -980,7 +976,7 @@ void Scene::updateAsyncLoading()
     {
         if (mAsyncLoadedEntities >= mAsyncTotalEntities)
         {
-            finishLoading(*mAsyncFile, false);
+            finishLoading(*mAsyncFile);
             stopAsyncLoading();
             
             using namespace AsyncLoadFinished;
@@ -992,9 +988,9 @@ void Scene::updateAsyncLoading()
         }
         
         if (!mAsyncXMLFile)
-            loadEntity(*mAsyncFile, false);
+            loadEntity(*mAsyncFile);
         else
-            loadEntityXML(mAsyncXMLElement, false);
+            loadEntityXML(mAsyncXMLElement);
         ++mAsyncLoadedEntities;
         
         if (asyncTimer.getMSec(false) >= (1000 / ASYNC_MIN_FPS))
@@ -1011,7 +1007,7 @@ void Scene::updateAsyncLoading()
     sendEvent(EVENT_ASYNCLOADPROGRESS, eventData);
 }
 
-void Scene::loadEntity(Deserializer& source, bool throwOnError)
+void Scene::loadEntity(Deserializer& source)
 {
     unsigned entityDataSize = source.readVLE();
     if (entityDataSize)
@@ -1032,19 +1028,17 @@ void Scene::loadEntity(Deserializer& source, bool throwOnError)
         }
         catch (...)
         {
-            if (throwOnError)
-                throw;
             LOGERROR("Failed to load entity " + toString(newEntity->getID()));
             removeEntity(newEntity);
         }
     }
 }
 
-void Scene::loadEntityXML(XMLElement& source, bool throwOnError)
+void Scene::loadEntityXML(XMLElement& source)
 {
     // Create the entity and let it load itself
     EntityID id = source.getInt("id");
-    std::string name = source.getString("name", false);
+    std::string name = source.getString("name");
     Entity* newEntity = createEntity(id, name);
     
     try
@@ -1054,8 +1048,6 @@ void Scene::loadEntityXML(XMLElement& source, bool throwOnError)
     }
     catch (...)
     {
-        if (throwOnError)
-            throw;
         LOGERROR("Failed to load entity " + toString(newEntity->getID()));
         removeEntity(newEntity);
     }
@@ -1079,7 +1071,7 @@ void Scene::updateNextEntityID(EntityID loadedID)
     }
 }
 
-void Scene::finishLoading(Deserializer& source, bool throwOnError)
+void Scene::finishLoading(Deserializer& source)
 {
     // Perform post-load on all entities (resolve entity & component references)
     for (std::map<EntityID, SharedPtr<Entity> >::iterator i = mEntities.begin(); i != mEntities.end(); ++i)
@@ -1090,8 +1082,6 @@ void Scene::finishLoading(Deserializer& source, bool throwOnError)
         }
         catch (...)
         {
-            if (throwOnError)
-                throw;
             LOGERROR("Failed to post-load entity " + toString(i->second->getID()));
         }
     }

+ 7 - 7
Engine/Scene/Scene.h

@@ -57,13 +57,13 @@ public:
     //! Perform client-side visual smoothing
     void interpolate(float timeStep);
     //! Write to a stream
-    void save(Serializer& dest, bool throwOnError = true);
+    void save(Serializer& dest);
     //! Read from a stream
-    void load(Deserializer& source, bool throwOnError = true);
+    void load(Deserializer& source);
     //! Write to an XML file
-    void saveXML(Serializer& dest, bool throwOnError = true);
+    void saveXML(Serializer& dest);
     //! Read from an XML file
-    void loadXML(Deserializer& source, bool throwOnError = true);
+    void loadXML(Deserializer& source);
     //! Write properties only to a stream
     void saveProperties(Serializer& dest);
     //! Read properties only from a stream
@@ -206,13 +206,13 @@ private:
     //! Update asynchronous loading. Load entities until a set time has passed
     void updateAsyncLoading();
     //! Load an entity from a stream
-    void loadEntity(Deserializer& source, bool throwOnError);
+    void loadEntity(Deserializer& source);
     //! Load an entity from an XML element
-    void loadEntityXML(XMLElement& source, bool throwOnError);
+    void loadEntityXML(XMLElement& source);
     //! Update next entity ID's after loading an entity
     void updateNextEntityID(EntityID loadedID);
     //! Perform post-load after scene loading has finished
-    void finishLoading(Deserializer& source, bool throwOnError);
+    void finishLoading(Deserializer& source);
     
     //! Scene name
     std::string mName;

+ 1 - 1
Engine/Script/ScriptInstance.cpp

@@ -161,7 +161,7 @@ void ScriptInstance::loadXML(const XMLElement& source, ResourceCache* cache)
     
     if (mMethods[METHOD_LOADXML])
     {
-        XMLElement dataElem = source.getChildElement("data", false);
+        XMLElement dataElem = source.getChildElement("data");
         if (dataElem)
         {
             std::vector<Variant> parameters;

+ 4 - 4
Engine/UI/UI.cpp

@@ -281,14 +281,14 @@ SharedPtr<UIElement> UI::loadLayout(XMLFile* file, XMLFile* styleFile)
     LOGDEBUG("Loading UI layout " + file->getName());
     
     XMLElement rootElem = file->getRootElement();
-    XMLElement childElem = rootElem.getChildElement("element", false);
+    XMLElement childElem = rootElem.getChildElement("element");
     if (!childElem)
     {
         LOGERROR("No root UI element in " + file->getName());
         return root;
     }
     
-    root = createElement(ShortStringHash(childElem.getString("type")), childElem.getString("name", false));
+    root = createElement(ShortStringHash(childElem.getString("type")), childElem.getString("name"));
     
     // First set the base style from the style file if exists, then apply UI layout overrides
     if (styleFile)
@@ -509,10 +509,10 @@ void UI::handleChar(StringHash eventType, VariantMap& eventData)
 
 void UI::loadLayout(UIElement* current, const XMLElement& elem, XMLFile* styleFile)
 {
-    XMLElement childElem = elem.getChildElement("element", false);
+    XMLElement childElem = elem.getChildElement("element");
     while (childElem)
     {
-        SharedPtr<UIElement> child = createElement(ShortStringHash(childElem.getString("type")), childElem.getString("name", false));
+        SharedPtr<UIElement> child = createElement(ShortStringHash(childElem.getString("type")), childElem.getString("name"));
         // First set the base style from the style file if exists, then apply UI layout overrides
         if (styleFile)
             child->setStyleAuto(styleFile, mCache);

+ 4 - 4
Engine/UI/UIElement.cpp

@@ -493,10 +493,10 @@ XMLElement UIElement::getStyleElement(XMLFile* file) const
     if (file)
     {
         XMLElement rootElem = file->getRootElement();
-        XMLElement childElem = rootElem.getChildElement("element", false);
+        XMLElement childElem = rootElem.getChildElement("element");
         while (childElem)
         {
-            if (childElem.getString("type", false) == getTypeName())
+            if (childElem.getString("type") == getTypeName())
                 return childElem;
             childElem = childElem.getNextElement("element");
         }
@@ -532,10 +532,10 @@ XMLElement UIElement::getStyleElement(XMLFile* file, const std::string& typeName
     if (file)
     {
         XMLElement rootElem = file->getRootElement();
-        XMLElement childElem = rootElem.getChildElement("element", false);
+        XMLElement childElem = rootElem.getChildElement("element");
         while (childElem)
         {
-            if (childElem.getString("type", false) == typeName)
+            if (childElem.getString("type") == typeName)
                 return childElem;
             childElem = childElem.getNextElement("element");
         }

+ 9 - 6
Examples/NinjaSnowWar/GameObject.cpp

@@ -339,7 +339,8 @@ void GameObject::enableAnim(const std::string& name, bool restart)
     else
     {
         AnimationState* state = model->addAnimationState(getAnim(name));
-        state->setWeight(1.0f);
+        if (state)
+            state->setWeight(1.0f);
     }
 }
 
@@ -370,11 +371,13 @@ void GameObject::enableOnlyAnimSmooth(const std::string& name, bool restart, flo
     AnimationState* state = model->getAnimationState(name);
     if (!state)
         state = model->addAnimationState(getAnim(name));
-    if (restart)
-        state->setTime(0.0f);
-    
-    // Increase weight of the animation we're activating, start from 0 if was disabled
-    state->addWeight(time);
+    if (state)
+    {
+        if (restart)
+            state->setTime(0.0f);
+        // Increase weight of the animation we're activating, start from 0 if was disabled
+        state->addWeight(time);
+    }
     
     // Decrease weight of all the rest, until at weight 0 and can be disabled
     std::vector<AnimationState*> states = model->getAnimationStates();

+ 58 - 58
Tools/OgreImporter/OgreImporter.cpp

@@ -177,11 +177,11 @@ void loadSkeleton(const std::string& inputFileName)
     {
     }
     
-    if (skeletonRoot.notNull())
+    if (skeletonRoot)
     {
-        XMLElement bonesRoot = skeletonRoot.getChildElement("bones", false);
-        XMLElement bone = bonesRoot.getChildElement("bone", false);
-        while (bone.notNull())
+        XMLElement bonesRoot = skeletonRoot.getChildElement("bones");
+        XMLElement bone = bonesRoot.getChildElement("bone");
+        while (bone)
         {
             unsigned index = bone.getInt("id");
             std::string name = bone.getString("name");
@@ -217,8 +217,8 @@ void loadSkeleton(const std::string& inputFileName)
         
         // Go through the bone hierarchy
         XMLElement boneHierarchy = skeletonRoot.getChildElement("bonehierarchy");
-        XMLElement boneParent = boneHierarchy.getChildElement("boneparent", false);
-        while (boneParent.notNull())
+        XMLElement boneParent = boneHierarchy.getChildElement("boneparent");
+        while (boneParent)
         {
             std::string bone = boneParent.getString("bone");
             std::string parent = boneParent.getString("parent");
@@ -278,10 +278,10 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
     XMLElement subMesh = subMeshes.getChildElement("submesh");
     unsigned totalVertices = 0;
     unsigned maxSubMeshVertices = 0;
-    while (subMesh.notNull())
+    while (subMesh)
     {
-        XMLElement geometry = subMesh.getChildElement("geometry", false);
-        if (geometry.notNull())
+        XMLElement geometry = subMesh.getChildElement("geometry");
+        if (geometry)
         {
             unsigned vertices = geometry.getInt("vertexcount");
             totalVertices += vertices;
@@ -293,8 +293,8 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
         subMesh = subMesh.getNextElement("submesh");
     }
     
-    XMLElement sharedGeometry = root.getChildElement("sharedgeometry", false);
-    if (sharedGeometry.notNull())
+    XMLElement sharedGeometry = root.getChildElement("sharedgeometry");
+    if (sharedGeometry)
     {
         unsigned vertices = sharedGeometry.getInt("vertexcount");
         totalVertices += vertices;
@@ -322,9 +322,9 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
     std::vector<unsigned> vertexStarts;
     vertexStarts.resize(numSubMeshes);
     
-    while (subMesh.notNull())
+    while (subMesh)
     {
-        XMLElement geometry = subMesh.getChildElement("geometry", false);
+        XMLElement geometry = subMesh.getChildElement("geometry");
         XMLElement faces = subMesh.getChildElement("faces");
         
         // If no submesh vertexbuffer, process the shared geometry, but do it only once
@@ -336,7 +336,7 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                 geometry = root.getChildElement("sharedgeometry");
         }
         
-        if (geometry.notNull())
+        if (geometry)
             vertices = geometry.getInt("vertexcount");
         
         ModelSubGeometryLodLevel subGeometryLodLevel;
@@ -374,7 +374,7 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
         if (geometry)
             bufferDef = geometry.getChildElement("vertexbuffer");
         
-        while (bufferDef.notNull())
+        while (bufferDef)
         {
             if (bufferDef.hasAttribute("positions"))
                 vBuf->mElementMask |= MASK_POSITION;
@@ -389,8 +389,8 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                 XMLElement vertex = bufferDef.getChildElement("vertex");
                 while (vertex)
                 {
-                    XMLElement position = vertex.getChildElement("position", false);
-                    if (position.notNull())
+                    XMLElement position = vertex.getChildElement("position");
+                    if (position)
                     {
                         // Convert from right- to left-handed
                         float x = position.getFloat("x");
@@ -401,8 +401,8 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                         vBuf->mVertices[vertexNum].mPosition = vec;
                         box.merge(vec);
                     }
-                    XMLElement normal = vertex.getChildElement("normal", false);
-                    if (normal.notNull())
+                    XMLElement normal = vertex.getChildElement("normal");
+                    if (normal)
                     {
                         // Convert from right- to left-handed
                         float x = normal.getFloat("x");
@@ -412,8 +412,8 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                         
                         vBuf->mVertices[vertexNum].mNormal = vec;
                     }
-                    XMLElement uv = vertex.getChildElement("texcoord", false);
-                    if (uv.notNull())
+                    XMLElement uv = vertex.getChildElement("texcoord");
+                    if (uv)
                     {
                         float x = uv.getFloat("u");
                         float y = uv.getFloat("v");
@@ -452,10 +452,10 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
         
         if (bones.size())
         {
-            XMLElement boneAssignments = subMesh.getChildElement("boneassignments", false);
+            XMLElement boneAssignments = subMesh.getChildElement("boneassignments");
             if (boneAssignments)
             {
-                XMLElement boneAssignment = boneAssignments.getChildElement("vertexboneassignment", false);
+                XMLElement boneAssignment = boneAssignments.getChildElement("vertexboneassignment");
                 while (boneAssignment)
                 {
                     unsigned vertex = boneAssignment.getInt("vertexindex") + vertexStart;
@@ -582,22 +582,22 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
     }
     
     // Process LOD levels, if any
-    XMLElement lods = root.getChildElement("levelofdetail", false);
-    if (lods.notNull())
+    XMLElement lods = root.getChildElement("levelofdetail");
+    if (lods)
     {
         try
         {
             // For now, support only generated LODs, where the vertices are the same
-            XMLElement lod = lods.getChildElement("lodgenerated", false);
-            while (lod.notNull())
+            XMLElement lod = lods.getChildElement("lodgenerated");
+            while (lod)
             {
                 float distance = M_EPSILON;
                 if (lod.hasAttribute("fromdepthsquared"))
                     distance = sqrtf(lod.getFloat("fromdepthsquared"));
                 if (lod.hasAttribute("value"))
                     distance = lod.getFloat("value");
-                XMLElement lodSubMesh = lod.getChildElement("lodfacelist", false);
-                while (lodSubMesh.notNull())
+                XMLElement lodSubMesh = lod.getChildElement("lodfacelist");
+                while (lodSubMesh)
                 {
                     unsigned subMeshIndex = lodSubMesh.getInt("submeshindex");
                     unsigned triangles = lodSubMesh.getInt("numfaces");
@@ -632,7 +632,7 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                     
                     // Append indices to the original index buffer
                     XMLElement triangle = lodSubMesh.getChildElement("face");
-                    while (triangle.notNull())
+                    while (triangle)
                     {
                         unsigned v1 = triangle.getInt("v1");
                         unsigned v2 = triangle.getInt("v2");
@@ -663,10 +663,10 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
         try
         {
             std::vector<XMLElement> poses;
-            XMLElement posesRoot = root.getChildElement("poses", false);
-            if (posesRoot.notNull())
+            XMLElement posesRoot = root.getChildElement("poses");
+            if (posesRoot)
             {
-                XMLElement pose = posesRoot.getChildElement("pose", false);
+                XMLElement pose = posesRoot.getChildElement("pose");
                 while (pose)
                 {
                     poses.push_back(pose);
@@ -675,29 +675,29 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
             }
             
             // Then process animations using the poses
-            XMLElement animsRoot = root.getChildElement("animations", false);
-            if (animsRoot.notNull())
+            XMLElement animsRoot = root.getChildElement("animations");
+            if (animsRoot)
             {
-                XMLElement anim = animsRoot.getChildElement("animation", false);
-                while (anim.notNull())
+                XMLElement anim = animsRoot.getChildElement("animation");
+                while (anim)
                 {
                     std::string name = anim.getString("name");
                     float length = anim.getFloat("length");
                     std::set<unsigned> usedPoses;
-                    XMLElement tracks = anim.getChildElement("tracks", false);
-                    if (tracks.notNull())
+                    XMLElement tracks = anim.getChildElement("tracks");
+                    if (tracks)
                     {
-                        XMLElement track = tracks.getChildElement("track", false);
-                        while (track.notNull())
+                        XMLElement track = tracks.getChildElement("track");
+                        while (track)
                         {
-                            XMLElement keyframes = track.getChildElement("keyframes", false);
-                            if (keyframes.notNull())
+                            XMLElement keyframes = track.getChildElement("keyframes");
+                            if (keyframes)
                             {
-                                XMLElement keyframe = keyframes.getChildElement("keyframe", false);
-                                while (keyframe.notNull())
+                                XMLElement keyframe = keyframes.getChildElement("keyframe");
+                                while (keyframe)
                                 {
                                     float time = keyframe.getFloat("time");
-                                    XMLElement poseref = keyframe.getChildElement("poseref", false);
+                                    XMLElement poseref = keyframe.getChildElement("poseref");
                                     // Get only the end pose
                                     if ((poseref) && (time == length))
                                         usedPoses.insert(poseref.getInt("poseindex"));
@@ -725,7 +725,7 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                         {
                             XMLElement pose = poses[*i];
                             unsigned targetSubMesh = pose.getInt("index");
-                            XMLElement poseOffset = pose.getChildElement("poseoffset", false);
+                            XMLElement poseOffset = pose.getChildElement("poseoffset");
                         
                             if (useOneBuffer)
                                 newMorph.mBuffers[bufIndex].mVertexBuffer = 0;
@@ -736,7 +736,7 @@ void loadMesh(const std::string& inputFileName, bool generateTangents, bool spli
                             
                             ModelVertexBuffer* vBuf = &vertexBuffers[newMorph.mBuffers[bufIndex].mVertexBuffer];
                             
-                            while (poseOffset.notNull())
+                            while (poseOffset)
                             {
                                 // Convert from right- to left-handed
                                 unsigned vertexIndex = poseOffset.getInt("index") + vertexStarts[targetSubMesh];
@@ -968,23 +968,23 @@ void writeOutput(const std::string& outputFileName, bool exportAnimations, bool
     dest.writeUInt(raycastLodLevel);
     dest.writeUInt(occlusionLodLevel);
     
-    XMLElement skeletonRoot = skelFile.getRootElement("", false);
-    if ((skeletonRoot.notNull()) && (exportAnimations))
+    XMLElement skeletonRoot = skelFile.getRootElement("");
+    if ((skeletonRoot) && (exportAnimations))
     {
         // Go through animations
-        XMLElement animationsRoot = skeletonRoot.getChildElement("animations", false);
+        XMLElement animationsRoot = skeletonRoot.getChildElement("animations");
         if (animationsRoot)
         {
-            XMLElement animation = animationsRoot.getChildElement("animation", false);
-            while (animation.notNull())
+            XMLElement animation = animationsRoot.getChildElement("animation");
+            while (animation)
             {
                 ModelAnimation newAnimation;
                 newAnimation.mName = animation.getString("name");
                 newAnimation.mLength = animation.getFloat("length");
                 
-                XMLElement tracksRoot = animation.getChildElement("tracks", false);
-                XMLElement track = tracksRoot.getChildElement("track", false);
-                while (track.notNull())
+                XMLElement tracksRoot = animation.getChildElement("tracks");
+                XMLElement track = tracksRoot.getChildElement("track");
+                while (track)
                 {
                     std::string trackName = track.getString("bone");
                     ModelBone* bone = 0;
@@ -1007,8 +1007,8 @@ void writeOutput(const std::string& outputFileName, bool exportAnimations, bool
                         newAnimationTrack.mChannelMask = CHANNEL_ROTATION;
                     
                     XMLElement keyFramesRoot = track.getChildElement("keyframes");
-                    XMLElement keyFrame = keyFramesRoot.getChildElement("keyframe", false);
-                    while (keyFrame.notNull())
+                    XMLElement keyFrame = keyFramesRoot.getChildElement("keyframe");
+                    while (keyFrame)
                     {
                         AnimationKeyFrame newKeyFrame;
                         

+ 17 - 17
Tools/ShaderCompiler/ShaderCompiler.cpp

@@ -230,15 +230,15 @@ void run(const std::vector<std::string>& arguments)
     XMLFile outDoc;
     XMLElement outShaders = outDoc.createRootElement("shaders");
     
-    XMLElement shader = shaders.getChildElement("shader", false);
-    while (shader.notNull())
+    XMLElement shader = shaders.getChildElement("shader");
+    while (shader)
     {
         bool writeOutput = false;
         
         std::string source = shader.getString("name");
         
         ShaderType compileType = Both;
-        std::string type = shader.getString("type", false);
+        std::string type = shader.getString("type");
         if ((type == "VS") || (type == "vs"))
             compileType = VS;
         if ((type == "PS") || (type == "ps"))
@@ -248,8 +248,8 @@ void run(const std::vector<std::string>& arguments)
         
         Shader baseShader(source, compileType);
         
-        XMLElement variation = shader.getChildElement("", false);
-        while (variation.notNull())
+        XMLElement variation = shader.getChildElement("");
+        while (variation)
         {
             std::string value = variation.getName();
             if ((value == "variation") || (value == "option"))
@@ -258,24 +258,24 @@ void run(const std::vector<std::string>& arguments)
                 
                 Variation newVar(name, value == "option");
                 
-                std::string simpleDefine = variation.getString("define", false);
+                std::string simpleDefine = variation.getString("define");
                 if (!simpleDefine.empty())
                     newVar.addDefine(simpleDefine);
                     
-                std::string simpleExclude = variation.getString("exclude", false);
+                std::string simpleExclude = variation.getString("exclude");
                 if (!simpleExclude.empty())
                     newVar.addExclude(simpleExclude);
                 
-                std::string simpleInclude = variation.getString("include", false);
+                std::string simpleInclude = variation.getString("include");
                 if (!simpleInclude.empty())
                     newVar.addInclude(simpleInclude);
                 
-                std::string simpleRequire = variation.getString("require", false);
+                std::string simpleRequire = variation.getString("require");
                 if (!simpleRequire.empty())
                     newVar.addRequire(simpleRequire);
                 
-                XMLElement define = variation.getChildElement("define", false);
-                while (define.notNull())
+                XMLElement define = variation.getChildElement("define");
+                while (define)
                 {
                     std::string name = define.getString("name");
                     newVar.addDefine(name);
@@ -283,8 +283,8 @@ void run(const std::vector<std::string>& arguments)
                     define = define.getNextElement("define");
                 }
                 
-                XMLElement exclude = variation.getChildElement("exclude", false);
-                while (exclude.notNull())
+                XMLElement exclude = variation.getChildElement("exclude");
+                while (exclude)
                 {
                     std::string name = exclude.getString("name");
                     newVar.addExclude(name);
@@ -292,8 +292,8 @@ void run(const std::vector<std::string>& arguments)
                     exclude = exclude.getNextElement("exclude");
                 }
                 
-                XMLElement include = variation.getChildElement("include", false);
-                while (include.notNull())
+                XMLElement include = variation.getChildElement("include");
+                while (include)
                 {
                     std::string name = include.getString("name");
                     newVar.addInclude(name);
@@ -301,8 +301,8 @@ void run(const std::vector<std::string>& arguments)
                     include = include.getNextElement("include");
                 }
                 
-                XMLElement require = variation.getChildElement("require", false);
-                while (require.notNull())
+                XMLElement require = variation.getChildElement("require");
+                while (require)
                 {
                     std::string name = require.getString("name");
                     newVar.addRequire(name);