Skip to content

Commit

Permalink
ParticleSpawner: Fix crash when attaching to invisible entity
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Jun 19, 2020
1 parent 495f719 commit 57df895
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/client/content_cao.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/client/particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 57df895

Please sign in to comment.