]> git.lizzy.rs Git - minetest.git/commitdiff
ParticleSpawner: Fix crash when attaching to invisible entity
authorSmallJoker <mk939@ymail.com>
Fri, 19 Jun 2020 17:29:47 +0000 (19:29 +0200)
committerSmallJoker <mk939@ymail.com>
Fri, 19 Jun 2020 17:29:47 +0000 (19:29 +0200)
src/client/content_cao.h
src/client/particles.cpp

index 699148c52306416eaaa4ea318db4e04678afb888..974ff9a1eecfd376f52d80639224024dec0468ae 100644 (file)
@@ -188,10 +188,11 @@ class GenericCAO : public ClientActiveObject
                return m_matrixnode->getRelativeTransformationMatrix();
        }
 
-       inline const core::matrix4 &getAbsolutePosRotMatrix() const
+       inline const core::matrix4 *getAbsolutePosRotMatrix() const
        {
-               assert(m_matrixnode);
-               return m_matrixnode->getAbsoluteTransformation();
+               if (!m_matrixnode)
+                       return nullptr;
+               return &m_matrixnode->getAbsoluteTransformation();
        }
 
        inline f32 getStepHeight() const
index c78a3e71a12535c2d4951502c9435729448ae4fd..7acd996dcef63f35ab85e0856d11a5df210ff5c7 100644 (file)
@@ -349,7 +349,7 @@ void ParticleSpawner::step(float dtime, ClientEnvironment *env)
        const core::matrix4 *attached_absolute_pos_rot_matrix = nullptr;
        if (m_attached_id) {
                if (GenericCAO *attached = dynamic_cast<GenericCAO *>(env->getActiveObject(m_attached_id))) {
-                       attached_absolute_pos_rot_matrix = &attached->getAbsolutePosRotMatrix();
+                       attached_absolute_pos_rot_matrix = attached->getAbsolutePosRotMatrix();
                } else {
                        unloaded = true;
                }