Fix client crash on deletion of an object the clients localplayer is attached to
authorsapier <Sapier at GMX dot net>
Sun, 6 Jul 2014 20:11:21 +0000 (22:11 +0200)
committersapier <Sapier at GMX dot net>
Sun, 6 Jul 2014 20:11:21 +0000 (22:11 +0200)
src/content_cao.cpp

index fe11d33da40c2ef4fbe177fdb0adbf97ffe2f9d5..02622f5b48b113754be2bb9225fe12bb934c3968 100644 (file)
@@ -736,7 +736,8 @@ ClientActiveObject* GenericCAO::getParent()
 
 void GenericCAO::removeFromScene(bool permanent)
 {
-       if((m_env != 0) && (permanent)) // Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
+       // Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
+       if((m_env != NULL) && (permanent)) 
        {
                for(std::vector<u16>::iterator ci = m_children.begin();
                                                ci != m_children.end(); ci++)
@@ -747,6 +748,12 @@ void GenericCAO::removeFromScene(bool permanent)
                }
 
                m_env->m_attachements[getId()] = 0;
+               
+               LocalPlayer* player = m_env->getLocalPlayer();
+               if (this == player->parent) {
+                       player->parent = NULL;
+                       player->isAttached = false;
+               }
        }
 
        if(m_meshnode)