From bc29e03b597be350fa856b1ae3d8623778a808b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sat, 21 Jan 2017 17:30:55 +0100 Subject: [PATCH] Revert "Detach the player from entities on death." (#5087) --- src/content_sao.cpp | 10 ---------- src/content_sao.h | 1 - src/script/lua_api/l_object.cpp | 15 ++++++++++++++- src/server.cpp | 2 -- src/serverobject.h | 2 -- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/content_sao.cpp b/src/content_sao.cpp index f0973082..bb62aea7 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -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); diff --git a/src/content_sao.h b/src/content_sao.h index 56a26fb0..c3674fa2 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -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); diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 1fa3663c..be445170 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -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; } diff --git a/src/server.cpp b/src/server.cpp index 1e570404..1656b9f5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -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; diff --git a/src/serverobject.h b/src/serverobject.h index dfe6312f..38204980 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -166,8 +166,6 @@ public: {} virtual void removeAttachmentChild(int child_id) {} - virtual void detachFromParent() - {} virtual const UNORDERED_SET &getAttachmentChildIds() { static const UNORDERED_SET rv; return rv; } virtual ObjectProperties* accessObjectProperties()