Revert "Detach the player from entities on death." (#5087)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Sat, 21 Jan 2017 16:30:55 +0000 (17:30 +0100)
committerGitHub <noreply@github.com>
Sat, 21 Jan 2017 16:30:55 +0000 (17:30 +0100)
src/content_sao.cpp
src/content_sao.h
src/script/lua_api/l_object.cpp
src/server.cpp
src/serverobject.h

index f0973082d7d90656e2fad020b6617ac1bf19e874..bb62aea7d8622e8c7e48f33861a9173286b0dcda 100644 (file)
@@ -203,16 +203,6 @@ void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
        *rotation = m_attachment_rotation;
 }
 
-void UnitSAO::detachFromParent()
-{
-       ServerActiveObject *parent = NULL;
-       if (m_attachment_parent_id)
-               parent = m_env->getActiveObject(m_attachment_parent_id);
-       setAttachment(NULL, "", v3f(0, 0, 0), v3f(0, 0, 0));
-       if (parent != NULL)
-               parent->removeAttachmentChild(m_id);
-}
-
 void UnitSAO::addAttachmentChild(int child_id)
 {
        m_attachment_child_ids.insert(child_id);
index 56a26fb0d242b73ad5f843700cea75fa7226db6b..c3674fa2dfa38e17e7309227b2305420837c6f13 100644 (file)
@@ -49,7 +49,6 @@ public:
        void setBonePosition(const std::string &bone, v3f position, v3f rotation);
        void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
        void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
-       void detachFromParent();
        void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
        void addAttachmentChild(int child_id);
        void removeAttachmentChild(int child_id);
index 1fa3663ca5b100d2b010fedd23f03a62ceab08e9..be4451704f7c67fe06f03dcec7153cda0a8f81fd 100644 (file)
@@ -710,7 +710,20 @@ int ObjectRef::l_set_detach(lua_State *L)
        ServerActiveObject *co = getobject(ref);
        if (co == NULL)
                return 0;
-       co->detachFromParent();
+
+       int parent_id = 0;
+       std::string bone = "";
+       v3f position;
+       v3f rotation;
+       co->getAttachment(&parent_id, &bone, &position, &rotation);
+       ServerActiveObject *parent = NULL;
+       if (parent_id)
+               parent = env->getActiveObject(parent_id);
+
+       // Do it
+       co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
+       if (parent != NULL)
+               parent->removeAttachmentChild(co->getId());
        return 0;
 }
 
index 1e57040421fd4aa991072bc7cd0f9b7620f6b1fb..1656b9f5a557c9b2769be576095e1a8d6a2777b8 100644 (file)
@@ -2560,8 +2560,6 @@ void Server::DiePlayer(u16 peer_id)
        if (!playersao)
                return;
 
-       playersao->detachFromParent();
-
        infostream << "Server::DiePlayer(): Player "
                        << playersao->getPlayer()->getName()
                        << " dies" << std::endl;
index dfe6312f082cde44e8ac6aa336c446d482f76ca1..38204980e439b57beda6722863a6d16d73166c97 100644 (file)
@@ -166,8 +166,6 @@ public:
        {}
        virtual void removeAttachmentChild(int child_id)
        {}
-       virtual void detachFromParent()
-       {}
        virtual const UNORDERED_SET<int> &getAttachmentChildIds()
        { static const UNORDERED_SET<int> rv; return rv; }
        virtual ObjectProperties* accessObjectProperties()