Skip to content

Commit 2e19af9

Browse files
sapiersapier
sapier
authored and
sapier
committedJul 6, 2014
Fix client crash on deletion of an object the clients localplayer is attached to
1 parent b459f53 commit 2e19af9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/content_cao.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ ClientActiveObject* GenericCAO::getParent()
736736

737737
void GenericCAO::removeFromScene(bool permanent)
738738
{
739-
if((m_env != 0) && (permanent)) // Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
739+
// Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
740+
if((m_env != NULL) && (permanent))
740741
{
741742
for(std::vector<u16>::iterator ci = m_children.begin();
742743
ci != m_children.end(); ci++)
@@ -747,6 +748,12 @@ void GenericCAO::removeFromScene(bool permanent)
747748
}
748749

749750
m_env->m_attachements[getId()] = 0;
751+
752+
LocalPlayer* player = m_env->getLocalPlayer();
753+
if (this == player->parent) {
754+
player->parent = NULL;
755+
player->isAttached = false;
756+
}
750757
}
751758

752759
if(m_meshnode)

0 commit comments

Comments
 (0)
Please sign in to comment.